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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <HbDeviceProfile>
|
|
19 |
|
|
20 |
#include "t_hsdomainmodel.h"
|
|
21 |
#include "hsdomainmodeldatastructures.h"
|
|
22 |
#include "hsconfiguration.h"
|
|
23 |
|
|
24 |
|
|
25 |
void TestHsDomainModel::testConfigurationConstruction()
|
|
26 |
{
|
|
27 |
HsConfiguration *c = new HsConfiguration;
|
|
28 |
|
|
29 |
QCOMPARE(c->mBounceEffect, 20);
|
|
30 |
QCOMPARE(c->mPageChangeAnimationDuration, 300);
|
|
31 |
QCOMPARE(c->mPageChangeZoneAnimationDuration, 600);
|
|
32 |
QCOMPARE(c->mPageChangeZoneReverseAnimationDuration, 200);
|
|
33 |
QCOMPARE(c->mPageRemovedAnimationDuration, 1000);
|
|
34 |
QCOMPARE(c->mNewPageAddedAnimationDuration, 1000);
|
|
35 |
QCOMPARE(c->mWidgetDragEffectDuration, 250);
|
|
36 |
QCOMPARE(c->mWidgetDropEffectDuration, 200);
|
|
37 |
QCOMPARE(c->mDefaultPageId, 1);
|
|
38 |
QCOMPARE(c->mMaximumPageCount, 8);
|
|
39 |
QCOMPARE(c->mIsShortcutLabelVisible, true);
|
|
40 |
QCOMPARE(c->mBounceFeedbackEffectDistance, qreal(3));
|
|
41 |
QCOMPARE(c->mPageChangeZoneWidth, qreal(30));
|
|
42 |
QCOMPARE(c->mPageIndicatorSpacing, qreal(8));
|
|
43 |
QCOMPARE(c->mMaximumWidgetHeight, qreal(39));
|
|
44 |
QCOMPARE(c->mMaximumWidgetWidth, qreal(48));
|
|
45 |
QCOMPARE(c->mMinimumWidgetHeight, qreal(8.75));
|
|
46 |
QCOMPARE(c->mMinimumWidgetWidth, qreal(8.75));
|
|
47 |
QCOMPARE(c->mPageChangePanDistance, qreal(120));
|
|
48 |
QCOMPARE(c->mPageChangeFeedbackEffect, HbFeedback::Sensitive);
|
|
49 |
QCOMPARE(c->mWidgetPickFeedbackEffect, HbFeedback::ItemPick);
|
|
50 |
QCOMPARE(c->mWidgetDropFeedbackEffect, HbFeedback::ItemDrop);
|
|
51 |
QCOMPARE(c->mWidgetRepositionFeedbackEffect, HbFeedback::BounceEffect);
|
|
52 |
QCOMPARE(c->mWidgetOverTrashbinFeedbackEffect, HbFeedback::ItemMoveOver);
|
|
53 |
QCOMPARE(c->mWidgetDropToTrashbinFeedbackEffect, HbFeedback::ItemDrop);
|
|
54 |
QCOMPARE(c->mShortcutWidgetTapFeedbackEffect, HbFeedback::BasicItem);
|
|
55 |
QCOMPARE(c->mWidgetMoveBlockedFeedbackEffect, HbFeedback::Basic);
|
|
56 |
QCOMPARE(c->mClockWidgetTapFeedbackEffect, HbFeedback::BasicItem);
|
|
57 |
QCOMPARE(c->mWidgetSnappingFeedbackEffect, HbFeedback::ItemMoveOver);
|
|
58 |
QCOMPARE(c->mIsSnapEnabled, true);
|
|
59 |
QCOMPARE(c->mSnapTimeout, 300);
|
|
60 |
QCOMPARE(c->mSnapForce, qreal(30));
|
|
61 |
QCOMPARE(c->mSnapGap, qreal(6));
|
|
62 |
QCOMPARE(c->mPageMargin, qreal(0));
|
|
63 |
QCOMPARE(c->mSnapLineFadeInDuration, 100);
|
|
64 |
QCOMPARE(c->mSnapLineFadeOutDuration, 100);
|
|
65 |
QCOMPARE(c->mSceneType, HsConfiguration::PageWallpapers);
|
|
66 |
|
|
67 |
delete c;
|
|
68 |
}
|
|
69 |
|
|
70 |
void TestHsDomainModel::testConfigurationStaticInterface()
|
|
71 |
{
|
|
72 |
HsConfiguration *stored = HsConfiguration::takeInstance();
|
|
73 |
|
|
74 |
HsConfiguration *c = new HsConfiguration;
|
|
75 |
QVERIFY(!HsConfiguration::instance());
|
|
76 |
HsConfiguration::setInstance(c);
|
|
77 |
QVERIFY(HsConfiguration::instance() == c);
|
|
78 |
HsConfiguration::setInstance(c);
|
|
79 |
QVERIFY(HsConfiguration::instance() == c);
|
|
80 |
HsConfiguration *c2 = HsConfiguration::takeInstance();
|
|
81 |
QVERIFY(!HsConfiguration::instance());
|
|
82 |
QVERIFY(c == c2);
|
|
83 |
delete c;
|
|
84 |
|
|
85 |
HsConfiguration::setInstance(stored);
|
|
86 |
}
|
|
87 |
|
|
88 |
void TestHsDomainModel::testConfigurationSizes()
|
|
89 |
{
|
|
90 |
HsConfiguration *c = new HsConfiguration;
|
|
91 |
|
|
92 |
QSizeF min1(c->mMinimumWidgetWidth, c->mMinimumWidgetHeight);
|
|
93 |
QSizeF max1(c->mMaximumWidgetWidth, c->mMaximumWidgetHeight);
|
|
94 |
|
|
95 |
QSizeF min2(c->minimumWidgetSizeInUnits());
|
|
96 |
QSizeF max2(c->maximumWidgetSizeInUnits());
|
|
97 |
|
|
98 |
QVERIFY(qFuzzyCompare(min1.width(), min2.width()));
|
|
99 |
QVERIFY(qFuzzyCompare(min1.height(), min2.height()));
|
|
100 |
QVERIFY(qFuzzyCompare(max1.width(), max2.width()));
|
|
101 |
QVERIFY(qFuzzyCompare(max1.height(), max2.height()));
|
|
102 |
|
|
103 |
HbDeviceProfile profile;
|
|
104 |
qreal factor = profile.unitValue();
|
|
105 |
|
|
106 |
min1 *= factor;
|
|
107 |
max1 *= factor;
|
|
108 |
|
|
109 |
min2 = c->minimumWidgetSizeInPixels();
|
|
110 |
max2 = c->maximumWidgetSizeInPixels();
|
|
111 |
|
|
112 |
QVERIFY(qFuzzyCompare(min1.width(), min2.width()));
|
|
113 |
QVERIFY(qFuzzyCompare(min1.height(), min2.height()));
|
|
114 |
QVERIFY(qFuzzyCompare(max1.width(), max2.width()));
|
|
115 |
QVERIFY(qFuzzyCompare(max1.height(), max2.height()));
|
|
116 |
|
|
117 |
delete c;
|
|
118 |
}
|
|
119 |
|
|
120 |
void TestHsDomainModel::testConfigurationImportAndExport()
|
|
121 |
{
|
|
122 |
HsConfiguration *c = new HsConfiguration;
|
|
123 |
|
|
124 |
QVERIFY(!c->exportToFile(QString()));
|
|
125 |
QVERIFY(!c->importFromFile(QString()));
|
|
126 |
|
|
127 |
QVERIFY(c->exportToFile("test_hsconfiguration.txt"));
|
|
128 |
QVERIFY(c->importFromFile("test_hsconfiguration.txt"));
|
|
129 |
|
|
130 |
QFile::remove("test_hsconfiguration.txt");
|
|
131 |
|
|
132 |
QCOMPARE(c->mBounceEffect, 20);
|
|
133 |
QCOMPARE(c->mPageChangeAnimationDuration, 300);
|
|
134 |
QCOMPARE(c->mPageChangeZoneAnimationDuration, 600);
|
|
135 |
QCOMPARE(c->mPageChangeZoneReverseAnimationDuration, 200);
|
|
136 |
QCOMPARE(c->mPageRemovedAnimationDuration, 1000);
|
|
137 |
QCOMPARE(c->mNewPageAddedAnimationDuration, 1000);
|
|
138 |
QCOMPARE(c->mWidgetDragEffectDuration, 250);
|
|
139 |
QCOMPARE(c->mWidgetDropEffectDuration, 200);
|
|
140 |
QCOMPARE(c->mDefaultPageId, 1);
|
|
141 |
QCOMPARE(c->mMaximumPageCount, 8);
|
|
142 |
QCOMPARE(c->mIsShortcutLabelVisible, true);
|
|
143 |
QCOMPARE(c->mBounceFeedbackEffectDistance, qreal(3));
|
|
144 |
QCOMPARE(c->mPageChangeZoneWidth, qreal(30));
|
|
145 |
QCOMPARE(c->mPageIndicatorSpacing, qreal(8));
|
|
146 |
QCOMPARE(c->mMaximumWidgetHeight, qreal(39));
|
|
147 |
QCOMPARE(c->mMaximumWidgetWidth, qreal(48));
|
|
148 |
QCOMPARE(c->mMinimumWidgetHeight, qreal(8.75));
|
|
149 |
QCOMPARE(c->mMinimumWidgetWidth, qreal(8.75));
|
|
150 |
QCOMPARE(c->mPageChangePanDistance, qreal(120));
|
|
151 |
QCOMPARE(c->mPageChangeFeedbackEffect, HbFeedback::Sensitive);
|
|
152 |
QCOMPARE(c->mWidgetPickFeedbackEffect, HbFeedback::ItemPick);
|
|
153 |
QCOMPARE(c->mWidgetDropFeedbackEffect, HbFeedback::ItemDrop);
|
|
154 |
QCOMPARE(c->mWidgetRepositionFeedbackEffect, HbFeedback::BounceEffect);
|
|
155 |
QCOMPARE(c->mWidgetOverTrashbinFeedbackEffect, HbFeedback::ItemMoveOver);
|
|
156 |
QCOMPARE(c->mWidgetDropToTrashbinFeedbackEffect, HbFeedback::ItemDrop);
|
|
157 |
QCOMPARE(c->mShortcutWidgetTapFeedbackEffect, HbFeedback::BasicItem);
|
|
158 |
QCOMPARE(c->mWidgetMoveBlockedFeedbackEffect, HbFeedback::Basic);
|
|
159 |
QCOMPARE(c->mClockWidgetTapFeedbackEffect, HbFeedback::BasicItem);
|
|
160 |
QCOMPARE(c->mWidgetSnappingFeedbackEffect, HbFeedback::ItemMoveOver);
|
|
161 |
QCOMPARE(c->mIsSnapEnabled, true);
|
|
162 |
QCOMPARE(c->mSnapTimeout, 300);
|
|
163 |
QCOMPARE(c->mSnapForce, qreal(30));
|
|
164 |
QCOMPARE(c->mSnapGap, qreal(6));
|
|
165 |
QCOMPARE(c->mPageMargin, qreal(0));
|
|
166 |
QCOMPARE(c->mSnapLineFadeInDuration, 100);
|
|
167 |
QCOMPARE(c->mSnapLineFadeOutDuration, 100);
|
|
168 |
QCOMPARE(c->mSceneType, HsConfiguration::PageWallpapers);
|
|
169 |
|
|
170 |
delete c;
|
|
171 |
}
|
|
172 |
|
|
173 |
void TestHsDomainModel::testConfigurationLoad()
|
|
174 |
{
|
|
175 |
HsConfiguration *c = new HsConfiguration;
|
|
176 |
QVERIFY(c->load());
|
|
177 |
delete c;
|
|
178 |
}
|