logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/src/ut_logsdbconnector.cpp
author hgs
Mon, 23 Aug 2010 18:14:51 +0300
changeset 15 76d2cf7a585e
parent 8 6c9acdc6adc0
child 17 90fe74753f71
permissions -rw-r--r--
201033
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
#include "ut_logsdbconnector.h"
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include "logsdbconnector.h"
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include "logsevent.h"
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include "logsmodel.h"
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include "logsreader.h"
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include "logscommondata.h"
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include "centralrepository_stub_helper.h"
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <QtTest/QtTest>
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
Q_DECLARE_METATYPE(QList<int>)
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
15
hgs
parents: 8
diff changeset
    29
#define LOGS_TEST_CREATE_EVENT_WITHOUT_IDX(eventName, id, eventState ) \
hgs
parents: 8
diff changeset
    30
LogsEvent* eventName = new LogsEvent; \
hgs
parents: 8
diff changeset
    31
eventName->setLogId(id);\
hgs
parents: 8
diff changeset
    32
eventName->setIsInView(true); \
hgs
parents: 8
diff changeset
    33
eventName->mEventState = eventState; \
hgs
parents: 8
diff changeset
    34
mDbConnector->mEvents.insert(id, eventName)
hgs
parents: 8
diff changeset
    35
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#define LOGS_TEST_CREATE_EVENT(eventName, index, eventState ) \
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
LogsEvent* eventName = new LogsEvent; \
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
eventName->setIndex(index); \
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
eventName->setLogId(index);\
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
eventName->setIsInView(true); \
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
eventName->mEventState = eventState; \
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
mDbConnector->mEvents.insert(index, eventName)
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
15
hgs
parents: 8
diff changeset
    44
#define ADD_EVENT_WITH_ID( arr, id ) \
hgs
parents: 8
diff changeset
    45
{\
hgs
parents: 8
diff changeset
    46
LogsEvent* ev = new LogsEvent;\
hgs
parents: 8
diff changeset
    47
ev->setLogId(id);\
hgs
parents: 8
diff changeset
    48
arr.append(ev);\
hgs
parents: 8
diff changeset
    49
}
hgs
parents: 8
diff changeset
    50
hgs
parents: 8
diff changeset
    51
#define ADD_EVENT_WITH_ID_2( arr, id ) \
hgs
parents: 8
diff changeset
    52
{\
hgs
parents: 8
diff changeset
    53
LogsEvent ev;\
hgs
parents: 8
diff changeset
    54
ev.setLogId(id);\
hgs
parents: 8
diff changeset
    55
arr.append(ev);\
hgs
parents: 8
diff changeset
    56
}
hgs
parents: 8
diff changeset
    57
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
void UT_LogsDbConnector::initTestCase()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
void UT_LogsDbConnector::cleanupTestCase()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
void UT_LogsDbConnector::init()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
    mDbConnector = new LogsDbConnector(mEvents);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
void UT_LogsDbConnector::cleanup()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
    delete mDbConnector;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
    mDbConnector = 0;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
void UT_LogsDbConnector::testConstructor()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
    QVERIFY( mDbConnector );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
