videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/src/testvideocollectionwrapper_p.cpp
author hgs
Fri, 16 Apr 2010 18:13:14 +0300
changeset 36 8aed59de29f9
parent 34 bbb98528c666
child 58 d2b028fd1f7d
permissions -rw-r--r--
201015
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34
hgs
parents:
diff changeset
     1
hgs
parents:
diff changeset
     2
/**
hgs
parents:
diff changeset
     3
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
hgs
parents:
diff changeset
     4
* All rights reserved.
hgs
parents:
diff changeset
     5
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     6
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     7
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     8
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     9
*
hgs
parents:
diff changeset
    10
* Initial Contributors:
hgs
parents:
diff changeset
    11
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    12
*
hgs
parents:
diff changeset
    13
* Contributors:
hgs
parents:
diff changeset
    14
*
hgs
parents:
diff changeset
    15
* Description:   tester for methods in VideoCollectionWrapperPrivate
hgs
parents:
diff changeset
    16
* 
hgs
parents:
diff changeset
    17
*/
hgs
parents:
diff changeset
    18
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
// INCLUDES
hgs
parents:
diff changeset
    21
#include <qabstractitemmodel.h>
hgs
parents:
diff changeset
    22
#include <hbapplication.h>
hgs
parents:
diff changeset
    23
#include "testvideocollectionwrapper_p.h"
hgs
parents:
diff changeset
    24
#include "videocollectionwrapper.h"
hgs
parents:
diff changeset
    25
#include "videocollectioncommon.h"
hgs
parents:
diff changeset
    26
#include "videolistdatamodel.h"
hgs
parents:
diff changeset
    27
#include "videosortfilterproxymodel.h"
hgs
parents:
diff changeset
    28
#include "videocollectionclient.h"
hgs
parents:
diff changeset
    29
#include "vcxmyvideosdefs.h"
hgs
parents:
diff changeset
    30
hgs
parents:
diff changeset
    31
#define private public
hgs
parents:
diff changeset
    32
#include "videocollectionwrapper_p.h"
hgs
parents:
diff changeset
    33
#undef private
hgs
parents:
diff changeset
    34
hgs
parents:
diff changeset
    35
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    36
// main
hgs
parents:
diff changeset
    37
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    38
//
hgs
parents:
diff changeset
    39
int main(int argc, char *argv[])
hgs
parents:
diff changeset
    40
{
hgs
parents:
diff changeset
    41
    TestVideCollectionWrapper_p tv;
hgs
parents:
diff changeset
    42
    HbApplication app(argc, argv);
hgs
parents:
diff changeset
    43
    int res;
hgs
parents:
diff changeset
    44
    if(argc > 1)
hgs
parents:
diff changeset
    45
    {   
hgs
parents:
diff changeset
    46
        res = QTest::qExec(&tv, argc, argv);
hgs
parents:
diff changeset
    47
    }
hgs
parents:
diff changeset
    48
    else
hgs
parents:
diff changeset
    49
    {
hgs
parents:
diff changeset
    50
        char *pass[3];
hgs
parents:
diff changeset
    51
        pass[0] = argv[0];
hgs
parents:
diff changeset
    52
        pass[1] = "-o";
hgs
parents:
diff changeset
    53
        pass[2] = "c:\\data\\testvideocollectionwrapper_p.txt";
hgs
parents:
diff changeset
    54
        res = QTest::qExec(&tv, 3, pass);
hgs
parents:
diff changeset
    55
    }
hgs
parents:
diff changeset
    56
    
hgs
parents:
diff changeset
    57
    return res;
hgs
parents:
diff changeset
    58
}
hgs
parents:
diff changeset
    59
hgs
parents:
diff changeset
    60
hgs
parents:
diff changeset
    61
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    62
// init
hgs
parents:
diff changeset
    63
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    64
//
hgs
parents:
diff changeset
    65
void TestVideCollectionWrapper_p::init()
hgs
parents:
diff changeset
    66
{
hgs
parents:
diff changeset
    67
    mTestObject = new VideoCollectionWrapperPrivate();
hgs
parents:
diff changeset
    68
    QVERIFY(mTestObject);
hgs
parents:
diff changeset
    69
}
hgs
parents:
diff changeset
    70
hgs
parents:
diff changeset
    71
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    72
// cleanup
hgs
parents:
diff changeset
    73
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    74
//
hgs
parents:
diff changeset
    75
void TestVideCollectionWrapper_p::cleanup()
hgs
parents:
diff changeset
    76
{
hgs
parents:
diff changeset
    77
    delete mTestObject;  
hgs
parents:
diff changeset
    78
    mTestObject = 0;
hgs
parents:
diff changeset
    79
}
hgs
parents:
diff changeset
    80
hgs
parents:
diff changeset
    81
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    82
// testGetModelInitFail
hgs
parents:
diff changeset
    83
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    84
//
hgs
parents:
diff changeset
    85
