controlpanel/tsrc/unit/ut_cppluginlauncher/src/ut_cppluginlauncher.cpp
branchRCL_3
changeset 54 7e0eff37aedb
parent 53 8ee96d21d9bf
child 57 e78c61e77b1a
equal deleted inserted replaced
53:8ee96d21d9bf 54:7e0eff37aedb
     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:  
       
    15 *       test application for qt control panel public apis.
       
    16 */
       
    17 
       
    18 #include "ut_cppluginlauncher.h"
       
    19 
       
    20 #include "cppluginlauncher.h"
       
    21 #include "cpbasesettingview.h"
       
    22 
       
    23 #include <QtTest/QtTest>
       
    24 #include <hbdataform.h>
       
    25 #include <hbpushbutton.h>
       
    26 #include <HbMainWindow>
       
    27 
       
    28 /*!
       
    29     \class TestCpPluginLauncher
       
    30     \brief The TestCpPluginLauncher class is designed for the unit testing for CpPluginLauncher class.
       
    31     This unit test is supported by QTest.
       
    32     There are total 3 test cases in this unit.
       
    33  */
       
    34 
       
    35 void TestCpPluginLauncher::initTestCase()
       
    36     {
       
    37     mainWindow = new HbMainWindow;
       
    38     mainWindow->show();
       
    39     }
       
    40 
       
    41 void TestCpPluginLauncher::cleanupTestCase()
       
    42     {
       
    43     delete mainWindow;
       
    44     
       
    45     //if delete mainwindow, test app will be freezing
       
    46     QCoreApplication::processEvents();
       
    47     }
       
    48 
       
    49 /*!
       
    50  * Test Case Description:\n &nbsp;
       
    51  * 1. Fucntion Name: \n&nbsp;
       
    52         static CpBaseSettingView* launchSettingView(const QString &pluginFile,const QVariant &hint = QVariant());&nbsp;
       
    53 
       
    54    2. Function Descrition: \n &nbsp;&nbsp;
       
    55        2.1 Create view object by call launchSettingView().\n &nbsp;&nbsp;
       
    56        2.2 emit signal to CpBaseSettingView object.\n &nbsp;&nbsp;
       
    57        
       
    58    3. Input Parameters: \n&nbsp;
       
    59        QString &pluginFile: plugin file path, either relative or absolute.\n&nbsp;&nbsp;
       
    60        QVariant &hint: hint string, for example, "profile_view".\n&nbsp;&nbsp;
       
    61    
       
    62    4. Expected result: \n&nbsp;&nbsp;
       
    63        CpBaseSettingView object created successfully, signal emit out to view object processed correctly.\n 
       
    64  */
       
    65 void TestCpPluginLauncher::testLaunchSettingViewWithCorrectProfileName()
       
    66     {
       
    67     CpBaseSettingView * pView1 = CpPluginLauncher::launchSettingView("testplugin.cpcfg", "profile_view");
       
    68     QVERIFY(pView1 != 0);
       
    69     
       
    70     CpBaseSettingView * pView2 = CpPluginLauncher::launchSettingView("testplugin.cpcfg", "profile_view");
       
    71     QVERIFY(pView2 != 0);
       
    72     
       
    73     QObject::connect(this, SIGNAL(connectAboutToClose()), pView1, SIGNAL(aboutToClose()));
       
    74     emit connectAboutToClose();
       
    75     
       
    76     QObject::connect(this, SIGNAL(connectAboutToClose()), pView2, SIGNAL(aboutToClose()));
       
    77     emit connectAboutToClose();
       
    78     emit connectAboutToClose();
       
    79     }
       
    80 
       
    81 /*!
       
    82  * Test Case Description:\n &nbsp;
       
    83  * 1. Fucntion Name: \n&nbsp;
       
    84         static CpBaseSettingView* launchSettingView(const QString &pluginFile,const QVariant &hint = QVariant());&nbsp;
       
    85 
       
    86    2. Function Descrition: \n &nbsp;&nbsp;
       
    87        2.1 Create view object by call launchSettingView().\n &nbsp;&nbsp;
       
    88        2.2 emit signal to CpBaseSettingView object.\n &nbsp;&nbsp;
       
    89        
       
    90    3. Input Parameters: \n&nbsp;
       
    91        QString &pluginFile: plugin file path, either relative or absolute.\n&nbsp;&nbsp;
       
    92        QVariant &hint: hint string, for example, "profile_view".\n&nbsp;&nbsp;
       
    93    
       
    94    4. Expected result: \n&nbsp;&nbsp;
       
    95        CpBaseSettingView object created successfully, signal emit out to view object processed correctly.\n 
       
    96  */
       
    97 void TestCpPluginLauncher::testLaunchSettingViewWithWrongProfileName()
       
    98     {
       
    99     CpBaseSettingView * pView1 = CpPluginLauncher::launchSettingView("testplugin.cpcfg", "myprofile_view");
       
   100     QVERIFY(pView1 == 0);
       
   101     
       
   102     CpBaseSettingView * pView2 = CpPluginLauncher::launchSettingView("testplugin.cpcfg", "myprofile_view");
       
   103     QVERIFY(pView2 == 0);
       
   104     
       
   105     QObject::connect(this, SIGNAL(connectAboutToClose()), pView1, SIGNAL(aboutToClose()));
       
   106     emit connectAboutToClose();
       
   107     
       
   108     QObject::connect(this, SIGNAL(connectAboutToClose()), pView2, SIGNAL(aboutToClose()));
       
   109     emit connectAboutToClose();
       
   110     emit connectAboutToClose();
       
   111     }
       
   112 
       
   113 /*!
       
   114  * Test Case Description:\n &nbsp;
       
   115  * 1. Fucntion Name: \n&nbsp;
       
   116         static CpBaseSettingView* launchSettingView(const QString &pluginFile,const QVariant &hint = QVariant());&nbsp;
       
   117 
       
   118    2. Function Descrition: \n &nbsp;&nbsp;
       
   119        2.1 Create view object by call launchSettingView().\n &nbsp;&nbsp;
       
   120        2.2 emit signal to CpBaseSettingView object.\n &nbsp;&nbsp;
       
   121        
       
   122    3. Input Parameters: \n&nbsp;
       
   123        QString &pluginFile: plugin file path, either relative or absolute.\n&nbsp;&nbsp;
       
   124        QVariant &hint: hint string, for example, "profile_view".\n&nbsp;&nbsp;
       
   125    
       
   126    4. Expected result: \n&nbsp;&nbsp;
       
   127        CpBaseSettingView object created successfully, signal emit out to view object processed correctly.\n 
       
   128  */
       
   129 void TestCpPluginLauncher::testLaunchSettingViewWithEmptyParam()
       
   130     {
       
   131     CpBaseSettingView * pView1 = CpPluginLauncher::launchSettingView("", "");
       
   132     QVERIFY(pView1 == 0);
       
   133     }
       
   134 
       
   135 QTEST_MAIN(TestCpPluginLauncher)