90
|
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: Main test class for hsHomeScreenStatePlugin library.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <QMetaType>
|
|
19 |
#include <QAction>
|
|
20 |
#include <QState>
|
|
21 |
|
|
22 |
#include <HbMainWindow>
|
|
23 |
#include <HbInstance>
|
|
24 |
#include <HbView>
|
|
25 |
|
|
26 |
#include "t_hshomescreenstateplugin.h"
|
|
27 |
#include "hshomescreenstateplugin.h"
|
|
28 |
#include "testwidget.h"
|
|
29 |
#include "hsdatabase.h"
|
|
30 |
#include "hsscene.h"
|
|
31 |
#include "hsgui.h"
|
|
32 |
#include "hswidgethost.h"
|
|
33 |
#include "hsdomainmodeldatastructures.h"
|
|
34 |
#include "hsconfiguration.h"
|
|
35 |
|
|
36 |
#include "hswidgetpositioningonorientationchange.h"
|
|
37 |
#include "hswidgetpositioningonwidgetadd.h"
|
|
38 |
#include "hswidgetpositioningonwidgetmove.h"
|
101
|
39 |
#include "hsdbupdatethread.h"
|
90
|
40 |
|
|
41 |
#ifdef Q_OS_SYMBIAN
|
|
42 |
#include <e32base.h>
|
|
43 |
#endif
|
|
44 |
|
|
45 |
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
void HomeScreenStatePluginTest::initTestCase()
|
|
50 |
{
|
|
51 |
mMainWindow = 0;
|
|
52 |
|
|
53 |
#ifdef Q_OS_SYMBIAN
|
|
54 |
mImageProcessingDelay = 5000;
|
|
55 |
#else
|
|
56 |
mImageProcessingDelay = 2000;
|
|
57 |
#endif
|
|
58 |
|
|
59 |
HsWidgetPositioningOnOrientationChange::setInstance(
|
|
60 |
new HsAdvancedWidgetPositioningOnOrientationChange);
|
|
61 |
|
|
62 |
HsWidgetPositioningOnWidgetAdd::setInstance(
|
|
63 |
new HsAnchorPointInBottomRight);
|
|
64 |
|
|
65 |
HsWidgetPositioningOnWidgetMove::setInstance(new HsSnapToLines);
|
|
66 |
|
|
67 |
HsDatabase::setInstance(new HsDatabase);
|
|
68 |
|
|
69 |
HsConfiguration::setInstance(new HsConfiguration);
|
|
70 |
|
101
|
71 |
// HsDbUpdateThread *updateThread = new HsDbUpdateThread("mockme","mockme");
|
|
72 |
// HsDbUpdateThread::setInstance(updateThread);
|
|
73 |
// updateThread->start();
|
90
|
74 |
}
|
|
75 |
|
|
76 |
void HomeScreenStatePluginTest::cleanupTestCase()
|
|
77 |
{
|
101
|
78 |
// HsDbUpdateThread::instance()->quit();
|
|
79 |
// HsDbUpdateThread::setInstance(0);
|
90
|
80 |
}
|
|
81 |
|
|
82 |
void HomeScreenStatePluginTest::cleanup()
|
|
83 |
{
|
|
84 |
//Scene already deleted as child of mainwindow
|
|
85 |
HsScene *scene = HsScene::takeInstance();
|
|
86 |
delete scene;
|
|
87 |
}
|
|
88 |
|
|
89 |
void HomeScreenStatePluginTest::init()
|
|
90 |
{
|
101
|
91 |
|
90
|
92 |
}
|
|
93 |
|
|
94 |
void HomeScreenStatePluginTest::createSceneAndWindow(int pageCount, int defaultPageIndex, int maximumPageCount)
|
|
95 |
{
|
|
96 |
HSCONFIGURATION_SET(setMaximumPageCount, maximumPageCount);
|
|
97 |
|
|
98 |
HbInstance::instance();
|
|
99 |
mMainWindow = new HbMainWindow;
|
|
100 |
mMainWindow->move(0, 0);
|
|
101 |
mMainWindow->show();
|
|
102 |
|
|
103 |
QEventLoop waitUntilMainWindowCreated;
|
|
104 |
QTimer eventLoopTimer;
|
|
105 |
eventLoopTimer.setInterval(15000);
|
|
106 |
eventLoopTimer.setSingleShot(true);
|
|
107 |
connect(mMainWindow, SIGNAL(viewReady()),
|
|
108 |
&waitUntilMainWindowCreated, SLOT(quit()));
|
|
109 |
connect(&eventLoopTimer, SIGNAL(timeout()),
|
|
110 |
&waitUntilMainWindowCreated, SLOT(quit()));
|
|
111 |
eventLoopTimer.start();
|
|
112 |
waitUntilMainWindowCreated.exec();
|
|
113 |
eventLoopTimer.stop();
|
|
114 |
|
|
115 |
HsScene *scene = HsScene::instance();
|
|
116 |
scene->setProperty("pageCount", pageCount);
|
|
117 |
scene->setProperty("defaultPageIndex", defaultPageIndex);
|
|
118 |
scene->setProperty("maximumPageCount", maximumPageCount);
|
|
119 |
scene->load();
|
|
120 |
}
|
|
121 |
|
|
122 |
void HomeScreenStatePluginTest::deleteSceneAndWindow()
|
|
123 |
{
|
|
124 |
delete mMainWindow;
|
|
125 |
mMainWindow = 0;
|
|
126 |
delete HsGui::takeInstance();
|
|
127 |
}
|
|
128 |
|
|
129 |
#ifdef Q_OS_SYMBIAN
|
|
130 |
//QTEST_MAIN corrected since crashes if TRAP not in correct place.
|
|
131 |
//Will be corrected in later (estimate 4.6.0) Qt release for Symbian.
|
|
132 |
int main(int argc, char *argv[])
|
|
133 |
{
|
|
134 |
QApplication app(argc, argv);
|
|
135 |
int error = 0;
|
|
136 |
TRAPD(err, \
|
|
137 |
QTEST_DISABLE_KEYPAD_NAVIGATION \
|
|
138 |
HomeScreenStatePluginTest tc; \
|
|
139 |
error = QTest::qExec(&tc, argc, argv););
|
|
140 |
Q_UNUSED(err);
|
|
141 |
return error;
|
|
142 |
}
|
|
143 |
#else //Q_OS_SYMBIAN
|
|
144 |
QTEST_MAIN(HomeScreenStatePluginTest)
|
|
145 |
#endif //Q_OS_SYMBIAN
|