Merge lp:~thomas-moenicke/phablet-extras/maliit-plugins-dynamic-unittests into lp:phablet-extras/maliit-plugins
- maliit-plugins-dynamic-unittests
- Merge into maliit-plugins
Status: | Merged |
---|---|
Approved by: | Thomas Moenicke |
Approved revision: | 2145 |
Merged at revision: | 2139 |
Proposed branch: | lp:~thomas-moenicke/phablet-extras/maliit-plugins-dynamic-unittests |
Merge into: | lp:phablet-extras/maliit-plugins |
Diff against target: |
700 lines (+480/-24) 13 files modified
debian/changelog (+7/-1) maliit-keyboard/data/languages/email.xml (+3/-3) maliit-keyboard/lib/logic/dynamiclayout.cpp (+31/-3) maliit-keyboard/lib/logic/dynamiclayout.h (+12/-1) maliit-keyboard/lib/logic/dynamiclayout_p.h (+20/-16) maliit-keyboard/tests/common/common.pro (+2/-0) maliit-keyboard/tests/common/mockscreen.cpp (+64/-0) maliit-keyboard/tests/common/mockscreen.h (+57/-0) maliit-keyboard/tests/dynamic-layout/dynamic-layout.pro (+17/-0) maliit-keyboard/tests/dynamic-layout/test-ui-constants.qml (+79/-0) maliit-keyboard/tests/dynamic-layout/test.cpp (+186/-0) maliit-keyboard/tests/tests.pro (+1/-0) unittests.sh (+1/-0) |
To merge this branch: | bzr merge lp:~thomas-moenicke/phablet-extras/maliit-plugins-dynamic-unittests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Günter Schwann (community) | Approve | ||
Review via email: mp+179227@code.launchpad.net |
Commit message
dynamiclayout unittests
Description of the change
dynamiclayout unittests
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2142
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Günter Schwann (schwann) wrote : | # |
Missing copyright header for
maliit-
maliit-
maliit-
Günter Schwann (schwann) wrote : | # |
616 + qDebug() << area.keys(
Why printing all the debugging, after the test?
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2143
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2144
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
Unapproved changes made after approval.
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2145
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2013-08-08 14:28:33 +0000 |
3 | +++ debian/changelog 2013-08-09 11:00:42 +0000 |
4 | @@ -1,4 +1,10 @@ |
5 | -maliit-plugins (0.99.trunk.phablet4) saycu; urgency=low |
6 | +maliit-plugins (0.99.trunk.phablet5) saucy; urgency=low |
7 | + |
8 | + * improved email layout |
9 | + |
10 | + -- Thomas Moenicke <thomas@pachamama> Fri, 09 Aug 2013 12:59:46 +0200 |
11 | + |
12 | +maliit-plugins (0.99.trunk.phablet4) saucy; urgency=low |
13 | |
14 | * url, phonenumber and number layouts |
15 | |
16 | |
17 | === modified file 'maliit-keyboard/data/languages/email.xml' |
18 | --- maliit-keyboard/data/languages/email.xml 2013-08-07 20:38:19 +0000 |
19 | +++ maliit-keyboard/data/languages/email.xml 2013-08-09 11:00:42 +0000 |
20 | @@ -464,10 +464,10 @@ |
21 | <binding action="sym" label="?123" /> |
22 | </key> |
23 | <spacer /> |
24 | - <key id="urlKey"> |
25 | - <binding label=".com" /> |
26 | + <key id="emailKey"> |
27 | + <binding label="@" /> |
28 | </key> |
29 | - <key width="large"> |
30 | + <key width="x-large"> |
31 | <binding action="space" /> |
32 | </key> |
33 | <key id="urlKey" width="large"> |
34 | |
35 | === modified file 'maliit-keyboard/lib/logic/dynamiclayout.cpp' |
36 | --- maliit-keyboard/lib/logic/dynamiclayout.cpp 2013-08-08 10:45:11 +0000 |
37 | +++ maliit-keyboard/lib/logic/dynamiclayout.cpp 2013-08-09 11:00:42 +0000 |
38 | @@ -84,13 +84,23 @@ |
39 | |
40 | DynamicLayout::DynamicLayout(QObject* parent) : QObject(parent), |
41 | d(new DynamicLayoutPrivate(this)) |
42 | -{} |
43 | +{ |
44 | + const QScreen* screen = qGuiApp->primaryScreen(); |
45 | + connect( screen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)), this, SLOT(onPrimaryOrientationChanged(Qt::ScreenOrientation)) ); |
46 | + connect( screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)), this, SLOT(onPrimaryOrientationChanged(Qt::ScreenOrientation)) ); |
47 | + connect( screen, SIGNAL(geometryChanged(QRect)), this, SLOT(onGeometryChanged(QRect)) ); |
48 | + |
49 | + d->primaryOrientation = screen->primaryOrientation(); |
50 | + d->orientation = screen->orientation(); |
51 | + d->geometry = screen->geometry(); |
52 | +} |
53 | + |
54 | |
55 | DynamicLayout* DynamicLayout::self = 0; |
56 | |
57 | -void DynamicLayout::initDynamicLayout() |
58 | +void DynamicLayout::initDynamicLayout(QString fileName) |
59 | { |
60 | - d->initDynamicLayout(); |
61 | + d->initDynamicLayout(fileName); |
62 | } |
63 | |
64 | int DynamicLayout::windowWidth(LayoutHelper::Orientation orientation) |
65 | @@ -306,4 +316,22 @@ |
66 | } |
67 | } |
68 | |
69 | +void DynamicLayout::onPrimaryOrientationChanged(Qt::ScreenOrientation orientation) |
70 | +{ |
71 | + d->primaryOrientation = orientation; |
72 | +} |
73 | + |
74 | +void DynamicLayout::onOrientationChanged(Qt::ScreenOrientation orientation) |
75 | +{ |
76 | + d->orientation = orientation; |
77 | +} |
78 | + |
79 | +void DynamicLayout::onGeometryChanged(const QRect & geometry) |
80 | +{ |
81 | + d->geometry = geometry; |
82 | + d->invalidateWindowGeometryCache(); |
83 | +} |
84 | + |
85 | + |
86 | + |
87 | }} // namespaces |
88 | |
89 | === modified file 'maliit-keyboard/lib/logic/dynamiclayout.h' |
90 | --- maliit-keyboard/lib/logic/dynamiclayout.h 2013-07-30 16:16:14 +0000 |
91 | +++ maliit-keyboard/lib/logic/dynamiclayout.h 2013-08-09 11:00:42 +0000 |
92 | @@ -48,7 +48,13 @@ |
93 | return self; |
94 | } |
95 | |
96 | - void initDynamicLayout(); |
97 | + static void reset() |
98 | + { |
99 | + if (self) |
100 | + self = new DynamicLayout; |
101 | + } |
102 | + |
103 | + void initDynamicLayout(QString fileName = MALIIT_KEYBOARD_DATA_DIR "/maliit-ui-constants.qml"); |
104 | |
105 | int keypadHeight(LayoutHelper::Orientation orientation); |
106 | int windowWidth(LayoutHelper::Orientation orientation); |
107 | @@ -84,6 +90,11 @@ |
108 | |
109 | Q_SLOT void onWordEngineSettingsChanged(bool wordEngineEnabled); |
110 | |
111 | + /* interface to primaryScreen */ |
112 | + Q_SLOT void onPrimaryOrientationChanged(Qt::ScreenOrientation orientation); |
113 | + Q_SLOT void onOrientationChanged(Qt::ScreenOrientation orientation); |
114 | + Q_SLOT void onGeometryChanged(const QRect & geometry); |
115 | + |
116 | private: |
117 | explicit DynamicLayout(QObject *parent = 0); |
118 | DynamicLayout(DynamicLayout const&) : QObject(0) {} |
119 | |
120 | === modified file 'maliit-keyboard/lib/logic/dynamiclayout_p.h' |
121 | --- maliit-keyboard/lib/logic/dynamiclayout_p.h 2013-07-30 16:16:14 +0000 |
122 | +++ maliit-keyboard/lib/logic/dynamiclayout_p.h 2013-08-09 11:00:42 +0000 |
123 | @@ -59,7 +59,7 @@ |
124 | |
125 | DynamicLayoutStorage* storage(LayoutHelper::Orientation orientation) |
126 | { |
127 | - initDynamicLayout(); |
128 | + q->initDynamicLayout(); |
129 | |
130 | if (orientation == LayoutHelper::Landscape) |
131 | return landscapeStorage; |
132 | @@ -112,6 +112,10 @@ |
133 | DynamicLayoutStorage* landscapeStorage; |
134 | DynamicLayoutStorage* genericStorage; |
135 | |
136 | + Qt::ScreenOrientation primaryOrientation; |
137 | + Qt::ScreenOrientation orientation; |
138 | + QRect geometry; |
139 | + |
140 | DynamicLayoutPrivate(DynamicLayout* _q) : |
141 | q(_q), |
142 | initialized(false), |
143 | @@ -132,34 +136,34 @@ |
144 | } |
145 | |
146 | // ToDo this needs to be refactored |
147 | - void initDynamicLayout() |
148 | + void initDynamicLayout(QString fileName) |
149 | { |
150 | q->instance(); |
151 | |
152 | if (!initialized) { |
153 | QQuickView quickView; |
154 | - quickView.setSource(QUrl::fromLocalFile(MALIIT_KEYBOARD_DATA_DIR "/maliit-ui-constants.qml")); |
155 | + quickView.setSource(QUrl::fromLocalFile( fileName )); |
156 | QQuickItem* quickItem = quickView.rootObject(); |
157 | |
158 | const QRect rLandscape = qGuiApp->primaryScreen()->mapBetween( |
159 | - qGuiApp->primaryScreen()->primaryOrientation(), |
160 | + primaryOrientation, |
161 | Qt::LandscapeOrientation, |
162 | - QGuiApplication::primaryScreen()->geometry()); |
163 | + geometry); |
164 | |
165 | const QRect rInvertedLandscape = qGuiApp->primaryScreen()->mapBetween( |
166 | - qGuiApp->primaryScreen()->primaryOrientation(), |
167 | + primaryOrientation, |
168 | Qt::InvertedLandscapeOrientation, |
169 | - QGuiApplication::primaryScreen()->geometry()); |
170 | + geometry); |
171 | |
172 | const QRect rPortrait = qGuiApp->primaryScreen()->mapBetween( |
173 | - qGuiApp->primaryScreen()->primaryOrientation(), |
174 | + primaryOrientation, |
175 | Qt::PortraitOrientation, |
176 | - QGuiApplication::primaryScreen()->geometry()); |
177 | + geometry); |
178 | |
179 | const QRect rInvertedPortrait = qGuiApp->primaryScreen()->mapBetween( |
180 | - qGuiApp->primaryScreen()->primaryOrientation(), |
181 | + primaryOrientation, |
182 | Qt::InvertedPortraitOrientation, |
183 | - QGuiApplication::primaryScreen()->geometry()); |
184 | + geometry); |
185 | |
186 | |
187 | // generic |
188 | @@ -179,7 +183,7 @@ |
189 | // portrait |
190 | |
191 | qreal portraitHeightRatio = quickItem->property("phone_keyboard_height_portrait").toReal(); |
192 | - if (qGuiApp->primaryScreen()->primaryOrientation() == Qt::LandscapeOrientation) |
193 | + if (primaryOrientation == Qt::LandscapeOrientation) |
194 | portraitHeightRatio = quickItem->property("tablet_keyboard_height_portrait").toReal(); |
195 | |
196 | portraitStorage->invisibleTouchAreaHeight = quickItem->property("portrait_invisible_touch_area").toInt(); |
197 | @@ -194,7 +198,7 @@ |
198 | |
199 | // point of origin differs when primary orientation is different |
200 | int yp = 0; |
201 | - if(qGuiApp->primaryScreen()->primaryOrientation() == Qt::PortraitOrientation) |
202 | + if(primaryOrientation == Qt::PortraitOrientation) |
203 | yp = rPortrait.height() - (portraitStorage->keypadHeight |
204 | + portraitStorage->wordRibbonHeight |
205 | + portraitStorage->invisibleTouchAreaHeight); |
206 | @@ -209,7 +213,7 @@ |
207 | |
208 | // point of origin differs when primary orientation is different |
209 | int ypi = 0; |
210 | - if(qGuiApp->primaryScreen()->primaryOrientation() == Qt::LandscapeOrientation) |
211 | + if(primaryOrientation == Qt::LandscapeOrientation) |
212 | ypi = rInvertedPortrait.height() - (portraitStorage->keypadHeight |
213 | + portraitStorage->wordRibbonHeight |
214 | + portraitStorage->invisibleTouchAreaHeight); |
215 | @@ -228,7 +232,7 @@ |
216 | // landscape |
217 | |
218 | qreal landscapeHeightRatio = quickItem->property("phone_keyboard_height_landscape").toReal(); |
219 | - if (qGuiApp->primaryScreen()->primaryOrientation() == Qt::LandscapeOrientation) |
220 | + if (primaryOrientation == Qt::LandscapeOrientation) |
221 | landscapeHeightRatio = quickItem->property("tablet_keyboard_height_landscape").toReal(); |
222 | |
223 | landscapeStorage->invisibleTouchAreaHeight = quickItem->property("landscape_invisible_touch_area").toInt(); |
224 | @@ -273,7 +277,7 @@ |
225 | genericStorage->keyWidthLarge = quickItem->property("key_width_large").toReal(); |
226 | genericStorage->keyWidthXLarge = quickItem->property("key_width_xlarge").toReal(); |
227 | genericStorage->keyWidthXXLarge = quickItem->property("key_width_xxlarge").toReal(); |
228 | - |
229 | + genericStorage->keyWidthStretched = quickItem->property("key_width_stretched").toReal(); |
230 | |
231 | landscapeStorage->spaceBetweenRows = quickItem->property("landscape_space_between_rows").toReal(); |
232 | landscapeStorage->spaceBetweenKeys = quickItem->property("landscape_space_between_keys").toReal(); |
233 | |
234 | === modified file 'maliit-keyboard/tests/common/common.pro' |
235 | --- maliit-keyboard/tests/common/common.pro 2013-08-06 19:58:25 +0000 |
236 | +++ maliit-keyboard/tests/common/common.pro 2013-08-09 11:00:42 +0000 |
237 | @@ -9,11 +9,13 @@ |
238 | utils-gui.cpp \ |
239 | inputmethodhostprobe.cpp \ |
240 | wordengineprobe.cpp \ |
241 | + mockscreen.cpp \ |
242 | |
243 | HEADERS += \ |
244 | utils.h \ |
245 | inputmethodhostprobe.h \ |
246 | wordengineprobe.h \ |
247 | + mockscreen.h \ |
248 | |
249 | contains(QT_MAJOR_VERSION, 4) { |
250 | QT = core gui |
251 | |
252 | === added file 'maliit-keyboard/tests/common/mockscreen.cpp' |
253 | --- maliit-keyboard/tests/common/mockscreen.cpp 1970-01-01 00:00:00 +0000 |
254 | +++ maliit-keyboard/tests/common/mockscreen.cpp 2013-08-09 11:00:42 +0000 |
255 | @@ -0,0 +1,64 @@ |
256 | +/* |
257 | + * Copyright 2013 Canonical Ltd. |
258 | + * |
259 | + * This program is free software; you can redistribute it and/or modify |
260 | + * it under the terms of the GNU Lesser General Public License as published by |
261 | + * the Free Software Foundation; version 3. |
262 | + * |
263 | + * This program is distributed in the hope that it will be useful, |
264 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
265 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
266 | + * GNU Lesser General Public License for more details. |
267 | + * |
268 | + * You should have received a copy of the GNU Lesser General Public License |
269 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
270 | + */ |
271 | + |
272 | +#include "mockscreen.h" |
273 | + |
274 | +MockScreen::MockScreen(QObject* parent) |
275 | + : QObject(parent) |
276 | + , m_orientation(Qt::PortraitOrientation) |
277 | + , m_primaryOrientation(Qt::PortraitOrientation) |
278 | + , m_geometry(QRect(0,0,0,0)) |
279 | +{ |
280 | +} |
281 | + |
282 | +Qt::ScreenOrientation MockScreen::orientation() const |
283 | +{ |
284 | + return m_orientation; |
285 | +} |
286 | + |
287 | +void MockScreen::setOrientation(Qt::ScreenOrientation orientation) |
288 | +{ |
289 | + m_orientation = orientation; |
290 | + Q_EMIT orientationChanged(orientation); |
291 | +} |
292 | + |
293 | +Qt::ScreenOrientation MockScreen::primaryOrientation() const |
294 | +{ |
295 | + return m_primaryOrientation; |
296 | +} |
297 | + |
298 | +void MockScreen::setPrimaryOrientation(Qt::ScreenOrientation orientation) |
299 | +{ |
300 | + m_primaryOrientation = orientation; |
301 | + Q_EMIT primaryOrientationChanged(orientation); |
302 | +} |
303 | + |
304 | +QRect MockScreen::geometry() const |
305 | +{ |
306 | + return m_geometry; |
307 | +} |
308 | + |
309 | +void MockScreen::setGeometry(const QRect& geometry) |
310 | +{ |
311 | + m_geometry = geometry; |
312 | + Q_EMIT geometryChanged(geometry); |
313 | +} |
314 | + |
315 | + |
316 | + |
317 | + |
318 | + |
319 | + |
320 | |
321 | === added file 'maliit-keyboard/tests/common/mockscreen.h' |
322 | --- maliit-keyboard/tests/common/mockscreen.h 1970-01-01 00:00:00 +0000 |
323 | +++ maliit-keyboard/tests/common/mockscreen.h 2013-08-09 11:00:42 +0000 |
324 | @@ -0,0 +1,57 @@ |
325 | +/* |
326 | + * Copyright 2013 Canonical Ltd. |
327 | + * |
328 | + * This program is free software; you can redistribute it and/or modify |
329 | + * it under the terms of the GNU Lesser General Public License as published by |
330 | + * the Free Software Foundation; version 3. |
331 | + * |
332 | + * This program is distributed in the hope that it will be useful, |
333 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
334 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
335 | + * GNU Lesser General Public License for more details. |
336 | + * |
337 | + * You should have received a copy of the GNU Lesser General Public License |
338 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
339 | + */ |
340 | + |
341 | +#ifndef MOCKSCREEN_H |
342 | +#define MOCKSCREEN_H |
343 | + |
344 | +#include <QScreen> |
345 | + |
346 | + |
347 | +/** |
348 | + * @brief The MockScreen class |
349 | + * this is not a real QScreen, but it can be used to change properties and fire related signals |
350 | + */ |
351 | + |
352 | +class MockScreen : public QObject |
353 | +{ |
354 | + Q_OBJECT |
355 | + |
356 | + Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) |
357 | + Q_PROPERTY(Qt::ScreenOrientation primaryOrientation READ primaryOrientation WRITE setPrimaryOrientation NOTIFY primaryOrientationChanged) |
358 | + Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry NOTIFY geometryChanged) |
359 | + |
360 | +public: |
361 | + MockScreen(QObject* parent = 0); |
362 | + |
363 | + Qt::ScreenOrientation orientation() const; |
364 | + Q_SLOT void setOrientation(Qt::ScreenOrientation orientation); |
365 | + Q_SIGNAL void orientationChanged(Qt::ScreenOrientation orientation); |
366 | + |
367 | + Qt::ScreenOrientation primaryOrientation() const; |
368 | + Q_SLOT void setPrimaryOrientation(Qt::ScreenOrientation orientation); |
369 | + Q_SIGNAL void primaryOrientationChanged(Qt::ScreenOrientation orientation); |
370 | + |
371 | + QRect geometry() const; |
372 | + Q_SLOT void setGeometry(const QRect& geometry); |
373 | + Q_SIGNAL void geometryChanged(const QRect& geometry); |
374 | + |
375 | +private: |
376 | + Qt::ScreenOrientation m_orientation; |
377 | + Qt::ScreenOrientation m_primaryOrientation; |
378 | + QRect m_geometry; |
379 | +}; |
380 | + |
381 | +#endif // MOCKSCREEN_H |
382 | |
383 | === added directory 'maliit-keyboard/tests/dynamic-layout' |
384 | === added file 'maliit-keyboard/tests/dynamic-layout/dynamic-layout.pro' |
385 | --- maliit-keyboard/tests/dynamic-layout/dynamic-layout.pro 1970-01-01 00:00:00 +0000 |
386 | +++ maliit-keyboard/tests/dynamic-layout/dynamic-layout.pro 2013-08-09 11:00:42 +0000 |
387 | @@ -0,0 +1,17 @@ |
388 | +include(../../config.pri) |
389 | +include(../common-check.pri) |
390 | +include(../../config-plugin.pri) |
391 | + |
392 | +#CONFIG += testlib |
393 | +TEMPLATE = app |
394 | +TARGET = ut_dynamiclayout |
395 | +INCLUDEPATH += . ../ ../../lib ../../ |
396 | +QT = core testlib gui quick |
397 | + |
398 | + |
399 | +TOP_BUILDDIR = $${OUT_PWD}/../.. |
400 | +LIBS += -L$${TOP_BUILDDIR}/plugin -lmaliit-keyboard-plugin |
401 | + |
402 | +OTHER_FILES += test-ui-constants.qml |
403 | + |
404 | +SOURCES += test.cpp |
405 | |
406 | === added file 'maliit-keyboard/tests/dynamic-layout/test-ui-constants.qml' |
407 | --- maliit-keyboard/tests/dynamic-layout/test-ui-constants.qml 1970-01-01 00:00:00 +0000 |
408 | +++ maliit-keyboard/tests/dynamic-layout/test-ui-constants.qml 2013-08-09 11:00:42 +0000 |
409 | @@ -0,0 +1,79 @@ |
410 | +/* |
411 | + * Copyright 2013 Canonical Ltd. |
412 | + * |
413 | + * This program is free software; you can redistribute it and/or modify |
414 | + * it under the terms of the GNU Lesser General Public License as published by |
415 | + * the Free Software Foundation; version 3. |
416 | + * |
417 | + * This program is distributed in the hope that it will be useful, |
418 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
419 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
420 | + * GNU Lesser General Public License for more details. |
421 | + * |
422 | + * You should have received a copy of the GNU Lesser General Public License |
423 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
424 | + */ |
425 | + |
426 | +import QtQuick 2.0 |
427 | +import Ubuntu.Components 0.1 |
428 | + |
429 | + |
430 | +/** |
431 | + * these items only hold variables |
432 | + */ |
433 | + |
434 | +Item { |
435 | + id: keyboard_constants |
436 | + |
437 | + property real key_area_borders: units.gu( 1.222 ); |
438 | + property string font_color: "#666666" |
439 | + property string font_family: "Ubuntu Medium" |
440 | + |
441 | + property int reference_width: 720 |
442 | + property int reference_height: 468 |
443 | + |
444 | + property int portrait_invisible_touch_area: units.gu( 6.777 ); |
445 | + property int portrait_keyboard_visible_height: units.gu( 26.0 ); |
446 | + property real portrait_keyboard_screen_width_ratio: 1.0 |
447 | + |
448 | + property real portrait_top_margin: units.gu( 1.35 ); |
449 | + property real landscape_top_margin: units.gu( 4.35 ); |
450 | + property real portrait_bottom_margin: units.gu( 2.00 ); |
451 | + property real landscape_bottom_margin: units.gu( 2.00 ); |
452 | + |
453 | + property real key_height: units.gu( 4.888 ); // not used |
454 | + |
455 | + // make sure when you change these, also change the unittest |
456 | + property real key_width_small: 10 |
457 | + property real key_width_medium: 12 |
458 | + property real key_width_large: 15 // shift |
459 | + property real key_width_xlarge: 18 // 123 key |
460 | + property real key_width_xxlarge: 24 // space |
461 | + property real key_width_stretched: 30 // ? |
462 | + |
463 | + property real font_size: 12; |
464 | + property real font_size_small: 10; |
465 | + |
466 | + property int landscape_invisible_touch_area: units.gu( 6.777 ); |
467 | + property int landscape_keyboard_visible_height: units.gu( 33.4 ); |
468 | + property real landscape_keyboard_screen_width_ratio: 1.0 |
469 | + |
470 | + property real landscape_space_between_rows: units.dp( 0.00 ); |
471 | + property real landscape_space_between_keys: units.dp( 0.00 ); |
472 | + property real portrait_space_between_rows: units.dp( 2.00 ); |
473 | + property real portrait_space_between_keys: units.dp( 10.00 ); |
474 | + |
475 | + property string key_background_normal: "keybg@18.png" |
476 | + property string key_background_special: "keybg_action@18.png" |
477 | + property string key_background_deadkey: "" |
478 | + |
479 | + property real phone_keyboard_height_portrait: 0.365; |
480 | + property real phone_keyboard_height_landscape: 0.50; |
481 | + |
482 | + property real tablet_keyboard_height_portrait: 0.28; |
483 | + property real tablet_keyboard_height_landscape: 0.38; |
484 | + |
485 | + property int landscape_wordribbon_height: units.gu( 4.0 ); |
486 | + property int portrait_wordribbon_height: units.gu( 4.0 ); |
487 | +} |
488 | + |
489 | |
490 | === added file 'maliit-keyboard/tests/dynamic-layout/test.cpp' |
491 | --- maliit-keyboard/tests/dynamic-layout/test.cpp 1970-01-01 00:00:00 +0000 |
492 | +++ maliit-keyboard/tests/dynamic-layout/test.cpp 2013-08-09 11:00:42 +0000 |
493 | @@ -0,0 +1,186 @@ |
494 | +/* |
495 | + * Copyright 2013 Canonical Ltd. |
496 | + * |
497 | + * This program is free software; you can redistribute it and/or modify |
498 | + * it under the terms of the GNU Lesser General Public License as published by |
499 | + * the Free Software Foundation; version 3. |
500 | + * |
501 | + * This program is distributed in the hope that it will be useful, |
502 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
503 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
504 | + * GNU Lesser General Public License for more details. |
505 | + * |
506 | + * You should have received a copy of the GNU Lesser General Public License |
507 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
508 | + */ |
509 | + |
510 | + |
511 | +#include "plugin/inputmethod.h" |
512 | +#include "lib/models/wordribbon.h" |
513 | +#include "lib/models/styleattributes.h" |
514 | + |
515 | +#include "lib/logic/dynamiclayout.h" |
516 | +#include "lib/logic/keyboardloader.h" |
517 | +#include "lib/logic/layouthelper.h" |
518 | +#include "lib/logic/keyareaconverter.h" |
519 | +#include "lib/logic/style.h" |
520 | + |
521 | +#include "common/inputmethodhostprobe.h" |
522 | +#include "common/mockscreen.h" |
523 | + |
524 | +#include <maliit/plugins/abstractinputmethodhost.h> |
525 | + |
526 | +#include <QtTest/QtTest> |
527 | + |
528 | +using namespace MaliitKeyboard; |
529 | +using namespace MaliitKeyboard::Logic; |
530 | + |
531 | +const QRect referenceScreenGeometry(0,0,720,1280); |
532 | + |
533 | +class TestDynamicLayout: public QObject |
534 | +{ |
535 | + Q_OBJECT |
536 | +private: |
537 | + |
538 | + void connectUiConstToScreen(const MockScreen& mockScreen) |
539 | + { |
540 | + const QScreen* screen = qGuiApp->primaryScreen(); |
541 | + disconnect( screen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)), uiConst, SLOT(onPrimaryOrientationChanged(Qt::ScreenOrientation)) ); |
542 | + disconnect( screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)), uiConst, SLOT(onPrimaryOrientationChanged(Qt::ScreenOrientation)) ); |
543 | + disconnect( screen, SIGNAL(geometryChanged(QRect)), uiConst, SLOT(onGeometryChanged(QRect)) ); |
544 | + |
545 | + connect( &mockScreen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)), uiConst, SLOT(onPrimaryOrientationChanged(Qt::ScreenOrientation)) ); |
546 | + connect( &mockScreen, SIGNAL(orientationChanged(Qt::ScreenOrientation)), uiConst, SLOT(onPrimaryOrientationChanged(Qt::ScreenOrientation)) ); |
547 | + connect( &mockScreen, SIGNAL(geometryChanged(QRect)), uiConst, SLOT(onGeometryChanged(QRect)) ); |
548 | + } |
549 | + |
550 | + Q_SLOT void dynamicLayout() |
551 | + { |
552 | + uiConst->instance(); |
553 | + QVERIFY(uiConst); |
554 | + |
555 | + MockScreen mockScreen; |
556 | + connectUiConstToScreen(mockScreen); |
557 | + |
558 | + mockScreen.setGeometry(QRect(0,0, 300,400)); |
559 | + mockScreen.setOrientation(Qt::PortraitOrientation); |
560 | + mockScreen.setPrimaryOrientation(Qt::PortraitOrientation); |
561 | + |
562 | + uiConst->initDynamicLayout( "maliit-keyboard/tests/dynamic-layout/test-ui-constants.qml" ); |
563 | + QCOMPARE( uiConst->windowGeometryRect(Qt::PortraitOrientation).width(), 300 ); |
564 | + |
565 | + KeyboardLoader loader; |
566 | + loader.setActiveId("en_us"); // TODO add a test layout |
567 | + Keyboard kb = loader.keyboard(); |
568 | + |
569 | + QVERIFY(kb.keys.size() > 0); |
570 | + QVERIFY2(kb.keys.size() == 33, "test if en_us layout contains 33 keys"); |
571 | + |
572 | + uiConst->reset(); |
573 | + connectUiConstToScreen(mockScreen); |
574 | + |
575 | + // this is important, so uiConst gets signals and changes internally |
576 | + mockScreen.setGeometry( referenceScreenGeometry ); |
577 | + mockScreen.setOrientation(Qt::PortraitOrientation); |
578 | + mockScreen.setPrimaryOrientation(Qt::PortraitOrientation); |
579 | + |
580 | + uiConst->initDynamicLayout( "maliit-keyboard/tests/dynamic-layout/test-ui-constants.qml" ); |
581 | + |
582 | + QCOMPARE( uiConst->windowGeometryRect(Qt::PortraitOrientation).width(), 720 ); |
583 | + |
584 | + // this should remain the same even if we rotate the screen, as we depend on contentOrientation |
585 | + mockScreen.setOrientation(Qt::LandscapeOrientation); |
586 | + QCOMPARE( uiConst->windowGeometryRect(Qt::PortraitOrientation).width(), 720 ); |
587 | + |
588 | + // virtual width depending on contentOrientation |
589 | + QCOMPARE( uiConst->windowWidth(LayoutHelper::Portrait), 720 ); |
590 | + QCOMPARE( uiConst->windowWidth(LayoutHelper::Landscape), 1280 ); |
591 | + |
592 | + // not sure if we need this in future |
593 | + QVector<int> margins = uiConst->calculateMargins(LayoutHelper::Portrait, kb); |
594 | + QVERIFY( margins[0] > 0 ); |
595 | + |
596 | + // TODO orientation argument not needed, qreal not needed |
597 | + QCOMPARE( uiConst->keyWidth(LayoutHelper::Portrait, KeyDescription::Small), 10.0 ); |
598 | + QCOMPARE( uiConst->keyWidth(LayoutHelper::Portrait, KeyDescription::Medium), 12.0 ); |
599 | + QCOMPARE( uiConst->keyWidth(LayoutHelper::Portrait, KeyDescription::Large), 15.0 ); |
600 | + QCOMPARE( uiConst->keyWidth(LayoutHelper::Portrait, KeyDescription::XLarge), 18.0 ); |
601 | + QCOMPARE( uiConst->keyWidth(LayoutHelper::Portrait, KeyDescription::XXLarge), 24.0 ); |
602 | + QCOMPARE( uiConst->keyWidth(LayoutHelper::Portrait, KeyDescription::Stretched), 30.0 ); |
603 | + |
604 | + // keyHeight() not tested, calculated |
605 | + |
606 | + QCOMPARE( uiConst->fontSize(LayoutHelper::Portrait), 12.0 ); |
607 | + QCOMPARE( uiConst->fontSizeSmall(LayoutHelper::Portrait), 10.0 ); |
608 | + } |
609 | + |
610 | + /* |
611 | + * Area |
612 | + * size QSize |
613 | + * background QByteArray |
614 | + * backgroundBorders QMargins |
615 | + * |
616 | + * Key |
617 | + * origin QPoint |
618 | + * area Area |
619 | + * label Label |
620 | + * action Action |
621 | + * style Key::Style (normal, special, dead) |
622 | + * margins QMargins |
623 | + * icon QByteArray |
624 | + * has_extended_keys bool |
625 | + * flags_padding int |
626 | + * command_sequence QString |
627 | + * |
628 | + * Label |
629 | + * text QString |
630 | + * font Font |
631 | + * rect QRect |
632 | + * |
633 | + * Font |
634 | + * name QByteArray |
635 | + * size int |
636 | + * color QByteArray |
637 | + * stretch int |
638 | + * |
639 | + * KeyDescription |
640 | + * row int |
641 | + * flags: left|right spacer, rtl-icon |
642 | + * width KeyDescription::Width (Small, Medium, ...) |
643 | + * icon KeyDescription::Icon (no, return, backspace, shift, ...) |
644 | + * font_group KeyDescription::FontGroup (normal, big) |
645 | + * |
646 | + * Keyboard |
647 | + * style name QString |
648 | + * keys vector of Key |
649 | + * descriptions vector of KeyDescription |
650 | + * |
651 | + * KeyArea |
652 | + * keys vector of Keys |
653 | + * origin QPoint |
654 | + * area Area |
655 | + * margin qreal |
656 | + **/ |
657 | + |
658 | + |
659 | + Q_SLOT void keyAreaConverter() |
660 | + { |
661 | + KeyboardLoader loader; |
662 | + loader.setActiveId("en_us"); |
663 | + |
664 | + // this really seems overkill |
665 | + Style* style = new Style; |
666 | + style->setProfile("ubuntu"); |
667 | + |
668 | + KeyAreaConverter converter(style->attributes(), &loader); |
669 | + converter.setLayoutOrientation(MaliitKeyboard::Logic::LayoutHelper::Portrait); |
670 | + |
671 | + KeyArea area = converter.keyArea(); |
672 | + |
673 | + QVERIFY2( area.keys().size() == 33, "Make sure all keys are in keyarea" ); |
674 | + } |
675 | +}; |
676 | + |
677 | + |
678 | +QTEST_MAIN(TestDynamicLayout) |
679 | +#include "test.moc" |
680 | |
681 | === modified file 'maliit-keyboard/tests/tests.pro' |
682 | --- maliit-keyboard/tests/tests.pro 2013-08-06 19:58:25 +0000 |
683 | +++ maliit-keyboard/tests/tests.pro 2013-08-09 11:00:42 +0000 |
684 | @@ -10,6 +10,7 @@ |
685 | qml-test-app \ |
686 | qml-api-tests \ |
687 | wordengine \ |
688 | + dynamic-layout \ |
689 | |
690 | CONFIG += ordered |
691 | QMAKE_EXTRA_TARGETS += check |
692 | |
693 | === modified file 'unittests.sh' |
694 | --- unittests.sh 2013-08-06 19:58:25 +0000 |
695 | +++ unittests.sh 2013-08-09 11:00:42 +0000 |
696 | @@ -9,3 +9,4 @@ |
697 | qmltestrunner -import maliit-keyboard/tests/qml-api-tests/imports/ -input maliit-keyboard/tests/qml-api-tests/tst_inputMethodHints.qml |
698 | |
699 | |
700 | + |
PASSED: Continuous integration, rev:2141 jenkins. qa.ubuntu. com/job/ phablet- extras- maliit- plugins- ci/115/ jenkins. qa.ubuntu. com/job/ phablet- extras- maliit- plugins- saucy-armhf- ci/67 jenkins. qa.ubuntu. com/job/ phablet- extras- maliit- plugins- saucy-armhf- ci/67/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ phablet- extras- maliit- plugins- saucy-i386- ci/67
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ phablet- extras- maliit- plugins- ci/115/ rebuild
http://