void TestVideCollectionWrapper_p::testGetModelInitFail()
hgs
parents:
diff changeset
    86
{
hgs
parents:
diff changeset
    87
    QVERIFY(mTestObject);        
hgs
parents:
diff changeset
    88
    
hgs
parents:
diff changeset
    89
    VideoSortFilterProxyModel *proxyGotten = 0;
hgs
parents:
diff changeset
    90
           
hgs
parents:
diff changeset
    91
    // source model init fails
hgs
parents:
diff changeset
    92
    VideoListDataModel::mInitFails = true;
36
hgs
parents: 34
diff changeset
    93
    VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos;
34
hgs
parents:
diff changeset
    94
    proxyGotten = mTestObject->getModel(type);
hgs
parents:
diff changeset
    95
    QVERIFY(!proxyGotten);
hgs
parents:
diff changeset
    96
    
hgs
parents:
diff changeset
    97
    VideoListDataModel::mInitFails = false;
hgs
parents:
diff changeset
    98
    VideoSortFilterProxyModel::setInitFailure(true);
hgs
parents:
diff changeset
    99
    
hgs
parents:
diff changeset
   100
    // VideoCollectionWrapper::EAllvideos -> init fails
36
hgs
parents: 34
diff changeset
   101
    type = VideoCollectionCommon::EModelTypeAllVideos;
34
hgs
parents:
diff changeset
   102
    proxyGotten = mTestObject->getModel(type);
hgs
parents:
diff changeset
   103
    QVERIFY(!proxyGotten);
hgs
parents:
diff changeset
   104
    
hgs
parents:
diff changeset
   105
    // VideoCollectionWrapper::ECollections -> init fails
36
hgs
parents: 34
diff changeset
   106
    type = VideoCollectionCommon::EModelTypeAllVideos;
34
hgs
parents:
diff changeset
   107
    proxyGotten = mTestObject->getModel(type);
hgs
parents:
diff changeset
   108
    QVERIFY(!proxyGotten);
hgs
parents:
diff changeset
   109
    
hgs
parents:
diff changeset
   110
    // VideoCollectionWrapper::EGeneric -> init fails
36
hgs
parents: 34
diff changeset
   111
    type = VideoCollectionCommon::EModelTypeGeneric;
34
hgs
parents:
diff changeset
   112
    proxyGotten = mTestObject->getModel(type);
hgs
parents:
diff changeset
   113
    QVERIFY(!proxyGotten);
hgs
parents:
diff changeset
   114
    
36
hgs
parents: 34
diff changeset
   115
    type = VideoCollectionCommon::EModelTypeCollectionContent;
34
hgs
parents:
diff changeset
   116
    proxyGotten = mTestObject->getModel(type);
hgs
parents:
diff changeset
   117
    QVERIFY(!proxyGotten);
hgs
parents:
diff changeset
   118
}
hgs
parents:
diff changeset
   119
hgs
parents:
diff changeset
   120
 
hgs
parents:
diff changeset
   121
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   122
// testGetModelSucceed
hgs
parents:
diff changeset
   123
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   124
//
hgs
parents:
diff changeset
   125
