videocollection/videocollectionview/tsrc/testvideocollectionviewutils/src/testvideocollectionviewutils.cpp
changeset 52 e3cecb93e76a
parent 47 45e72b57a2fd
child 59 a76e86df7ccd
equal deleted inserted replaced
47:45e72b57a2fd 52:e3cecb93e76a
    13 *
    13 *
    14 * Description:   tester for methods in VideoCollectionViewUtils
    14 * Description:   tester for methods in VideoCollectionViewUtils
    15 * 
    15 * 
    16 */
    16 */
    17 
    17 
       
    18 #include <qdebug.h>
    18 #include <qapplication.h>
    19 #include <qapplication.h>
       
    20 #include "xqsettingsmanagerstub.h"
    19 #include <vcxmyvideosdefs.h>
    21 #include <vcxmyvideosdefs.h>
    20 #include "centralrepository.h"
    22 #include "centralrepository.h"
    21 #include "testvideocollectionviewutils.h"
    23 #include "testvideocollectionviewutils.h"
    22 #include "hblabel.h"
    24 #include "hblabel.h"
    23 #include "hbaction.h"
    25 #include "hbaction.h"
    29 #include "hbmessageboxdata.h"
    31 #include "hbmessageboxdata.h"
    30 #include "hbnotificationdialog.h"
    32 #include "hbnotificationdialog.h"
    31 #include "hblistview.h"
    33 #include "hblistview.h"
    32 #include <hbactivitymanager.h>
    34 #include <hbactivitymanager.h>
    33 #include <hbapplication.h>
    35 #include <hbapplication.h>
       
    36 #include <xqsettingsmanagerstub.h>
    34 
    37 
    35 #define private public
    38 #define private public
    36 #include "videocollectionviewutils.h"
    39 #include "videocollectionviewutils.h"
    37 #undef private
    40 #undef private
    38 
    41 
   373 // -----------------------------------------------------------------------------
   376 // -----------------------------------------------------------------------------
   374 // testLoadSortingValues
   377 // testLoadSortingValues
   375 // -----------------------------------------------------------------------------
   378 // -----------------------------------------------------------------------------
   376 //
   379 //
   377 void TestVideoVideoCollectionViewUtils::testLoadSortingValues()
   380 void TestVideoVideoCollectionViewUtils::testLoadSortingValues()
   378 {      
   381 {
       
   382     CRepository::setSetFail(255);
       
   383 
   379     CRepository::mSortValues[KVideoSortingRoleKey] = VideoCollectionCommon::KeyDateTime;
   384     CRepository::mSortValues[KVideoSortingRoleKey] = VideoCollectionCommon::KeyDateTime;
   380     CRepository::mSortValues[KVideoSortingOrderKey] = Qt::DescendingOrder;
   385     CRepository::mSortValues[KVideoSortingOrderKey] = Qt::DescendingOrder;
   381     CRepository::mSortValues[KCollectionsSortingRoleKey] = VideoCollectionCommon::KeyTitle;
   386     CRepository::mSortValues[KCollectionsSortingRoleKey] = VideoCollectionCommon::KeyTitle;
   382     CRepository::mSortValues[KCollectionsSortingOrderKey] = Qt::DescendingOrder;
   387     CRepository::mSortValues[KCollectionsSortingOrderKey] = Qt::DescendingOrder;
   383     
   388     
   516     QVERIFY(sortOrder == Qt::DescendingOrder);
   521     QVERIFY(sortOrder == Qt::DescendingOrder);
   517 
   522 
   518 }
   523 }
   519 
   524 
   520 // -----------------------------------------------------------------------------
   525 // -----------------------------------------------------------------------------
   521 // testGetServiceIconStrings
   526 // testGetCenRepStringValue
   522 // -----------------------------------------------------------------------------
   527 // -----------------------------------------------------------------------------
   523 //
   528 //
   524 void TestVideoVideoCollectionViewUtils::testGetServiceIconStrings()
   529 void TestVideoVideoCollectionViewUtils::testGetCenRepStringValue()
   525 {
   530 {  
   526     VideoCollectionViewUtils &testObject(VideoCollectionViewUtils::instance());
   531     VideoCollectionViewUtils &testObject(VideoCollectionViewUtils::instance());
   527     CRepository::setNewLLeave(true);
   532 
   528     _LIT(KExpectedTDesValue, "expected");
   533     // Invalid
   529     CRepository::setTDesValue(KExpectedTDesValue());
   534     XQSettingsManager::mReadItemValueReturnValue = QVariant();
   530     QString expected((QChar*)KExpectedTDesValue().Ptr(),KExpectedTDesValue().Length());
   535     QVERIFY(testObject.getCenRepStringValue(0) == "");
   531     
   536     
   532     QString icon;
   537     // Ok
   533     QString pressed;
   538     XQSettingsManager::mReadItemValueReturnValue = QVariant("test");
   534     QVERIFY(testObject.getServiceIconStrings(icon, pressed) < 0);
   539     QVERIFY(testObject.getCenRepStringValue(0) == "test");
   535     QVERIFY(icon.isNull());
   540 }
   536     QVERIFY(pressed.isNull());
   541 
   537     
   542 // -----------------------------------------------------------------------------
   538     CRepository::setNewLLeave(false);
   543 // testGetCenRepIntValue
   539     CRepository::setGetFail(0);
   544 // -----------------------------------------------------------------------------
   540     QVERIFY(testObject.getServiceIconStrings(icon, pressed) < 0);
   545 //
   541     QVERIFY(icon.isNull());
   546 void TestVideoVideoCollectionViewUtils::testGetCenRepIntValue()
   542     QVERIFY(pressed.isNull());
   547 {   
   543     
   548     VideoCollectionViewUtils &testObject(VideoCollectionViewUtils::instance());
   544     CRepository::setGetFail(1);
   549 
   545     QVERIFY(testObject.getServiceIconStrings(icon, pressed) < 0);
   550     // Invalid
   546     QVERIFY(icon.isNull());
   551     XQSettingsManager::mReadItemValueReturnValue = QVariant();
   547     QVERIFY(pressed.isNull());
   552     QVERIFY(testObject.getCenRepIntValue(0) == -1);
   548     
   553     
   549     CRepository::setGetFail(255);
   554     // Ok
   550     QVERIFY(testObject.getServiceIconStrings(icon, pressed) == 0);
   555     XQSettingsManager::mReadItemValueReturnValue = QVariant(13);
   551     QCOMPARE(icon, expected);
   556     QVERIFY(testObject.getCenRepIntValue(0) == 13);
   552     QCOMPARE(pressed, expected);
       
   553 }
       
   554 
       
   555 // -----------------------------------------------------------------------------
       
   556 // testGetServiceIconStrings
       
   557 // -----------------------------------------------------------------------------
       
   558 //
       
   559 void TestVideoVideoCollectionViewUtils::testGetServiceUriString()
       
   560 {
       
   561      VideoCollectionViewUtils &testObject(VideoCollectionViewUtils::instance());
       
   562     CRepository::setNewLLeave(true);
       
   563     _LIT(KExpectedTDesValue, "expected");
       
   564     CRepository::setTDesValue(KExpectedTDesValue());
       
   565     QString expected((QChar*)KExpectedTDesValue().Ptr(),KExpectedTDesValue().Length());
       
   566     
       
   567     QVERIFY(testObject.getServiceUriString().isNull());
       
   568     
       
   569     CRepository::setNewLLeave(false);
       
   570     CRepository::setGetFail(0);
       
   571     QVERIFY(testObject.getServiceUriString().isNull());
       
   572     
       
   573     CRepository::setGetFail(255);
       
   574     QCOMPARE(testObject.getServiceUriString(), expected);
       
   575 }
   557 }
   576 
   558 
   577 // -----------------------------------------------------------------------------
   559 // -----------------------------------------------------------------------------
   578 // testInitListView
   560 // testInitListView
   579 // -----------------------------------------------------------------------------
   561 // -----------------------------------------------------------------------------
   639 // testSortModel
   621 // testSortModel
   640 // -----------------------------------------------------------------------------
   622 // -----------------------------------------------------------------------------
   641 //
   623 //
   642 void TestVideoVideoCollectionViewUtils::testSortModel()
   624 void TestVideoVideoCollectionViewUtils::testSortModel()
   643 {
   625 {
       
   626     CRepository::setGetFail(255);
       
   627     
   644     VideoCollectionViewUtils &testObject(VideoCollectionViewUtils::instance());
   628     VideoCollectionViewUtils &testObject(VideoCollectionViewUtils::instance());
   645     testObject.mVideosSortRole = -1;
   629     testObject.mVideosSortRole = -1;
   646     testObject.mVideosSortOrder = Qt::AscendingOrder;
   630     testObject.mVideosSortOrder = Qt::AscendingOrder;
   647     testObject.mCollectionsSortRole = -1;
   631     testObject.mCollectionsSortRole = -1;
   648     testObject.mCollectionsSortOrder = Qt::AscendingOrder;
   632     testObject.mCollectionsSortOrder = Qt::AscendingOrder;
   795     QVERIFY(name == "name");
   779     QVERIFY(name == "name");
   796    
   780    
   797 }
   781 }
   798 
   782 
   799 // End of file
   783 // End of file
   800     
       
   801 
       
   802