videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/src/testvideocollectionwrapper_p.cpp
changeset 62 0e1e938beb1a
parent 17 69946d1824c4
equal deleted inserted replaced
59:a76e86df7ccd 62:0e1e938beb1a
    16 * 
    16 * 
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 // INCLUDES
    20 // INCLUDES
       
    21 #include <qdebug.h>
    21 #include <qabstractitemmodel.h>
    22 #include <qabstractitemmodel.h>
    22 #include <hbapplication.h>
    23 #include <hbapplication.h>
    23 #include "testvideocollectionwrapper_p.h"
    24 #include "testvideocollectionwrapper_p.h"
    24 #include "videocollectionwrapper.h"
    25 #include "videocollectionwrapper.h"
    25 #include "videocollectioncommon.h"
    26 #include "videocollectioncommon.h"
    26 #include "videolistdatamodel.h"
    27 #include "videolistdatamodel.h"
    27 #include "videosortfilterproxymodel.h"
    28 #include "videoproxymodelgeneric.h"
    28 #include "videocollectionclient.h"
    29 #include "videocollectionclient.h"
    29 #include "vcxmyvideosdefs.h"
    30 #include "vcxmyvideosdefs.h"
    30 
    31 
    31 #define private public
    32 #define private public
    32 #include "videocollectionwrapper_p.h"
    33 #include "videocollectionwrapper_p.h"
    84 //
    85 //
    85 void TestVideCollectionWrapper_p::testGetModelInitFail()
    86 void TestVideCollectionWrapper_p::testGetModelInitFail()
    86 {
    87 {
    87     QVERIFY(mTestObject);        
    88     QVERIFY(mTestObject);        
    88     
    89     
    89     VideoSortFilterProxyModel *proxyGotten = 0;
    90     VideoProxyModelGeneric *proxyGotten = 0;
    90            
    91     
    91     // source model init fails
       
    92     VideoListDataModel::mInitFails = true;
    92     VideoListDataModel::mInitFails = true;
    93     VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos;
    93     // Test source model init fails
    94     proxyGotten = mTestObject->getModel(type);
    94     
       
    95     proxyGotten = mTestObject->getGenericModel();
    95     QVERIFY(!proxyGotten);
    96     QVERIFY(!proxyGotten);
    96     
    97     
    97     VideoListDataModel::mInitFails = false;
    98     proxyGotten = mTestObject->getAllVideosModel();
    98     VideoSortFilterProxyModel::setInitFailure(true);
       
    99     
       
   100     // VideoCollectionWrapper::EAllvideos -> init fails
       
   101     type = VideoCollectionCommon::EModelTypeAllVideos;
       
   102     proxyGotten = mTestObject->getModel(type);
       
   103     QVERIFY(!proxyGotten);
    99     QVERIFY(!proxyGotten);
   104     
   100     
   105     // VideoCollectionWrapper::ECollections -> init fails
   101     proxyGotten = mTestObject->getCollectionsModel();
   106     type = VideoCollectionCommon::EModelTypeAllVideos;
       
   107     proxyGotten = mTestObject->getModel(type);
       
   108     QVERIFY(!proxyGotten);
   102     QVERIFY(!proxyGotten);
   109     
   103     
   110     // VideoCollectionWrapper::EGeneric -> init fails
   104     proxyGotten = mTestObject->getCollectionContentModel();
   111     type = VideoCollectionCommon::EModelTypeGeneric;
       
   112     proxyGotten = mTestObject->getModel(type);
       
   113     QVERIFY(!proxyGotten);
       
   114     
       
   115     type = VideoCollectionCommon::EModelTypeCollectionContent;
       
   116     proxyGotten = mTestObject->getModel(type);
       
   117     QVERIFY(!proxyGotten);
   105     QVERIFY(!proxyGotten);
   118 }
   106 }
   119 
       
   120  
   107  
   121 // -----------------------------------------------------------------------------
   108 // -----------------------------------------------------------------------------
   122 // testGetModelSucceed
   109 // testGetModelSucceed
   123 // -----------------------------------------------------------------------------
   110 // -----------------------------------------------------------------------------
   124 //
   111 //
   125 void TestVideCollectionWrapper_p::testGetModelSucceed()
   112 void TestVideCollectionWrapper_p::testGetModelSucceed()
   126 {
   113 {
   127     QVERIFY(mTestObject);        
   114     QVERIFY(mTestObject);        
   128        
       
   129     VideoSortFilterProxyModel *proxyGotten = 0;
       
   130     VideoSortFilterProxyModel::setInitFailure(false);
       
   131     VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos;
       
   132 
   115 
   133     // VideoCollectionWrapper::EAllvideos
   116     VideoListDataModel::mInitFails = false;
   134     type = VideoCollectionCommon::EModelTypeAllVideos;
   117     
   135     proxyGotten = mTestObject->getModel(type);
   118     VideoProxyModelGeneric *proxyGotten = 0;
       
   119     VideoProxyModelGeneric *proxyGotten2 = 0;
       
   120 
       
   121     proxyGotten = mTestObject->getAllVideosModel();
   136     QVERIFY(proxyGotten);
   122     QVERIFY(proxyGotten);
   137     QVERIFY(proxyGotten->mType == type);
   123     
   138     proxyGotten = mTestObject->getModel(type);
   124     QString name = proxyGotten->metaObject()->className();
   139     QVERIFY(proxyGotten);
   125     QString expectedName = QString("VideoProxyModelAllVideos");
   140     QVERIFY(proxyGotten->mType == type);
   126     QVERIFY(name == expectedName);
       
   127     // again
       
   128     proxyGotten2 = mTestObject->getAllVideosModel();
       
   129     QCOMPARE(proxyGotten, proxyGotten2);
   141     delete proxyGotten;
   130     delete proxyGotten;
   142     proxyGotten = 0;
   131     proxyGotten = 0;
   143    
   132 
   144     // VideoCollectionWrapper::ECollections
   133     proxyGotten = mTestObject->getCollectionsModel();
   145     type = VideoCollectionCommon::EModelTypeCollections;
       
   146     proxyGotten = mTestObject->getModel(type);
       
   147     QVERIFY(proxyGotten);
   134     QVERIFY(proxyGotten);
   148     QVERIFY(proxyGotten->mType == type);
   135     name = proxyGotten->metaObject()->className();
   149     proxyGotten = mTestObject->getModel(type);
   136     expectedName = QString("VideoProxyModelCollections");
   150     QVERIFY(proxyGotten);
   137     QVERIFY(name == expectedName);
   151     QVERIFY(proxyGotten->mType == type);
   138     // again
   152     delete proxyGotten;
   139     proxyGotten2 = mTestObject->getCollectionsModel();
   153     proxyGotten = 0;
   140     QCOMPARE(proxyGotten, proxyGotten2);
   154    
       
   155    // VideoCollectionWrapper::EGeneric
       
   156     type = VideoCollectionCommon::EModelTypeGeneric;
       
   157     proxyGotten = mTestObject->getModel(type);
       
   158     QVERIFY(proxyGotten);
       
   159     QVERIFY(proxyGotten->mType == type);
       
   160     proxyGotten = mTestObject->getModel(type);
       
   161     QVERIFY(proxyGotten);
       
   162     QVERIFY(proxyGotten->mType == type);
       
   163     delete proxyGotten;
   141     delete proxyGotten;
   164     proxyGotten = 0;
   142     proxyGotten = 0;
   165     
   143     
   166     // VideoCollectionWrapper::ECollectionContent
   144     proxyGotten = mTestObject->getCollectionContentModel();
   167     type = VideoCollectionCommon::EModelTypeCollectionContent;
       
   168     proxyGotten = mTestObject->getModel(type);
       
   169     QVERIFY(proxyGotten);
   145     QVERIFY(proxyGotten);
   170     QVERIFY(proxyGotten->mType == type);
   146     name = proxyGotten->metaObject()->className();
   171     proxyGotten = mTestObject->getModel(type);
   147     expectedName = QString("VideoProxyModelContent");
       
   148     QVERIFY(name == expectedName);
       
   149     // again
       
   150     proxyGotten2 = mTestObject->getCollectionContentModel();
       
   151     QCOMPARE(proxyGotten, proxyGotten2);
       
   152     delete proxyGotten;
       
   153     proxyGotten = 0;
       
   154 
       
   155     proxyGotten = mTestObject->getGenericModel();
   172     QVERIFY(proxyGotten);
   156     QVERIFY(proxyGotten);
   173     QVERIFY(proxyGotten->mType == type);
   157     name = proxyGotten->metaObject()->className();
       
   158     expectedName = QString("VideoProxyModelGeneric");
       
   159     QVERIFY(name == expectedName);
       
   160     // again
       
   161     proxyGotten2 = mTestObject->getGenericModel();
       
   162     QCOMPARE(proxyGotten, proxyGotten2);
   174     delete proxyGotten;
   163     delete proxyGotten;
   175     proxyGotten = 0;
   164     proxyGotten = 0;
   176 }
   165 }
   177 
   166 
   178 // -----------------------------------------------------------------------------
   167 // -----------------------------------------------------------------------------
   182 void TestVideCollectionWrapper_p::testAboutToQuitSlot()
   171 void TestVideCollectionWrapper_p::testAboutToQuitSlot()
   183 {
   172 {
   184     QVERIFY(mTestObject);        
   173     QVERIFY(mTestObject);        
   185     connect(this, SIGNAL(testSignal()), mTestObject, SLOT(aboutToQuitSlot()));
   174     connect(this, SIGNAL(testSignal()), mTestObject, SLOT(aboutToQuitSlot()));
   186     
   175     
   187     VideoSortFilterProxyModel *proxyGotten = 0;
   176     VideoProxyModelGeneric *proxyGotten = 0;
   188     VideoSortFilterProxyModel::setInitFailure(false);
   177     proxyGotten = mTestObject->getAllVideosModel();
   189     VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos;
       
   190     proxyGotten = mTestObject->getModel(type);
       
   191     QVERIFY(proxyGotten);
   178     QVERIFY(proxyGotten);
   192     QVERIFY(!mTestObject->mSourceModel.isNull());
   179     QVERIFY(!mTestObject->mSourceModel.isNull());
   193     emit testSignal();
       
   194     QVERIFY(mTestObject->mSourceModel.isNull());
       
   195     
   180     
   196     emit testSignal();
   181     emit testSignal();
   197     QVERIFY(mTestObject->mSourceModel.isNull());
   182     QVERIFY(mTestObject->mSourceModel.isNull());
       
   183     proxyGotten = mTestObject->getAllVideosModel();
       
   184     QVERIFY(!proxyGotten);
   198     
   185     
       
   186     emit testSignal();
       
   187     QVERIFY(mTestObject->mSourceModel.isNull());
       
   188     proxyGotten = mTestObject->getAllVideosModel();
       
   189     QVERIFY(!proxyGotten);
       
   190 
   199     disconnect(this, SIGNAL(testSignal()), mTestObject, SLOT(aboutToQuitSlot()));
   191     disconnect(this, SIGNAL(testSignal()), mTestObject, SLOT(aboutToQuitSlot()));
   200 }
   192 }
   201 
       
   202 
   193 
   203 // End of file
   194 // End of file
   204     
   195     
   205 
   196 
   206 
   197