void TestVideCollectionWrapper_p::testGetModelSucceed()
hgs
parents:
diff changeset
   126
{
hgs
parents:
diff changeset
   127
    QVERIFY(mTestObject);        
hgs
parents:
diff changeset
   128
       
hgs
parents:
diff changeset
   129
    VideoSortFilterProxyModel *proxyGotten = 0;
hgs
parents:
diff changeset
   130
    VideoSortFilterProxyModel::setInitFailure(false);
36
hgs
parents: 34
diff changeset
   131
    VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos;
hgs
parents: 34
diff changeset
   132
34
hgs
parents:
diff changeset
   133
    // VideoCollectionWrapper::EAllvideos
36
hgs
parents: 34
diff changeset
   134
    type = VideoCollectionCommon::EModelTypeAllVideos;
34
hgs
parents:
diff changeset
   135
    proxyGotten = mTestObject->getModel(type);
hgs
parents:
diff changeset
   136
    QVERIFY(proxyGotten);
hgs
parents:
diff changeset
   137
    QVERIFY(proxyGotten->mType == type);
hgs
parents:
diff changeset
   138
    proxyGotten = mTestObject->getModel(type);
hgs
parents:
diff changeset
   139
    QVERIFY(proxyGotten);
hgs
parents:
diff changeset
   140
    QVERIFY(proxyGotten->mType == type);
hgs
parents:
diff changeset
   141
    delete proxyGotten;
hgs
parents:
diff changeset
   142
    proxyGotten = 0;
hgs
parents:
diff changeset
   143
   
hgs
parents:
diff changeset
   144
    // VideoCollectionWrapper::ECollections
36
hgs
parents: 34
diff changeset
   145
    type = VideoCollectionCommon::EModelTypeCollections;
34
hgs
parents:
diff changeset
   146
    proxyGotten = mTestObject->getModel(type);
hgs
parents:
diff changeset
   147
    QVERIFY(proxyGotten);
hgs
parents:
diff changeset
   148
    QVERIFY(proxyGotten->mType == type);
hgs
parents:
diff changeset
   149
    proxyGotten = mTestObject->getModel(type);
hgs
parents:
diff changeset
   150
    QVERIFY(proxyGotten);
hgs
parents:
diff changeset
   151
    QVERIFY(proxyGotten->mType == type);
hgs
parents:
diff changeset
   152
    delete proxyGotten;
hgs
parents:
diff changeset
   153
    proxyGotten = 0;
hgs
parents:
diff changeset
   154
   
hgs
parents:
diff changeset
   155
   // VideoCollectionWrapper::EGeneric
36
hgs
parents: 34
diff changeset
   156
    type = VideoCollectionCommon::EModelTypeGeneric;
34
hgs
parents:
diff changeset
   157
    proxyGotten = mTestObject->getModel(type);
hgs
parents:
diff changeset
   158
    QVERIFY(proxyGotten);
hgs
parents:
diff changeset
   159
    QVERIFY(proxyGotten->mType == type);
hgs
parents:
diff changeset
   160
    proxyGotten = mTestObject->getModel(type);
hgs
parents:
diff changeset
   161
    QVERIFY(proxyGotten);
hgs
parents:
diff changeset
   162
    QVERIFY(proxyGotten->mType == type);
hgs
parents:
diff changeset
   163
    delete proxyGotten;
hgs
parents:
diff changeset
   164
    proxyGotten = 0;
hgs
parents:
diff changeset
   165
    
hgs
parents:
diff changeset
   166
    // VideoCollectionWrapper::ECollectionContent
36
hgs
parents: 34
diff changeset
   167
    type = VideoCollectionCommon::EModelTypeCollectionContent;
34
hgs
parents:
diff changeset
   168
    proxyGotten = mTestObject->getModel(type);
hgs
parents:
diff changeset
   169
    QVERIFY(proxyGotten);
hgs
parents:
diff changeset
   170
    QVERIFY(proxyGotten->mType == type);
hgs
parents:
diff changeset
   171
    proxyGotten = mTestObject->getModel(type);
hgs
parents:
diff changeset
   172
    QVERIFY(proxyGotten);
hgs
parents:
diff changeset
   173
    QVERIFY(proxyGotten->mType == type);
hgs
parents:
diff changeset
   174
    delete proxyGotten;
hgs
parents:
diff changeset
   175
    proxyGotten = 0;
hgs
parents:
diff changeset
   176
}
hgs
parents:
diff changeset
   177
hgs
parents:
diff changeset
   178
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   179
// testAboutToQuitSlot
hgs
parents:
diff changeset
   180
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   181
//
hgs
parents:
diff changeset
   182
void TestVideCollectionWrapper_p::testAboutToQuitSlot()
hgs
parents:
diff changeset
   183
{
hgs
parents:
diff changeset
   184
    QVERIFY(mTestObject);        
hgs
parents:
diff changeset
   185
    connect(this, SIGNAL(testSignal()), mTestObject, SLOT(aboutToQuitSlot()));
hgs
parents:
diff changeset
   186
    
hgs
parents:
diff changeset
   187
    VideoSortFilterProxyModel *proxyGotten = 0;
hgs
parents:
diff changeset
   188
    VideoSortFilterProxyModel::setInitFailure(false);
36
hgs
parents: 34
diff changeset
   189
    VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos;
34
hgs
parents:
diff changeset
   190
    proxyGotten = mTestObject->getModel(type);
hgs
parents:
diff changeset
   191
    QVERIFY(proxyGotten);
hgs
parents:
diff changeset
   192
    QVERIFY(!mTestObject->mSourceModel.isNull());
hgs
parents:
diff changeset
   193
    emit testSignal();
hgs
parents:
diff changeset
   194
    QVERIFY(mTestObject->mSourceModel.isNull());
hgs
parents:
diff changeset
   195
    
hgs
parents:
diff changeset
   196
    emit testSignal();
hgs
parents:
diff changeset
   197
    QVERIFY(mTestObject->mSourceModel.isNull());
hgs
parents:
diff changeset
   198
    
hgs
parents:
diff changeset
   199
    disconnect(this, SIGNAL(testSignal()), mTestObject, SLOT(aboutToQuitSlot()));
hgs
parents:
diff changeset
   200
}
hgs
parents:
diff changeset
   201
hgs
parents:
diff changeset
   202
hgs
parents:
diff changeset
   203
// End of file
hgs
parents:
diff changeset
   204
    
hgs
parents:
diff changeset
   205
hgs
parents:
diff changeset
   206