messagingapp/msgui/msgaudiofetcher/tsrc/unittest_msgaudiofetcherdialog/src/unittest_msgaudiofetcherdialog.cpp
changeset 73 ecf6a73a9186
equal deleted inserted replaced
68:e8a69c93c830 73:ecf6a73a9186
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  Item decorator of the message list view.
       
    15  *
       
    16  */
       
    17 
       
    18 #include "unittest_msgaudiofetcherdialog.h"
       
    19 #include <QtTest/QtTest>
       
    20 #include <HbTextItem>
       
    21 #include <HbMainWindow>
       
    22 #include <HbColorScheme>
       
    23 #include <HbAction>
       
    24 #include <QtTest/QSignalSpy>
       
    25 #include <Qstring>
       
    26 #include "msguitest.h"
       
    27 #define LOC_SELECT_SELECT hbTrId("txt_common_button_select")
       
    28 const QString LIST_ITEM_TITLE("qtc_list_item_title_normal");
       
    29 TestMsgAudioFetcherDialog::TestMsgAudioFetcherDialog(): mAudioFetcherDialog(0),mTestMainWindow(0)
       
    30     {
       
    31 
       
    32     }
       
    33 TestMsgAudioFetcherDialog::~TestMsgAudioFetcherDialog()
       
    34     {
       
    35     
       
    36     }
       
    37 void TestMsgAudioFetcherDialog::initTestCase()
       
    38     {
       
    39         mTestMainWindow = new HbMainWindow();
       
    40         mAudioFetcherDialog = new MsgAudioFetcherDialog();
       
    41         mAudioFetcherDialog->show();
       
    42     }
       
    43 
       
    44 void TestMsgAudioFetcherDialog::test_Constructor()
       
    45     {
       
    46         QVERIFY(mAudioFetcherDialog->dismissPolicy() == HbDialog::NoDismiss);
       
    47         QVERIFY(mAudioFetcherDialog->frameType() == HbDialog::Strong);
       
    48         QVERIFY(mAudioFetcherDialog->isModal()==true);    
       
    49     }
       
    50 
       
    51 void TestMsgAudioFetcherDialog::test_initMainWidget()
       
    52     {
       
    53         HbTextItem* heading =  static_cast<HbTextItem*>(mAudioFetcherDialog->headingWidget());
       
    54         QVERIFY(heading != NULL);
       
    55         QVERIFY(heading->textColor() == HbColorScheme::color( LIST_ITEM_TITLE ));
       
    56         QVERIFY(heading->alignment() == Qt::AlignLeft);      
       
    57     }
       
    58 
       
    59 void TestMsgAudioFetcherDialog::test_initActions()
       
    60     {
       
    61         QVERIFY(mAudioFetcherDialog->mLeftAction != NULL);
       
    62         QVERIFY(mAudioFetcherDialog->mLeftAction->text() == LOC_SELECT_SELECT);
       
    63     }
       
    64 
       
    65 void TestMsgAudioFetcherDialog::test_doDelayedConstruction()
       
    66 { 
       
    67     QVERIFY(mAudioFetcherDialog->mListView != NULL);
       
    68     QVERIFY(mAudioFetcherDialog->mListView->selectionMode() == HbAbstractItemView::SingleSelection);
       
    69     QVERIFY(mAudioFetcherDialog->mFetcherModel != NULL);
       
    70     QVERIFY(long((mAudioFetcherDialog->mListView->model())) == long(mAudioFetcherDialog->mFetcherModel));
       
    71     QVERIFY(mAudioFetcherDialog->mListView->uniformItemSizes() == TRUE);
       
    72     QVERIFY(mAudioFetcherDialog->contentWidget() == mAudioFetcherDialog->mListView);
       
    73     QVERIFY(mAudioFetcherDialog->mAudioPreview != NULL);    
       
    74 }
       
    75 
       
    76 
       
    77 
       
    78 void TestMsgAudioFetcherDialog::test_onSelectAction()
       
    79     {  
       
    80         QSignalSpy audioSelect(mAudioFetcherDialog, SIGNAL(audioSelected(QString&)));
       
    81         QCOMPARE( audioSelect.count(), 0 );
       
    82         mAudioFetcherDialog->onSelectAction();
       
    83         QCOMPARE( audioSelect.count(), 1 );        
       
    84     }
       
    85 
       
    86 void TestMsgAudioFetcherDialog::test_reset()
       
    87     {
       
    88         mAudioFetcherDialog->reset();
       
    89         QVERIFY(mAudioFetcherDialog->mSelected == false);
       
    90         QVERIFY(mAudioFetcherDialog->mLeftAction->isEnabled() == false);
       
    91     }
       
    92 void TestMsgAudioFetcherDialog::cleanupTestCase()
       
    93     {
       
    94         if(mAudioFetcherDialog){
       
    95             delete mAudioFetcherDialog;
       
    96             mAudioFetcherDialog = NULL;
       
    97         }
       
    98         if (mTestMainWindow) {
       
    99             delete mTestMainWindow;
       
   100             mTestMainWindow = NULL;
       
   101         }
       
   102     }
       
   103 
       
   104 MSGUI_TEST_MAIN(TestMsgAudioFetcherDialog)