phoneapp/phoneuiqtviewadapter/tsrc/ut_phonemessagecontroller/unit_tests.cpp
changeset 36 2eacb6118286
parent 30 ebdbd102c78a
child 37 ba76fc04e6c2
equal deleted inserted replaced
30:ebdbd102c78a 36:2eacb6118286
     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:  Unit tests for PhoneNoteController.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtTest/QtTest>
       
    19 #include <QtGui>
       
    20 #include <hbapplication.h>
       
    21 #include <QSignalSpy>
       
    22 //#include <hbglobal_p.h>
       
    23 #include "phonemessagecontroller.h"
       
    24 #include "tphonecmdparamsfidata.h"
       
    25 
       
    26 #define PHONE_QT_MESSAGE_CONTROLLER_TEST_MAIN(TestObject) \
       
    27 int main(int argc, char *argv[]) \
       
    28 { \
       
    29     HbApplication app(argc, argv); \
       
    30     TestObject tc; \
       
    31     QResource::registerResource("../hbcore.rcc"); \
       
    32     int ret = QTest::qExec(&tc, argc, argv); \
       
    33     /* Core dump if HbIconLoader instance is not destroyed before the application instance. */ \
       
    34     /* HbIconLoader uses QCoreApplication::aboutToQuit() signal to destroy itself. */ \
       
    35     /* app.exec() where the signal is normally emitted is not called here. */ \
       
    36     /* So, invoking the signal explicitly. */ \
       
    37     QMetaObject::invokeMethod(&app, "aboutToQuit", Qt::DirectConnection); \
       
    38     return ret; \
       
    39 }
       
    40 
       
    41 class TestPhoneMessageController : public QObject
       
    42 {
       
    43     Q_OBJECT
       
    44 public:
       
    45     TestPhoneMessageController();
       
    46     virtual ~TestPhoneMessageController();
       
    47 
       
    48 public slots:
       
    49     void initTestCase();
       
    50     void cleanupTestCase();
       
    51     void init();
       
    52     void cleanup(); 
       
    53     
       
    54 private slots:
       
    55     void testOpenSoftRejectEditor();
       
    56 
       
    57 
       
    58     
       
    59 private:
       
    60     PhoneMessageController *m_messageController; // class under test
       
    61 };
       
    62 
       
    63 TestPhoneMessageController::TestPhoneMessageController()
       
    64 {
       
    65 }
       
    66 
       
    67 TestPhoneMessageController::~TestPhoneMessageController()
       
    68 {
       
    69 }
       
    70 
       
    71 void TestPhoneMessageController::initTestCase()
       
    72 {
       
    73     m_messageController = new PhoneMessageController();
       
    74 }
       
    75 
       
    76 void TestPhoneMessageController::cleanupTestCase()
       
    77 {
       
    78     delete m_messageController;
       
    79 }
       
    80 
       
    81 void TestPhoneMessageController::init()
       
    82 {
       
    83 }
       
    84 
       
    85 void TestPhoneMessageController::cleanup()
       
    86 {
       
    87 }
       
    88 
       
    89 void TestPhoneMessageController::testOpenSoftRejectEditor()
       
    90 {
       
    91     TPhoneCmdParamSfiData sfiParam;
       
    92     sfiParam.SetNumber(_L("1234567"));
       
    93     sfiParam.SetName(_L("Tester"));
       
    94     
       
    95     m_messageController->openSoftRejectMessageEditor(&sfiParam);
       
    96 }
       
    97 
       
    98 PHONE_QT_MESSAGE_CONTROLLER_TEST_MAIN(TestPhoneMessageController)
       
    99 #include "unit_tests.moc"