|
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 |
|
51 * 1. Fucntion Name: \n |
|
52 static CpBaseSettingView* launchSettingView(const QString &pluginFile,const QVariant &hint = QVariant()); |
|
53 |
|
54 2. Function Descrition: \n |
|
55 2.1 Create view object by call launchSettingView().\n |
|
56 2.2 emit signal to CpBaseSettingView object.\n |
|
57 |
|
58 3. Input Parameters: \n |
|
59 QString &pluginFile: plugin file path, either relative or absolute.\n |
|
60 QVariant &hint: hint string, for example, "profile_view".\n |
|
61 |
|
62 4. Expected result: \n |
|
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 |
|
83 * 1. Fucntion Name: \n |
|
84 static CpBaseSettingView* launchSettingView(const QString &pluginFile,const QVariant &hint = QVariant()); |
|
85 |
|
86 2. Function Descrition: \n |
|
87 2.1 Create view object by call launchSettingView().\n |
|
88 2.2 emit signal to CpBaseSettingView object.\n |
|
89 |
|
90 3. Input Parameters: \n |
|
91 QString &pluginFile: plugin file path, either relative or absolute.\n |
|
92 QVariant &hint: hint string, for example, "profile_view".\n |
|
93 |
|
94 4. Expected result: \n |
|
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 |
|
115 * 1. Fucntion Name: \n |
|
116 static CpBaseSettingView* launchSettingView(const QString &pluginFile,const QVariant &hint = QVariant()); |
|
117 |
|
118 2. Function Descrition: \n |
|
119 2.1 Create view object by call launchSettingView().\n |
|
120 2.2 emit signal to CpBaseSettingView object.\n |
|
121 |
|
122 3. Input Parameters: \n |
|
123 QString &pluginFile: plugin file path, either relative or absolute.\n |
|
124 QVariant &hint: hint string, for example, "profile_view".\n |
|
125 |
|
126 4. Expected result: \n |
|
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) |