void UT_LogsDbConnector::testInit()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
    QVERIFY( !mDbConnector->mLogsRemove );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
    QVERIFY( mDbConnector->init() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
    QVERIFY( mDbConnector->mReader );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
    QVERIFY( mDbConnector->mLogsRemove );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
    QVERIFY( mDbConnector->mLogEventStrings.iFetched.length() > 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
    QVERIFY( !mDbConnector->mCompressionEnabled );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
    QVERIFY( LogsCommonData::getInstance().maxReadSize() == logsReadSizeUndefined );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
    // Resource control enabled
15
hgs
parents: 8
diff changeset
    95
    CentralRepositoryStubHelper::setCurrentVal(logsDefaultMatchLength + 2);
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
    LogsDbConnector* connector = new LogsDbConnector(mEvents, false, true);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
    QVERIFY( connector->init() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
    QVERIFY( connector->mReader );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
    QVERIFY( connector->mLogsRemove );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
    QVERIFY( connector->mCompressionEnabled );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
    QVERIFY( LogsCommonData::getInstance().maxReadSize() == logsReadSizeCompressEnabled );
15
hgs
parents: 8
diff changeset
   102
    QCOMPARE( LogsCommonData::getInstance().telNumMatchLen(), logsDefaultMatchLength + 2 );
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
    delete connector;
15
hgs
parents: 8
diff changeset
   104
    
hgs
parents: 8
diff changeset
   105
    // Match len not found, default is used
hgs
parents: 8
diff changeset
   106
    CentralRepositoryStubHelper::setCurrentVal(logsDefaultMatchLength + 2);
hgs
parents: 8
diff changeset
   107
    CentralRepositoryStubHelper::setFailCode( -1 );
hgs
parents: 8
diff changeset
   108
    connector = new LogsDbConnector(mEvents);
hgs
parents: 8
diff changeset
   109
    QVERIFY( connector->init() == 0 );
hgs
parents: 8
diff changeset
   110
    QVERIFY( connector->mReader );
hgs
parents: 8
diff changeset
   111
    QVERIFY( connector->mLogsRemove );
hgs
parents: 8
diff changeset
   112
    QCOMPARE( LogsCommonData::getInstance().telNumMatchLen(), logsDefaultMatchLength );
hgs
parents: 8
diff changeset
   113
    
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
void  UT_LogsDbConnector::testClearList()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
    QVERIFY( !mDbConnector->mLogsRemove );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
    QVERIFY( !mDbConnector->clearList(LogsModel::TypeLogsClearAll) );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
    mDbConnector->init();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
    QVERIFY( mDbConnector->mLogsRemove );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
    QVERIFY( mDbConnector->clearList(LogsModel::TypeLogsClearAll) );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
void UT_LogsDbConnector::testClearEvents()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
    QVERIFY( !mDbConnector->mLogsRemove );
15
hgs
parents: 8
diff changeset
   129
    QList<LogsEvent*> events;
hgs
parents: 8
diff changeset
   130
    ADD_EVENT_WITH_ID(events, 1);
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
    QVERIFY( !mDbConnector->clearEvents(events) ); // sync
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
    mDbConnector->init();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
    QVERIFY( mDbConnector->mLogsRemove );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
    mDbConnector->clearEvents(events); 
15
hgs
parents: 8
diff changeset
   136
    QVERIFY( mDbConnector->mReader->mLocked );
hgs
parents: 8
diff changeset
   137
    QVERIFY( !mDbConnector->clearEvents(events) ); // Already clearing
hgs
parents: 8
diff changeset
   138
    QVERIFY( mDbConnector->mReader->mLocked );
hgs
parents: 8
diff changeset
   139
    qDeleteAll(events);
hgs
parents: 8
diff changeset
   140
    
hgs
parents: 8
diff changeset
   141
    // Remove completed or removeError causes read lock release
hgs
parents: 8
diff changeset
   142
    mDbConnector->removeCompleted();
hgs
parents: 8
diff changeset
   143
    QVERIFY( !mDbConnector->mReader->mLocked );
hgs
parents: 8
diff changeset
   144
    mDbConnector->mReader->mLocked = true;
hgs
parents: 8
diff changeset
   145
    mDbConnector->logsRemoveErrorOccured(-1);
hgs
parents: 8
diff changeset
   146
    QVERIFY( !mDbConnector->mReader->mLocked );
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
void UT_LogsDbConnector::testMarkEventsSeen()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
{
15
hgs
parents: 8
diff changeset
   151
    QList<LogsEvent*> events;
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
    QSignalSpy spy( mDbConnector, SIGNAL(markingCompleted(int)) );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    // Not ready
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
    mDbConnector->mEventsSeen.clear();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
    mDbConnector->markEventsSeen(events);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
    QVERIFY( mDbConnector->mEventsSeen.count() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
    // No events
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
    mDbConnector->init();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
    mDbConnector->markEventsSeen(events);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
    QVERIFY( mDbConnector->mEventsSeen.count() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
    // Marking missed as seen (one is already seen)
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
    LOGS_TEST_CREATE_EVENT(event, 0, LogsEvent::EventAdded );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
    event->setDirection(LogsEvent::DirMissed);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
    LOGS_TEST_CREATE_EVENT(event2, 1, LogsEvent::EventAdded );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
    event2->setDirection(LogsEvent::DirMissed);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
    LOGS_TEST_CREATE_EVENT(event3, 2, LogsEvent::EventAdded );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
    event3->setDirection(LogsEvent::DirMissed);
15
hgs
parents: 8
diff changeset
   171
    ADD_EVENT_WITH_ID(events, 0);
hgs
parents: 8
diff changeset
   172
    ADD_EVENT_WITH_ID(events, 1);
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
    QVERIFY( mDbConnector->markEventsSeen(events) );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
    QVERIFY( mDbConnector->mEventsSeen.count() == 2 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
    QVERIFY( mDbConnector->mReader->mCurrentEventId == 0 ); // Started modifying
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
    // Trying to clear missed again, id is appended to mark list, old modifying process in ongoing
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
    // and is not interrupted
15
hgs
parents: 8
diff changeset
   179
    ADD_EVENT_WITH_ID(events, 2);
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
    QVERIFY( !mDbConnector->markEventsSeen(events) );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
    QVERIFY( mDbConnector->mEventsSeen.count() == 3 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
    QVERIFY( mDbConnector->mReader->mCurrentEventId == 0 ); // Modifying still previous
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
    // Completed previous modifying, next one in queue is modified
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
    mDbConnector->mReader->Cancel();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
    mDbConnector->eventModifyingCompleted();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
    QVERIFY( mDbConnector->mEventsSeen.count() == 2 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
    QVERIFY( mDbConnector->mReader->mCurrentEventId == 1 ); // Started modifying next one
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
    QVERIFY( spy.count() == 0 ); // Not yet totally completed
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
    // Last pending gets completed
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
    mDbConnector->mEventsSeen.takeLast(); // Now only one pending left
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
    mDbConnector->eventModifyingCompleted();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
    QVERIFY( mDbConnector->mEventsSeen.count() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
    QVERIFY( spy.count() == 1 ); // Completion was signaled with err 0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
    QVERIFY( spy.takeFirst().at(0).toInt() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
    // Clearing all, ids are not appended as those are already in modification list
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
    mDbConnector->mEventsSeen.clear();
15
hgs
parents: 8
diff changeset
   200
    ADD_EVENT_WITH_ID_2(mDbConnector->mEventsSeen, 0);
hgs
parents: 8
diff changeset
   201
    ADD_EVENT_WITH_ID_2(mDbConnector->mEventsSeen, 1);
hgs
parents: 8
diff changeset
   202
    ADD_EVENT_WITH_ID_2(mDbConnector->mEventsSeen, 2);
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
    QVERIFY( !mDbConnector->markEventsSeen(events) );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
    QVERIFY( mDbConnector->mEventsSeen.count() == 3 );
15
hgs
parents: 8
diff changeset
   205
    
hgs
parents: 8
diff changeset
   206
    // Marked events contains merged duplicates which will be handled same way
hgs
parents: 8
diff changeset
   207
    // as any other event
hgs
parents: 8
diff changeset
   208
    mDbConnector->mEventsSeen.clear();
hgs
parents: 8
diff changeset
   209
    qDeleteAll(events);
hgs
parents: 8
diff changeset
   210
    events.clear();
hgs
parents: 8
diff changeset
   211
    ADD_EVENT_WITH_ID(events, 8);
hgs
parents: 8
diff changeset
   212
    ADD_EVENT_WITH_ID(events, 9);
hgs
parents: 8
diff changeset
   213
    ADD_EVENT_WITH_ID_2( events.at(0)->mergedDuplicates(), 88 );
hgs
parents: 8
diff changeset
   214
    ADD_EVENT_WITH_ID_2( events.at(0)->mergedDuplicates(), 9 ); // already exists in main event list
hgs
parents: 8
diff changeset
   215
    QVERIFY( !mDbConnector->markEventsSeen(events) );
hgs
parents: 8
diff changeset
   216
    QVERIFY( mDbConnector->mEventsSeen.count() == 3 );
hgs
parents: 8
diff changeset
   217
    QVERIFY( mDbConnector->mEventsSeen.at(0).logId() == 8 );
hgs
parents: 8
diff changeset
   218
    QVERIFY( mDbConnector->mEventsSeen.at(1).logId() == 88 );
hgs
parents: 8
diff changeset
   219
    QVERIFY( mDbConnector->mEventsSeen.at(2).logId() == 9 );
hgs
parents: 8
diff changeset
   220
    qDeleteAll(events);
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
void UT_LogsDbConnector::testReadDuplicates()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
    QSignalSpy spy( mDbConnector, SIGNAL(duplicatesRead()) );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
    // Not ready
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
    QVERIFY( mDbConnector->readDuplicates(2) != 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
    // Previous results are cleared when starting ok
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
    LogsEvent* event = new LogsEvent;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
    mDbConnector->mDuplicatedEvents.append(event);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
    mDbConnector->init();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
    mDbConnector->readDuplicates(2);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
    QVERIFY( mDbConnector->mDuplicatedEvents.count() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
    // Completes
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
    LogsEvent* event2 = new LogsEvent;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
    LogsEvent* event3 = new LogsEvent;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
    QList<LogsEvent*> duplicates;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
    duplicates.append(event2);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
    duplicates.append(event3);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
    mDbConnector->duplicatesReadingCompleted(duplicates);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
    QVERIFY( mDbConnector->mDuplicatedEvents.count() == 2 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
    QVERIFY( spy.count() == 1 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
    // Client reads those events
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
    QList<LogsEvent*> takenEvents = mDbConnector->takeDuplicates();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
    QVERIFY( mDbConnector->mDuplicatedEvents.count() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
    QVERIFY( takenEvents.count() == 2 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
void UT_LogsDbConnector::testStart()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
    // No reader, starting fails
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
    QVERIFY( mDbConnector->start() == -1 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
    // Starting ok
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
    mDbConnector->init();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
    QVERIFY( mDbConnector->start() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
void UT_LogsDbConnector::testReadCompleted()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
    qRegisterMetaType< QList<int> >("QList<int>");
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
    QSignalSpy spyAdded(mDbConnector, SIGNAL(dataAdded(QList<int>)));
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
    QSignalSpy spyRemoved(mDbConnector, SIGNAL(dataRemoved(QList<int>)));
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
    QSignalSpy spyUpdated(mDbConnector, SIGNAL(dataUpdated(QList<int>)));
6
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   270
    QSignalSpy spyReset(mDbConnector, SIGNAL(dataReset()));
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
    // No events, no signal
15
hgs
parents: 8
diff changeset
   273
    mDbConnector->readCompleted();
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
    QVERIFY( spyAdded.count() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
    QVERIFY( spyRemoved.count() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
    QVERIFY( spyUpdated.count() == 0 );
6
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   277
    QVERIFY( spyReset.count() == 0 );
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
    
15
hgs
parents: 8
diff changeset
   279
    // Events exists, their indexes are signaled, indexes are assigned at this phase
hgs
parents: 8
diff changeset
   280
    LOGS_TEST_CREATE_EVENT_WITHOUT_IDX(event, 0, LogsEvent::EventAdded );
hgs
parents: 8
diff changeset
   281
    QCOMPARE( event->index(), -1 );
hgs
parents: 8
diff changeset
   282
    mDbConnector->readCompleted();
hgs
parents: 8
diff changeset
   283
    QCOMPARE( event->index(), 0 );
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
    QVERIFY( spyAdded.count() == 1 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
    QList<int> addedIndexes = qvariant_cast< QList<int> >(spyAdded.at(0).at(0));
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
    QVERIFY( addedIndexes.count() == 1 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
    QVERIFY( addedIndexes.at(0) == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
    QVERIFY( spyRemoved.count() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
    QVERIFY( spyUpdated.count() == 0 );
6
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   290
    QVERIFY( spyReset.count() == 0 );
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
    QVERIFY( mDbConnector->mEvents.count() == 1 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
    QVERIFY( mEvents.count() == 1 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
    // 2 more events added, their indexes are signaled
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
    event->mEventState = LogsEvent::EventNotUpdated;
15
hgs
parents: 8
diff changeset
   296
    LOGS_TEST_CREATE_EVENT_WITHOUT_IDX(event2, 0, LogsEvent::EventAdded );
hgs
parents: 8
diff changeset
   297
    LOGS_TEST_CREATE_EVENT_WITHOUT_IDX(event3, 1, LogsEvent::EventAdded );
hgs
parents: 8
diff changeset
   298
    mDbConnector->readCompleted();
hgs
parents: 8
diff changeset
   299
    QCOMPARE( event2->index(), 0 );
hgs
parents: 8
diff changeset
   300
    QCOMPARE( event3->index(), 1 );
hgs
parents: 8
diff changeset
   301
    QCOMPARE( event->index(), 2 );
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
    QVERIFY( spyAdded.count() == 2 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
    QList<int> addedIndexes2 = qvariant_cast< QList<int> >(spyAdded.at(1).at(0));
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
    QVERIFY( addedIndexes2.count() == 2 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
    QVERIFY( addedIndexes2.at(0) == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
    QVERIFY( addedIndexes2.at(1) == 1 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
    QVERIFY( spyRemoved.count() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
    QVERIFY( spyUpdated.count() == 0 );
6
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   309
    QVERIFY( spyReset.count() == 0 );
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
    QVERIFY( mDbConnector->mEvents.count() == 3 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
    QVERIFY( mEvents.count() == 3 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
    // One of the events updated (index 1)
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
    event->mEventState = LogsEvent::EventNotUpdated;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
    event2->mEventState = LogsEvent::EventNotUpdated;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
    event3->mEventState = LogsEvent::EventUpdated;
15
hgs
parents: 8
diff changeset
   317
    mDbConnector->readCompleted(); 
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
    QVERIFY( spyAdded.count() == 2 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
    QVERIFY( spyRemoved.count() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
    QVERIFY( spyUpdated.count() == 1 );
6
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   321
    QVERIFY( spyReset.count() == 0 );
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
    QList<int> updatedIndexes = qvariant_cast< QList<int> >(spyUpdated.at(0).at(0));
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
    QVERIFY( updatedIndexes.count() == 1 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
    QVERIFY( updatedIndexes.at(0) == 1 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
    QVERIFY( mDbConnector->mEvents.count() == 3 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
    QVERIFY( mEvents.count() == 3 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
    // One of the events removed (index 2)
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
    event->setIsInView(false);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
    event3->mEventState = LogsEvent::EventNotUpdated;
15
hgs
parents: 8
diff changeset
   331
    mDbConnector->readCompleted();
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
    QVERIFY( spyAdded.count() == 2 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
    QVERIFY( spyRemoved.count() == 1 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
    QVERIFY( spyUpdated.count() == 1 );
6
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   335
    QVERIFY( spyReset.count() == 0 );
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
    QList<int> removedIndexes = qvariant_cast< QList<int> >(spyRemoved.at(0).at(0));
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
    QVERIFY( removedIndexes.count() == 1 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
    QVERIFY( removedIndexes.at(0) == 2 ); // index 2
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
    QVERIFY( mDbConnector->mEvents.count() == 2 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
    QVERIFY( mEvents.count() == 2 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
    
6
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   342
    // Event added and removed, reset should be signaled
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   343
    mDbConnector->mEvents.at(0)->mEventState = LogsEvent::EventAdded;
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   344
    mDbConnector->mEvents.at(1)->mIsInView = false;
15
hgs
parents: 8
diff changeset
   345
    mDbConnector->readCompleted();
6
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   346
    QVERIFY( spyAdded.count() == 2 );
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   347
    QVERIFY( spyRemoved.count() == 1 );
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   348
    QVERIFY( spyUpdated.count() == 1 );
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   349
    QVERIFY( spyReset.count() == 1 );
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   350
    QVERIFY( mDbConnector->mEvents.count() == 1 );
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   351
    QVERIFY( mEvents.count() == 1 );
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   352
8
hgs
parents: 6
diff changeset
   353
    // Read completed when compression is enabled, reader is not stopped
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
    QVERIFY( mDbConnector->init() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
    QVERIFY( mDbConnector->start() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
    QVERIFY( mDbConnector->mReader->mLogViewRecent != 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
    mDbConnector->mCompressionEnabled = true;
15
hgs
parents: 8
diff changeset
   358
    mDbConnector->readCompleted();
8
hgs
parents: 6
diff changeset
   359
    QVERIFY( mDbConnector->mReader->mLogViewRecent != 0 );
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
void UT_LogsDbConnector::testErrorOccurred()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
    // If pending event modifying, completion is signaled
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
    QSignalSpy spy( mDbConnector, SIGNAL(markingCompleted(int)) );
15
hgs
parents: 8
diff changeset
   366
    ADD_EVENT_WITH_ID_2(mDbConnector->mEventsSeen, 0);
hgs
parents: 8
diff changeset
   367
    ADD_EVENT_WITH_ID_2(mDbConnector->mEventsSeen, 1);
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
    mDbConnector->errorOccurred(-3);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
    QVERIFY( spy.count() == 1 ); // Completion was signaled with err -3
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
    QVERIFY( spy.takeFirst().at(0).toInt() == -3 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
    QVERIFY( mDbConnector->mEventsSeen.count() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
void UT_LogsDbConnector::testUpdateDetails()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
    QSignalSpy spyUpdated(mDbConnector, SIGNAL(dataUpdated(QList<int>)));
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
    QVERIFY( !mDbConnector->mReader );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
    QVERIFY( mDbConnector->updateDetails(false) == -1 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
    QVERIFY( spyUpdated.count() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
    mDbConnector->init();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
    QVERIFY( mDbConnector->mReader );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
    LOGS_TEST_CREATE_EVENT(event, 0, LogsEvent::EventUpdated );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
    QVERIFY( mDbConnector->updateDetails(false) == 0 );
15
hgs
parents: 8
diff changeset
   385
    QVERIFY( spyUpdated.count() == 0 ); // Will happen asynchronously
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
void UT_LogsDbConnector::testClearMissedCallsCounter()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
    // Not ready
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
    QVERIFY( mDbConnector->clearMissedCallsCounter() != 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
    // Ready and value is changed
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
    mDbConnector->init();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
    CentralRepositoryStubHelper::reset();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
    CentralRepositoryStubHelper::setCurrentVal(5);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
    QVERIFY( mDbConnector->clearMissedCallsCounter() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
    QVERIFY( CentralRepositoryStubHelper::currentVal() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
    // Ready and no need to change value as it is already zero
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
    QVERIFY( mDbConnector->clearMissedCallsCounter() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
    QVERIFY( CentralRepositoryStubHelper::currentVal() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
    // Fails with some error
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
    CentralRepositoryStubHelper::setCurrentVal(100);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
    CentralRepositoryStubHelper::setFailCode(KErrNotFound);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
    QVERIFY( mDbConnector->clearMissedCallsCounter() != 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
void UT_LogsDbConnector::testRefreshData()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
    QVERIFY( mDbConnector->refreshData() != 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
    // Resource control enabled, no reader
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
    mDbConnector->mResourceControl = true;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
    QVERIFY( mDbConnector->refreshData() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
    // Reader exists, not compressed before, nothing done
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
    mDbConnector->init();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
    mDbConnector->mCompressionEnabled = false;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
    QVERIFY( mDbConnector->refreshData() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
    QVERIFY( !mDbConnector->mReader->IsActive() );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
    QVERIFY( LogsCommonData::getInstance().maxReadSize() == logsReadSizeUndefined );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
    // Reader exists, compressed before, reading started
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
    mDbConnector->mCompressionEnabled = true;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
    QVERIFY( mDbConnector->refreshData() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
    QVERIFY( mDbConnector->mReader->IsActive() );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
    QVERIFY( !mDbConnector->mCompressionEnabled );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
    QVERIFY( LogsCommonData::getInstance().maxReadSize() == logsReadSizeUndefined );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
    // Reading not started again as already active
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
    LogsCommonData::getInstance().configureReadSize(30, LogsEvent::DirUndefined);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
    mDbConnector->mCompressionEnabled = true;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
    QVERIFY( mDbConnector->refreshData() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
    QVERIFY( mDbConnector->mReader->IsActive() );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
    QVERIFY( !mDbConnector->mCompressionEnabled );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
    QVERIFY( LogsCommonData::getInstance().maxReadSize() == logsReadSizeUndefined );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
void UT_LogsDbConnector::testCompressData()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
    qRegisterMetaType< QList<int> >("QList<int>");
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
    QSignalSpy spyRemoved(mDbConnector, SIGNAL(dataRemoved(QList<int>)));
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
    QVERIFY( mDbConnector->compressData() != 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
    // Reader exists, zero events, nothing really done
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
    mDbConnector->mResourceControl = true;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
    mDbConnector->init();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
    mDbConnector->mCompressionEnabled = false;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
    QVERIFY( mDbConnector->compressData() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
    QVERIFY( mDbConnector->mCompressionEnabled );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
    QVERIFY( LogsCommonData::getInstance().maxReadSize() == logsReadSizeCompressEnabled );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
    QVERIFY( spyRemoved.count() == 1 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
    QList<int> removedIndexes = qvariant_cast< QList<int> >(spyRemoved.at(0).at(0));
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
    QVERIFY( removedIndexes.count() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
        
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
    // Less events than compression limit is, nothing really done
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
    int numEvents = 3;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
    for ( int i = 0; i < numEvents; i++ ){
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
        LOGS_TEST_CREATE_EVENT(event, i, LogsEvent::EventAdded );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
    }
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
    mDbConnector->mCompressionEnabled = false;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
    QVERIFY( mDbConnector->compressData() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
    QVERIFY( mDbConnector->mCompressionEnabled );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
    QVERIFY( LogsCommonData::getInstance().maxReadSize() == logsReadSizeCompressEnabled );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
    QVERIFY( spyRemoved.count() == 2 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
    QList<int> removedIndexes2 = qvariant_cast< QList<int> >(spyRemoved.at(1).at(0));
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
    QVERIFY( removedIndexes2.count() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
    QVERIFY( mDbConnector->mModelEvents.count() == numEvents );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
    // More events than compression limit is, extra events removed
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
    int numEventsMoreThanCompressLimit = ( numEvents + logsReadSizeCompressEnabled );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
    for ( int i = numEvents; i < numEventsMoreThanCompressLimit; i++ ){
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
       LOGS_TEST_CREATE_EVENT(event, i, LogsEvent::EventAdded );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   477
    }
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   478
    mDbConnector->mCompressionEnabled = false;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
    QVERIFY( mDbConnector->compressData() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
    QVERIFY( mDbConnector->mCompressionEnabled );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
    QVERIFY( LogsCommonData::getInstance().maxReadSize() == logsReadSizeCompressEnabled );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
    QVERIFY( spyRemoved.count() == 3 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
    QList<int> removedIndexes3 = qvariant_cast< QList<int> >(spyRemoved.at(2).at(0));
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
    QVERIFY( removedIndexes3.count() == numEvents );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
    // Check indexes of those removed events (3 oldest events)
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
    QVERIFY( removedIndexes3.at(0) == ( numEventsMoreThanCompressLimit - 3 ) ); 
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
    QVERIFY( removedIndexes3.at(1) == ( numEventsMoreThanCompressLimit - 2) );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
    QVERIFY( removedIndexes3.at(2) == ( numEventsMoreThanCompressLimit - 1 ) );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
    QVERIFY( mDbConnector->mModelEvents.count() == logsReadSizeCompressEnabled );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
void UT_LogsDbConnector::testPredictiveSearchStatus()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
    // Not ready
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
    QVERIFY( mDbConnector->predictiveSearchStatus() != 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
    // Ready and value returned
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
    mDbConnector->init();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
    CentralRepositoryStubHelper::reset();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
    CentralRepositoryStubHelper::setCurrentVal(2);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
    QVERIFY( mDbConnector->predictiveSearchStatus() == 2 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
    // Fails with some error
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
    CentralRepositoryStubHelper::setCurrentVal(2);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
    CentralRepositoryStubHelper::setFailCode(KErrNotSupported);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
    QVERIFY( mDbConnector->predictiveSearchStatus() == KErrNotSupported );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
void UT_LogsDbConnector::testSetPredictiveSearch()
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
    // Not ready
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
    QVERIFY( mDbConnector->setPredictiveSearch(true) != 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
    // Ready and value change is not allowed
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
    mDbConnector->init();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
    CentralRepositoryStubHelper::reset();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
    CentralRepositoryStubHelper::setCurrentVal(0);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
    QVERIFY( mDbConnector->setPredictiveSearch(true) != 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
    QVERIFY( CentralRepositoryStubHelper::currentVal() == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
    // Ready and value is changed
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
    CentralRepositoryStubHelper::setCurrentVal(2);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
    QVERIFY( mDbConnector->setPredictiveSearch(true) == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
    QVERIFY( CentralRepositoryStubHelper::currentVal() == 1 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
    // Ready and value is changed
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
    CentralRepositoryStubHelper::setCurrentVal(1);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
    QVERIFY( mDbConnector->setPredictiveSearch(false) == 0 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
    QVERIFY( CentralRepositoryStubHelper::currentVal() == 2 );
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
        
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
    // Fails with some error
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
    CentralRepositoryStubHelper::setCurrentVal(1);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
    CentralRepositoryStubHelper::setFailCode(KErrNotFound);
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
    QVERIFY( mDbConnector->setPredictiveSearch(false) == KErrNotFound ); 
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
}
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536