mpviewplugins/mpdetailsviewplugin/tsrc/unittest_mpdetailssharedialog/src/unittest_mpdetailssharedialog.cpp
changeset 48 af3740e3753f
parent 42 79c49924ae23
child 54 c5b304f4d89b
equal deleted inserted replaced
42:79c49924ae23 48:af3740e3753f
     1 /*
       
     2 * Copyright (c) 2010 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 test for MpDetailsShareDialog
       
    15 *
       
    16 */
       
    17 #include <QSignalSpy>
       
    18 #ifdef Q_OS_SYMBIAN
       
    19 #include <hbapplication.h>
       
    20 #include <hbmainwindow.h>
       
    21 #include <hbicon.h>
       
    22 #endif
       
    23 #include"unittest_mpdetailssharedialog.h"
       
    24 #include "hbmessagebox.h"
       
    25 
       
    26 // Do this so we can access all member variables.
       
    27 #define private public
       
    28 #include "mpdetailssharedialog.h"
       
    29 #undef private
       
    30 #include "mpsharedata.h"
       
    31 #include "mpsongdata.h"
       
    32 
       
    33 /*!
       
    34  Make our test case a stand-alone executable that runs all the test functions.
       
    35  */
       
    36 #ifdef Q_OS_SYMBIAN
       
    37 int main(int argc, char *argv[])
       
    38 {
       
    39 
       
    40     HbApplication app(argc, argv);
       
    41     HbMainWindow window;
       
    42 
       
    43     TestMpDetailsShareDialog tv;
       
    44 
       
    45     if ( argc > 1 ) {
       
    46         return QTest::qExec( &tv, argc, argv);
       
    47     }
       
    48     else {
       
    49         char *pass[3];
       
    50         pass[0] = argv[0];
       
    51         pass[1] = "-o";
       
    52         pass[2] = "c:\\data\\unittest_testmpdetailssharedialog.txt";
       
    53 
       
    54         return QTest::qExec(&tv, 3, pass);
       
    55     }
       
    56 }
       
    57 #endif
       
    58 
       
    59 #ifdef Q_OS_WIN32
       
    60 QTEST_MAIN(TestMpDetailsShareDialog)
       
    61 #endif
       
    62 //Constructor
       
    63 TestMpDetailsShareDialog::TestMpDetailsShareDialog()
       
    64     : mTest(0)
       
    65 {
       
    66 
       
    67 }
       
    68 
       
    69 //Destructor
       
    70 TestMpDetailsShareDialog::~TestMpDetailsShareDialog()
       
    71 {
       
    72     if (mTest) delete mTest;
       
    73 }
       
    74 
       
    75 /*!
       
    76  Called before the first testfunction is executed.
       
    77  */
       
    78 void TestMpDetailsShareDialog::initTestCase()
       
    79 {
       
    80     qDebug() << "unit test for mpdetailssharedialog begin.";
       
    81 }
       
    82 
       
    83 /*!
       
    84  Called after the last testfunction was executed.
       
    85  */
       
    86 void TestMpDetailsShareDialog::cleanupTestCase()
       
    87 {
       
    88     qDebug() << "unit test for mpdetailssharedialog end.";
       
    89     QCoreApplication::processEvents();
       
    90 }
       
    91 
       
    92 /*!
       
    93  Called before each testfunction is executed.
       
    94  */
       
    95 void TestMpDetailsShareDialog::init()
       
    96 {
       
    97     mSongData = new MpSongData();
       
    98     mTest = new MpDetailsShareDialog();
       
    99     mTest->initialize(mSongData, "unknown");
       
   100 }
       
   101 
       
   102 /*!
       
   103  Called after every testfunction.
       
   104  */
       
   105 void TestMpDetailsShareDialog::cleanup()
       
   106 {
       
   107     delete mTest;
       
   108     delete mSongData;
       
   109     mTest = 0;
       
   110     mSongData = 0;
       
   111 }
       
   112 
       
   113 void TestMpDetailsShareDialog::testConstruction()
       
   114 {
       
   115     mTest->updateSharedData();
       
   116     mTest->debugJs("Test");
       
   117     mTest->errorHandler("Test error", "Test message");
       
   118     mTest->clearCache();
       
   119     mTest->addContext();
       
   120 
       
   121     mTest->mShareNetAccMan = NULL;
       
   122     mTest->mShareWebView = NULL;
       
   123     mTest->updateSharedData();
       
   124     mTest->debugJs("Test");
       
   125     mTest->errorHandler("Test error", "Test message");
       
   126     mTest->clearCache();
       
   127     mTest->addContext();
       
   128     //nothing to verify
       
   129     QCOMPARE(true, true);
       
   130 }
       
   131 
       
   132 void TestMpDetailsShareDialog::testIndexLoadOk()
       
   133 {
       
   134     mTest->onIndexLoad(true);
       
   135     mTest->onIndexLoad(false);
       
   136     //nothing to verify
       
   137     QCOMPARE(true, true);
       
   138 }
       
   139