|
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 * |
|
16 */ |
|
17 |
|
18 #include "t_tsdevicedialogplugin.h" |
|
19 |
|
20 #include <QtTest/QtTest> |
|
21 #include <HbDeviceDialogInterface> |
|
22 |
|
23 #include <qvaluespacesubscriber.h> |
|
24 #include <qvaluespacepublisher.h> |
|
25 QTM_USE_NAMESPACE |
|
26 |
|
27 #include <tstestutils.h> |
|
28 #include <tspropertydefs.h> |
|
29 |
|
30 #include "tsdevicedialogplugin.h" |
|
31 |
|
32 void T_TsDeviceDialogPlugin::testCreation() |
|
33 { |
|
34 TsDeviceDialogPlugin *deviceDialogPlugin = new TsDeviceDialogPlugin; |
|
35 delete deviceDialogPlugin; |
|
36 } |
|
37 |
|
38 void T_TsDeviceDialogPlugin::testAccessAllowed() |
|
39 { |
|
40 TsDeviceDialogPlugin deviceDialogPlugin; |
|
41 QVERIFY(deviceDialogPlugin.accessAllowed(QString(), QVariantMap(), QVariantMap())); |
|
42 } |
|
43 |
|
44 void T_TsDeviceDialogPlugin::testDialogInfo() |
|
45 { |
|
46 TsDeviceDialogPlugin deviceDialogPlugin; |
|
47 |
|
48 HbDeviceDialogPlugin::DeviceDialogInfo info; |
|
49 deviceDialogPlugin.deviceDialogInfo(QString(), QVariantMap(), &info); |
|
50 QVERIFY(info.group == HbDeviceDialogPlugin::GenericDeviceDialogGroup); |
|
51 QVERIFY(info.flags == HbDeviceDialogPlugin::SingleInstance); |
|
52 QVERIFY(info.priority == HbDeviceDialogPlugin::DefaultPriority); |
|
53 } |
|
54 |
|
55 void T_TsDeviceDialogPlugin::testDialogTypes() |
|
56 { |
|
57 TsDeviceDialogPlugin deviceDialogPlugin; |
|
58 |
|
59 QStringList dialogTypes = deviceDialogPlugin.deviceDialogTypes(); |
|
60 QCOMPARE(1, dialogTypes.count()); |
|
61 QCOMPARE(QString("com.nokia.taskswitcher.tsdevicedialogplugin/1.0"), dialogTypes.first()); |
|
62 } |
|
63 |
|
64 void T_TsDeviceDialogPlugin::testPluginFlags() |
|
65 { |
|
66 TsDeviceDialogPlugin deviceDialogPlugin; |
|
67 |
|
68 QVERIFY(deviceDialogPlugin.pluginFlags() & HbDeviceDialogPlugin::PreloadPlugin); |
|
69 QVERIFY(deviceDialogPlugin.pluginFlags() & HbDeviceDialogPlugin::KeepPluginLoaded); |
|
70 } |
|
71 |
|
72 void T_TsDeviceDialogPlugin::testError() |
|
73 { |
|
74 TsDeviceDialogPlugin deviceDialogPlugin; |
|
75 QCOMPARE(0, deviceDialogPlugin.error()); |
|
76 } |
|
77 |
|
78 void T_TsDeviceDialogPlugin::testCreateDialog() |
|
79 { |
|
80 TsDeviceDialogPlugin deviceDialogPlugin; |
|
81 QVERIFY(!deviceDialogPlugin.createDeviceDialog("InvalidDialogType", QVariantMap())); |
|
82 foreach(const QString &dialogType, deviceDialogPlugin.deviceDialogTypes()) { |
|
83 HbDeviceDialogInterface *dialog = deviceDialogPlugin.createDeviceDialog(dialogType, QVariantMap()); |
|
84 QVERIFY(dialog); |
|
85 QVERIFY(0 != dialog->deviceDialogWidget()); |
|
86 QVERIFY(false == dialog->setDeviceDialogParameters(QVariantMap())); |
|
87 dialog->closeDeviceDialog(true); |
|
88 QVERIFY(0 == dialog->deviceDialogError()); |
|
89 delete dialog; |
|
90 } |
|
91 } |
|
92 |
|
93 void T_TsDeviceDialogPlugin::testNoCrashOnOrientationChange() |
|
94 { |
|
95 TsDeviceDialogPlugin deviceDialogPlugin; |
|
96 HbDeviceDialogInterface *dialog = deviceDialogPlugin.createDeviceDialog(deviceDialogPlugin.deviceDialogTypes().first(), QVariantMap()); |
|
97 QVERIFY(dialog); |
|
98 mMainWindow.setOrientation(Qt::Vertical); |
|
99 QCoreApplication::processEvents(); |
|
100 mMainWindow.setOrientation(Qt::Horizontal); |
|
101 QCoreApplication::processEvents(); |
|
102 delete dialog; |
|
103 } |
|
104 |
|
105 void T_TsDeviceDialogPlugin::testCreateDeviceDialogTwoTimes() |
|
106 { |
|
107 TsDeviceDialogPlugin deviceDialogPlugin; |
|
108 HbDeviceDialogInterface *dialog1 = deviceDialogPlugin.createDeviceDialog(deviceDialogPlugin.deviceDialogTypes().first(), QVariantMap()); |
|
109 QVERIFY(dialog1); |
|
110 HbDeviceDialogInterface *dialog2 = deviceDialogPlugin.createDeviceDialog(deviceDialogPlugin.deviceDialogTypes().first(), QVariantMap()); |
|
111 QVERIFY(dialog2); |
|
112 |
|
113 delete dialog1; |
|
114 delete dialog2; |
|
115 } |
|
116 |
|
117 void T_TsDeviceDialogPlugin::testCorrectSignalSenderIsReturned() |
|
118 { |
|
119 TsDeviceDialogPlugin deviceDialogPlugin; |
|
120 HbDeviceDialogInterface *dialog = deviceDialogPlugin.createDeviceDialog(deviceDialogPlugin.deviceDialogTypes().first(), QVariantMap()); |
|
121 QVERIFY(dialog); |
|
122 QVERIFY(dialog->signalSender()); |
|
123 } |
|
124 |
|
125 void T_TsDeviceDialogPlugin::testDialogSendsItsStatusNotifications() |
|
126 { |
|
127 QString tsVisibilityPath = QString("%1/%2").arg(TsProperty::KTsPath).arg(TsProperty::KVisibilityPath); |
|
128 |
|
129 TsDeviceDialogPlugin deviceDialogPlugin; |
|
130 HbDeviceDialogInterface *dialog = deviceDialogPlugin.createDeviceDialog(deviceDialogPlugin.deviceDialogTypes().first(), QVariantMap()); |
|
131 QVERIFY(dialog); |
|
132 QCOMPARE(QValueSpaceSubscriber(tsVisibilityPath).value().toBool(), true); |
|
133 |
|
134 dialog->closeDeviceDialog(true); |
|
135 QCOMPARE(QValueSpaceSubscriber(tsVisibilityPath).value().toBool(), false); |
|
136 |
|
137 delete dialog; |
|
138 } |
|
139 |
|
140 void T_TsDeviceDialogPlugin::testDialogCanBeDismissedThroughProperty() |
|
141 { |
|
142 QString tsDismissRequestPath = QString("%1/%2").arg(TsProperty::KTsPath).arg(TsProperty::KDismissRequestPath); |
|
143 |
|
144 TsDeviceDialogPlugin deviceDialogPlugin; |
|
145 HbDeviceDialogInterface *dialog = deviceDialogPlugin.createDeviceDialog(deviceDialogPlugin.deviceDialogTypes().first(), QVariantMap()); |
|
146 QVERIFY(dialog); |
|
147 QCOMPARE(QValueSpaceSubscriber(tsDismissRequestPath).value().toBool(), false); |
|
148 |
|
149 QValueSpacePublisher dismissRequestPublisher(TsProperty::KTsPath); |
|
150 dismissRequestPublisher.setValue(TsProperty::KDismissRequestPath, static_cast<int>(true)); |
|
151 dismissRequestPublisher.sync(); |
|
152 |
|
153 QVERIFY(TsTestUtils::waitForSignal(dialog->signalSender(), SIGNAL(deviceDialogClosed()), 3000)); |
|
154 |
|
155 delete dialog; |
|
156 } |
|
157 |
|
158 QTEST_MAIN(T_TsDeviceDialogPlugin) |