|
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 <QStateMachine> |
|
19 |
|
20 #include <HbInstance> |
|
21 #include <HbMainWindow> |
|
22 |
|
23 #include "t_hshomescreenstateplugin.h" |
|
24 #include "hswallpaperselectionstate.h" |
|
25 #include "hsscene.h" |
|
26 #include "hspage.h" |
|
27 #include "hsspinnerdialog.h" |
|
28 #include "hsconfiguration.h" |
|
29 #include "hsgui.h" |
|
30 |
|
31 #ifdef Q_OS_SYMBIAN |
|
32 #include "hsimagehandlingclient.h" |
|
33 #else |
|
34 #include "xqaiwgetimageclient.h" |
|
35 #endif |
|
36 |
|
37 void HomeScreenStatePluginTest::testWallpaperSelectionStateConstruction() |
|
38 { |
|
39 HsWallpaperSelectionState *s = new HsWallpaperSelectionState; |
|
40 QVERIFY(!s->mImageHandler); |
|
41 QVERIFY(!s->mWallpaper); |
|
42 QVERIFY(!s->mWaitDialog); |
|
43 QCOMPARE(s->findChildren<QState *>().count(), 5); |
|
44 delete s; |
|
45 } |
|
46 |
|
47 void HomeScreenStatePluginTest::testWallpaperSelectionStateImageSelection() |
|
48 { |
|
49 HsWallpaperSelectionState *s = new HsWallpaperSelectionState; |
|
50 |
|
51 // Generate mImageHandler. |
|
52 s->action_selectingImage_start(); |
|
53 |
|
54 QSignalSpy assignImageSpy(s, SIGNAL(event_assignImage())); |
|
55 QSignalSpy errorSpy(s, SIGNAL(event_error())); |
|
56 |
|
57 s->mImageHandler->setProperty("testSetToFail", false); |
|
58 s->mImageHandler->fetch(); |
|
59 |
|
60 QCOMPARE(assignImageSpy.count(), 1); |
|
61 assignImageSpy.clear(); |
|
62 QCOMPARE(errorSpy.count(), 0); |
|
63 |
|
64 s->mImageHandler->setProperty("testSetToFail", true); |
|
65 s->mImageHandler->fetch(); |
|
66 |
|
67 QCOMPARE(assignImageSpy.count(), 0); |
|
68 QCOMPARE(errorSpy.count(), 1); |
|
69 errorSpy.clear(); |
|
70 |
|
71 delete s; |
|
72 } |
|
73 |
|
74 void HomeScreenStatePluginTest::testWallpaperSelectionStateImageAssignment() |
|
75 { |
|
76 createSceneAndWindow(1, 0); |
|
77 HsWallpaperSelectionState *s = new HsWallpaperSelectionState; |
|
78 |
|
79 QSignalSpy waitInputSpy(s, SIGNAL(event_waitInput())); |
|
80 s->action_assigningImage_start(); |
|
81 QCOMPARE(waitInputSpy.count(), 1); |
|
82 QVERIFY(s->mWallpaper); |
|
83 s->action_assigningImage_cleanup(); |
|
84 QVERIFY(!s->mWallpaper); |
|
85 |
|
86 delete s; |
|
87 deleteSceneAndWindow(); |
|
88 } |
|
89 |
|
90 void HomeScreenStatePluginTest::testWallpaperSelectionStateSimpleMethods() |
|
91 { |
|
92 HbInstance::instance(); |
|
93 HbMainWindow *window = new HbMainWindow; |
|
94 window->move(0, 0); |
|
95 window->show(); |
|
96 |
|
97 HsWallpaperSelectionState *s = new HsWallpaperSelectionState; |
|
98 |
|
99 // Cleanup |
|
100 s->action_selectingImage_start(); |
|
101 s->action_imageHandler_cleanup(); |
|
102 QVERIFY(!s->mImageHandler); |
|
103 |
|
104 delete s; |
|
105 s = new HsWallpaperSelectionState; |
|
106 |
|
107 // Wait dialog |
|
108 s->action_assigningImage_showWaitDialog(); |
|
109 QVERIFY(s->mWaitDialog); |
|
110 s->mWaitDialog->stop(); |
|
111 s->action_assigningImage_hideWaitDialog(); |
|
112 QVERIFY(!s->mWaitDialog); |
|
113 |
|
114 delete s; |
|
115 s = new HsWallpaperSelectionState; |
|
116 |
|
117 QSignalSpy waitInputSpy(s, SIGNAL(event_waitInput())); |
|
118 s->action_errorMessage_show(); |
|
119 QCOMPARE(waitInputSpy.count(), 1); |
|
120 waitInputSpy.clear(); |
|
121 |
|
122 s->onImageSet(); |
|
123 QCOMPARE(waitInputSpy.count(), 1); |
|
124 waitInputSpy.clear(); |
|
125 |
|
126 QSignalSpy errorSpy(s, SIGNAL(event_error())); |
|
127 |
|
128 s->onImageSetFailed(); |
|
129 QCOMPARE(errorSpy.count(), 1); |
|
130 |
|
131 delete s; |
|
132 // main window deleted -> HsGui must be deleted also |
|
133 delete HsGui::takeInstance(); |
|
134 delete window; |
|
135 } |
|
136 |