videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/src/testvideocollectionwrapper_p.cpp
changeset 36 8aed59de29f9
parent 34 bbb98528c666
child 58 d2b028fd1f7d
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
    85 void TestVideCollectionWrapper_p::testGetModelInitFail()
    85 void TestVideCollectionWrapper_p::testGetModelInitFail()
    86 {
    86 {
    87     QVERIFY(mTestObject);        
    87     QVERIFY(mTestObject);        
    88     
    88     
    89     VideoSortFilterProxyModel *proxyGotten = 0;
    89     VideoSortFilterProxyModel *proxyGotten = 0;
    90     int type = -1;
       
    91            
    90            
    92     // source model init fails
    91     // source model init fails
    93     VideoListDataModel::mInitFails = true;
    92     VideoListDataModel::mInitFails = true;
    94     type = VideoCollectionWrapper::EAllVideos;
    93     VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos;
    95     proxyGotten = mTestObject->getModel(type);
    94     proxyGotten = mTestObject->getModel(type);
    96     QVERIFY(!proxyGotten);
    95     QVERIFY(!proxyGotten);
    97     
    96     
    98     VideoListDataModel::mInitFails = false;
    97     VideoListDataModel::mInitFails = false;
    99     VideoSortFilterProxyModel::setInitFailure(true);
    98     VideoSortFilterProxyModel::setInitFailure(true);
   100     
    99     
   101     // VideoCollectionWrapper::EAllvideos -> init fails
   100     // VideoCollectionWrapper::EAllvideos -> init fails
   102     type = VideoCollectionWrapper::EAllVideos;
   101     type = VideoCollectionCommon::EModelTypeAllVideos;
   103     proxyGotten = mTestObject->getModel(type);
   102     proxyGotten = mTestObject->getModel(type);
   104     QVERIFY(!proxyGotten);
   103     QVERIFY(!proxyGotten);
   105     
   104     
   106     // VideoCollectionWrapper::ECollections -> init fails
   105     // VideoCollectionWrapper::ECollections -> init fails
   107     type = VideoCollectionWrapper::ECollections;
   106     type = VideoCollectionCommon::EModelTypeAllVideos;
   108     proxyGotten = mTestObject->getModel(type);
   107     proxyGotten = mTestObject->getModel(type);
   109     QVERIFY(!proxyGotten);
   108     QVERIFY(!proxyGotten);
   110     
   109     
   111     // VideoCollectionWrapper::EGeneric -> init fails
   110     // VideoCollectionWrapper::EGeneric -> init fails
   112     type = VideoCollectionWrapper::EGeneric;
   111     type = VideoCollectionCommon::EModelTypeGeneric;
   113     proxyGotten = mTestObject->getModel(type);
   112     proxyGotten = mTestObject->getModel(type);
   114     QVERIFY(!proxyGotten);
   113     QVERIFY(!proxyGotten);
   115     
   114     
   116     type = VideoCollectionWrapper::ECollectionContent;
   115     type = VideoCollectionCommon::EModelTypeCollectionContent;
   117     proxyGotten = mTestObject->getModel(type);
   116     proxyGotten = mTestObject->getModel(type);
   118     QVERIFY(!proxyGotten);
   117     QVERIFY(!proxyGotten);
   119     
       
   120     // called with invalid type param
       
   121     type = -1;
       
   122     VideoListDataModel::mInitFails = false;
       
   123     proxyGotten = mTestObject->getModel(type);
       
   124     QVERIFY(!proxyGotten);
       
   125     
       
   126 }
   118 }
   127 
   119 
   128  
   120  
   129 // -----------------------------------------------------------------------------
   121 // -----------------------------------------------------------------------------
   130 // testGetModelSucceed
   122 // testGetModelSucceed
   133 void TestVideCollectionWrapper_p::testGetModelSucceed()
   125 void TestVideCollectionWrapper_p::testGetModelSucceed()
   134 {
   126 {
   135     QVERIFY(mTestObject);        
   127     QVERIFY(mTestObject);        
   136        
   128        
   137     VideoSortFilterProxyModel *proxyGotten = 0;
   129     VideoSortFilterProxyModel *proxyGotten = 0;
   138     int type = -1;    
       
   139     VideoSortFilterProxyModel::setInitFailure(false);
   130     VideoSortFilterProxyModel::setInitFailure(false);
       
   131     VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos;
       
   132 
   140     // VideoCollectionWrapper::EAllvideos
   133     // VideoCollectionWrapper::EAllvideos
   141     type = VideoCollectionWrapper::EAllVideos;
   134     type = VideoCollectionCommon::EModelTypeAllVideos;
   142     proxyGotten = mTestObject->getModel(type);
   135     proxyGotten = mTestObject->getModel(type);
   143     QVERIFY(proxyGotten);
   136     QVERIFY(proxyGotten);
   144     QVERIFY(proxyGotten->mType == type);
   137     QVERIFY(proxyGotten->mType == type);
   145     proxyGotten = mTestObject->getModel(type);
   138     proxyGotten = mTestObject->getModel(type);
   146     QVERIFY(proxyGotten);
   139     QVERIFY(proxyGotten);
   147     QVERIFY(proxyGotten->mType == type);
   140     QVERIFY(proxyGotten->mType == type);
   148     delete proxyGotten;
   141     delete proxyGotten;
   149     proxyGotten = 0;
   142     proxyGotten = 0;
   150    
   143    
   151     // VideoCollectionWrapper::ECollections
   144     // VideoCollectionWrapper::ECollections
   152     type = VideoCollectionWrapper::ECollections;
   145     type = VideoCollectionCommon::EModelTypeCollections;
   153     proxyGotten = mTestObject->getModel(type);
   146     proxyGotten = mTestObject->getModel(type);
   154     QVERIFY(proxyGotten);
   147     QVERIFY(proxyGotten);
   155     QVERIFY(proxyGotten->mType == type);
   148     QVERIFY(proxyGotten->mType == type);
   156     proxyGotten = mTestObject->getModel(type);
   149     proxyGotten = mTestObject->getModel(type);
   157     QVERIFY(proxyGotten);
   150     QVERIFY(proxyGotten);
   158     QVERIFY(proxyGotten->mType == type);
   151     QVERIFY(proxyGotten->mType == type);
   159     delete proxyGotten;
   152     delete proxyGotten;
   160     proxyGotten = 0;
   153     proxyGotten = 0;
   161    
   154    
   162    // VideoCollectionWrapper::EGeneric
   155    // VideoCollectionWrapper::EGeneric
   163     type = VideoCollectionWrapper::EGeneric;
   156     type = VideoCollectionCommon::EModelTypeGeneric;
   164     proxyGotten = mTestObject->getModel(type);
   157     proxyGotten = mTestObject->getModel(type);
   165     QVERIFY(proxyGotten);
   158     QVERIFY(proxyGotten);
   166     QVERIFY(proxyGotten->mType == type);
   159     QVERIFY(proxyGotten->mType == type);
   167     proxyGotten = mTestObject->getModel(type);
   160     proxyGotten = mTestObject->getModel(type);
   168     QVERIFY(proxyGotten);
   161     QVERIFY(proxyGotten);
   169     QVERIFY(proxyGotten->mType == type);
   162     QVERIFY(proxyGotten->mType == type);
   170     delete proxyGotten;
   163     delete proxyGotten;
   171     proxyGotten = 0;
   164     proxyGotten = 0;
   172     
   165     
   173     // VideoCollectionWrapper::ECollectionContent
   166     // VideoCollectionWrapper::ECollectionContent
   174     type = VideoCollectionWrapper::ECollectionContent;
   167     type = VideoCollectionCommon::EModelTypeCollectionContent;
   175     proxyGotten = mTestObject->getModel(type);
   168     proxyGotten = mTestObject->getModel(type);
   176     QVERIFY(proxyGotten);
   169     QVERIFY(proxyGotten);
   177     QVERIFY(proxyGotten->mType == type);
   170     QVERIFY(proxyGotten->mType == type);
   178     proxyGotten = mTestObject->getModel(type);
   171     proxyGotten = mTestObject->getModel(type);
   179     QVERIFY(proxyGotten);
   172     QVERIFY(proxyGotten);
   180     QVERIFY(proxyGotten->mType == type);
   173     QVERIFY(proxyGotten->mType == type);
   181     delete proxyGotten;
   174     delete proxyGotten;
   182     proxyGotten = 0;
   175     proxyGotten = 0;
   183    
       
   184     // called with invalid type param
       
   185     type = -1;
       
   186     VideoListDataModel::mInitFails = false;
       
   187     proxyGotten = mTestObject->getModel(type);
       
   188     QVERIFY(!proxyGotten);
       
   189     
       
   190 }
   176 }
   191 
   177 
   192 // -----------------------------------------------------------------------------
   178 // -----------------------------------------------------------------------------
   193 // testAboutToQuitSlot
   179 // testAboutToQuitSlot
   194 // -----------------------------------------------------------------------------
   180 // -----------------------------------------------------------------------------
   197 {
   183 {
   198     QVERIFY(mTestObject);        
   184     QVERIFY(mTestObject);        
   199     connect(this, SIGNAL(testSignal()), mTestObject, SLOT(aboutToQuitSlot()));
   185     connect(this, SIGNAL(testSignal()), mTestObject, SLOT(aboutToQuitSlot()));
   200     
   186     
   201     VideoSortFilterProxyModel *proxyGotten = 0;
   187     VideoSortFilterProxyModel *proxyGotten = 0;
   202     int type = -1;    
       
   203     
       
   204     VideoSortFilterProxyModel::setInitFailure(false);
   188     VideoSortFilterProxyModel::setInitFailure(false);
   205     type = VideoCollectionWrapper::EAllVideos;
   189     VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos;
   206     proxyGotten = mTestObject->getModel(type);
   190     proxyGotten = mTestObject->getModel(type);
   207     QVERIFY(proxyGotten);
   191     QVERIFY(proxyGotten);
   208     QVERIFY(!mTestObject->mSourceModel.isNull());
   192     QVERIFY(!mTestObject->mSourceModel.isNull());
   209     emit testSignal();
   193     emit testSignal();
   210     QVERIFY(mTestObject->mSourceModel.isNull());
   194     QVERIFY(mTestObject->mSourceModel.isNull());
   211     
   195     
   212     emit testSignal();
   196     emit testSignal();
   213     QVERIFY(mTestObject->mSourceModel.isNull());
   197     QVERIFY(mTestObject->mSourceModel.isNull());
   214     
   198     
   215     
       
   216     disconnect(this, SIGNAL(testSignal()), mTestObject, SLOT(aboutToQuitSlot()));
   199     disconnect(this, SIGNAL(testSignal()), mTestObject, SLOT(aboutToQuitSlot()));
   217 }
   200 }
   218 
   201 
   219 
   202 
   220 // End of file
   203 // End of file