Merge lp:~thomas-moenicke/phablet-extras/maliit-plugins-dynamic-unittests into lp:phablet-extras/maliit-plugins

Proposed by Thomas Moenicke
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
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

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Günter Schwann (schwann) wrote :

Missing copyright header for
maliit-keyboard/tests/common/mockscreen.cpp
maliit-keyboard/tests/dynamic-layout/test-ui-constants.qml
maliit-keyboard/tests/dynamic-layout/test.cpp

review: Needs Fixing
Revision history for this message
Günter Schwann (schwann) wrote :

616 + qDebug() << area.keys().at(i).origin() << area.keys().at(i).area().size();
Why printing all the debugging, after the test?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Günter Schwann (schwann) wrote :

looks good now

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2013-08-08 14:28:33 +0000
+++ debian/changelog 2013-08-09 11:00:42 +0000
@@ -1,4 +1,10 @@
1maliit-plugins (0.99.trunk.phablet4) saycu; urgency=low1maliit-plugins (0.99.trunk.phablet5) saucy; urgency=low
2
3 * improved email layout
4
5 -- Thomas Moenicke <thomas@pachamama> Fri, 09 Aug 2013 12:59:46 +0200
6
7maliit-plugins (0.99.trunk.phablet4) saucy; urgency=low
28
3 * url, phonenumber and number layouts9 * url, phonenumber and number layouts
410
511
=== modified file 'maliit-keyboard/data/languages/email.xml'
--- maliit-keyboard/data/languages/email.xml 2013-08-07 20:38:19 +0000
+++ maliit-keyboard/data/languages/email.xml 2013-08-09 11:00:42 +0000
@@ -464,10 +464,10 @@
464 <binding action="sym" label="?123" />464 <binding action="sym" label="?123" />
465 </key>465 </key>
466 <spacer />466 <spacer />
467 <key id="urlKey">467 <key id="emailKey">
468 <binding label=".com" />468 <binding label="@" />
469 </key>469 </key>
470 <key width="large">470 <key width="x-large">
471 <binding action="space" />471 <binding action="space" />
472 </key>472 </key>
473 <key id="urlKey" width="large">473 <key id="urlKey" width="large">
474474
=== modified file 'maliit-keyboard/lib/logic/dynamiclayout.cpp'
--- maliit-keyboard/lib/logic/dynamiclayout.cpp 2013-08-08 10:45:11 +0000
+++ maliit-keyboard/lib/logic/dynamiclayout.cpp 2013-08-09 11:00:42 +0000
@@ -84,13 +84,23 @@
8484
85DynamicLayout::DynamicLayout(QObject* parent) : QObject(parent),85DynamicLayout::DynamicLayout(QObject* parent) : QObject(parent),
86 d(new DynamicLayoutPrivate(this))86 d(new DynamicLayoutPrivate(this))
87{}87{
88 const QScreen* screen = qGuiApp->primaryScreen();
89 connect( screen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)), this, SLOT(onPrimaryOrientationChanged(Qt::ScreenOrientation)) );
90 connect( screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)), this, SLOT(onPrimaryOrientationChanged(Qt::ScreenOrientation)) );
91 connect( screen, SIGNAL(geometryChanged(QRect)), this, SLOT(onGeometryChanged(QRect)) );
92
93 d->primaryOrientation = screen->primaryOrientation();
94 d->orientation = screen->orientation();
95 d->geometry = screen->geometry();
96}
97
8898
89DynamicLayout* DynamicLayout::self = 0;99DynamicLayout* DynamicLayout::self = 0;
90100
91void DynamicLayout::initDynamicLayout()101void DynamicLayout::initDynamicLayout(QString fileName)
92{102{
93 d->initDynamicLayout();103 d->initDynamicLayout(fileName);
94}104}
95105
96int DynamicLayout::windowWidth(LayoutHelper::Orientation orientation)106int DynamicLayout::windowWidth(LayoutHelper::Orientation orientation)
@@ -306,4 +316,22 @@
306 }316 }
307}317}
308318
319void DynamicLayout::onPrimaryOrientationChanged(Qt::ScreenOrientation orientation)
320{
321 d->primaryOrientation = orientation;
322}
323
324void DynamicLayout::onOrientationChanged(Qt::ScreenOrientation orientation)
325{
326 d->orientation = orientation;
327}
328
329void DynamicLayout::onGeometryChanged(const QRect & geometry)
330{
331 d->geometry = geometry;
332 d->invalidateWindowGeometryCache();
333}
334
335
336
309}} // namespaces337}} // namespaces
310338
=== modified file 'maliit-keyboard/lib/logic/dynamiclayout.h'
--- maliit-keyboard/lib/logic/dynamiclayout.h 2013-07-30 16:16:14 +0000
+++ maliit-keyboard/lib/logic/dynamiclayout.h 2013-08-09 11:00:42 +0000
@@ -48,7 +48,13 @@
48 return self;48 return self;
49 }49 }
5050
51 void initDynamicLayout();51 static void reset()
52 {
53 if (self)
54 self = new DynamicLayout;
55 }
56
57 void initDynamicLayout(QString fileName = MALIIT_KEYBOARD_DATA_DIR "/maliit-ui-constants.qml");
5258
53 int keypadHeight(LayoutHelper::Orientation orientation);59 int keypadHeight(LayoutHelper::Orientation orientation);
54 int windowWidth(LayoutHelper::Orientation orientation);60 int windowWidth(LayoutHelper::Orientation orientation);
@@ -84,6 +90,11 @@
8490
85 Q_SLOT void onWordEngineSettingsChanged(bool wordEngineEnabled);91 Q_SLOT void onWordEngineSettingsChanged(bool wordEngineEnabled);
8692
93 /* interface to primaryScreen */
94 Q_SLOT void onPrimaryOrientationChanged(Qt::ScreenOrientation orientation);
95 Q_SLOT void onOrientationChanged(Qt::ScreenOrientation orientation);
96 Q_SLOT void onGeometryChanged(const QRect & geometry);
97
87private:98private:
88 explicit DynamicLayout(QObject *parent = 0);99 explicit DynamicLayout(QObject *parent = 0);
89 DynamicLayout(DynamicLayout const&) : QObject(0) {}100 DynamicLayout(DynamicLayout const&) : QObject(0) {}
90101
=== modified file 'maliit-keyboard/lib/logic/dynamiclayout_p.h'
--- maliit-keyboard/lib/logic/dynamiclayout_p.h 2013-07-30 16:16:14 +0000
+++ maliit-keyboard/lib/logic/dynamiclayout_p.h 2013-08-09 11:00:42 +0000
@@ -59,7 +59,7 @@
5959
60 DynamicLayoutStorage* storage(LayoutHelper::Orientation orientation)60 DynamicLayoutStorage* storage(LayoutHelper::Orientation orientation)
61 {61 {
62 initDynamicLayout();62 q->initDynamicLayout();
6363
64 if (orientation == LayoutHelper::Landscape)64 if (orientation == LayoutHelper::Landscape)
65 return landscapeStorage;65 return landscapeStorage;
@@ -112,6 +112,10 @@
112 DynamicLayoutStorage* landscapeStorage;112 DynamicLayoutStorage* landscapeStorage;
113 DynamicLayoutStorage* genericStorage;113 DynamicLayoutStorage* genericStorage;
114114
115 Qt::ScreenOrientation primaryOrientation;
116 Qt::ScreenOrientation orientation;
117 QRect geometry;
118
115 DynamicLayoutPrivate(DynamicLayout* _q) :119 DynamicLayoutPrivate(DynamicLayout* _q) :
116 q(_q),120 q(_q),
117 initialized(false),121 initialized(false),
@@ -132,34 +136,34 @@
132 }136 }
133137
134 // ToDo this needs to be refactored138 // ToDo this needs to be refactored
135 void initDynamicLayout()139 void initDynamicLayout(QString fileName)
136 {140 {
137 q->instance();141 q->instance();
138142
139 if (!initialized) {143 if (!initialized) {
140 QQuickView quickView;144 QQuickView quickView;
141 quickView.setSource(QUrl::fromLocalFile(MALIIT_KEYBOARD_DATA_DIR "/maliit-ui-constants.qml"));145 quickView.setSource(QUrl::fromLocalFile( fileName ));
142 QQuickItem* quickItem = quickView.rootObject();146 QQuickItem* quickItem = quickView.rootObject();
143147
144 const QRect rLandscape = qGuiApp->primaryScreen()->mapBetween(148 const QRect rLandscape = qGuiApp->primaryScreen()->mapBetween(
145 qGuiApp->primaryScreen()->primaryOrientation(),149 primaryOrientation,
146 Qt::LandscapeOrientation,150 Qt::LandscapeOrientation,
147 QGuiApplication::primaryScreen()->geometry());151 geometry);
148152
149 const QRect rInvertedLandscape = qGuiApp->primaryScreen()->mapBetween(153 const QRect rInvertedLandscape = qGuiApp->primaryScreen()->mapBetween(
150 qGuiApp->primaryScreen()->primaryOrientation(),154 primaryOrientation,
151 Qt::InvertedLandscapeOrientation,155 Qt::InvertedLandscapeOrientation,
152 QGuiApplication::primaryScreen()->geometry());156 geometry);
153157
154 const QRect rPortrait = qGuiApp->primaryScreen()->mapBetween(158 const QRect rPortrait = qGuiApp->primaryScreen()->mapBetween(
155 qGuiApp->primaryScreen()->primaryOrientation(),159 primaryOrientation,
156 Qt::PortraitOrientation,160 Qt::PortraitOrientation,
157 QGuiApplication::primaryScreen()->geometry());161 geometry);
158162
159 const QRect rInvertedPortrait = qGuiApp->primaryScreen()->mapBetween(163 const QRect rInvertedPortrait = qGuiApp->primaryScreen()->mapBetween(
160 qGuiApp->primaryScreen()->primaryOrientation(),164 primaryOrientation,
161 Qt::InvertedPortraitOrientation,165 Qt::InvertedPortraitOrientation,
162 QGuiApplication::primaryScreen()->geometry());166 geometry);
163167
164168
165 // generic169 // generic
@@ -179,7 +183,7 @@
179 // portrait183 // portrait
180184
181 qreal portraitHeightRatio = quickItem->property("phone_keyboard_height_portrait").toReal();185 qreal portraitHeightRatio = quickItem->property("phone_keyboard_height_portrait").toReal();
182 if (qGuiApp->primaryScreen()->primaryOrientation() == Qt::LandscapeOrientation)186 if (primaryOrientation == Qt::LandscapeOrientation)
183 portraitHeightRatio = quickItem->property("tablet_keyboard_height_portrait").toReal();187 portraitHeightRatio = quickItem->property("tablet_keyboard_height_portrait").toReal();
184188
185 portraitStorage->invisibleTouchAreaHeight = quickItem->property("portrait_invisible_touch_area").toInt();189 portraitStorage->invisibleTouchAreaHeight = quickItem->property("portrait_invisible_touch_area").toInt();
@@ -194,7 +198,7 @@
194198
195 // point of origin differs when primary orientation is different199 // point of origin differs when primary orientation is different
196 int yp = 0;200 int yp = 0;
197 if(qGuiApp->primaryScreen()->primaryOrientation() == Qt::PortraitOrientation)201 if(primaryOrientation == Qt::PortraitOrientation)
198 yp = rPortrait.height() - (portraitStorage->keypadHeight202 yp = rPortrait.height() - (portraitStorage->keypadHeight
199 + portraitStorage->wordRibbonHeight203 + portraitStorage->wordRibbonHeight
200 + portraitStorage->invisibleTouchAreaHeight);204 + portraitStorage->invisibleTouchAreaHeight);
@@ -209,7 +213,7 @@
209213
210 // point of origin differs when primary orientation is different214 // point of origin differs when primary orientation is different
211 int ypi = 0;215 int ypi = 0;
212 if(qGuiApp->primaryScreen()->primaryOrientation() == Qt::LandscapeOrientation)216 if(primaryOrientation == Qt::LandscapeOrientation)
213 ypi = rInvertedPortrait.height() - (portraitStorage->keypadHeight217 ypi = rInvertedPortrait.height() - (portraitStorage->keypadHeight
214 + portraitStorage->wordRibbonHeight218 + portraitStorage->wordRibbonHeight
215 + portraitStorage->invisibleTouchAreaHeight);219 + portraitStorage->invisibleTouchAreaHeight);
@@ -228,7 +232,7 @@
228 // landscape232 // landscape
229233
230 qreal landscapeHeightRatio = quickItem->property("phone_keyboard_height_landscape").toReal();234 qreal landscapeHeightRatio = quickItem->property("phone_keyboard_height_landscape").toReal();
231 if (qGuiApp->primaryScreen()->primaryOrientation() == Qt::LandscapeOrientation)235 if (primaryOrientation == Qt::LandscapeOrientation)
232 landscapeHeightRatio = quickItem->property("tablet_keyboard_height_landscape").toReal();236 landscapeHeightRatio = quickItem->property("tablet_keyboard_height_landscape").toReal();
233237
234 landscapeStorage->invisibleTouchAreaHeight = quickItem->property("landscape_invisible_touch_area").toInt();238 landscapeStorage->invisibleTouchAreaHeight = quickItem->property("landscape_invisible_touch_area").toInt();
@@ -273,7 +277,7 @@
273 genericStorage->keyWidthLarge = quickItem->property("key_width_large").toReal();277 genericStorage->keyWidthLarge = quickItem->property("key_width_large").toReal();
274 genericStorage->keyWidthXLarge = quickItem->property("key_width_xlarge").toReal();278 genericStorage->keyWidthXLarge = quickItem->property("key_width_xlarge").toReal();
275 genericStorage->keyWidthXXLarge = quickItem->property("key_width_xxlarge").toReal();279 genericStorage->keyWidthXXLarge = quickItem->property("key_width_xxlarge").toReal();
276280 genericStorage->keyWidthStretched = quickItem->property("key_width_stretched").toReal();
277281
278 landscapeStorage->spaceBetweenRows = quickItem->property("landscape_space_between_rows").toReal();282 landscapeStorage->spaceBetweenRows = quickItem->property("landscape_space_between_rows").toReal();
279 landscapeStorage->spaceBetweenKeys = quickItem->property("landscape_space_between_keys").toReal();283 landscapeStorage->spaceBetweenKeys = quickItem->property("landscape_space_between_keys").toReal();
280284
=== modified file 'maliit-keyboard/tests/common/common.pro'
--- maliit-keyboard/tests/common/common.pro 2013-08-06 19:58:25 +0000
+++ maliit-keyboard/tests/common/common.pro 2013-08-09 11:00:42 +0000
@@ -9,11 +9,13 @@
9 utils-gui.cpp \9 utils-gui.cpp \
10 inputmethodhostprobe.cpp \10 inputmethodhostprobe.cpp \
11 wordengineprobe.cpp \11 wordengineprobe.cpp \
12 mockscreen.cpp \
1213
13HEADERS += \14HEADERS += \
14 utils.h \15 utils.h \
15 inputmethodhostprobe.h \16 inputmethodhostprobe.h \
16 wordengineprobe.h \17 wordengineprobe.h \
18 mockscreen.h \
1719
18contains(QT_MAJOR_VERSION, 4) {20contains(QT_MAJOR_VERSION, 4) {
19 QT = core gui21 QT = core gui
2022
=== added file 'maliit-keyboard/tests/common/mockscreen.cpp'
--- maliit-keyboard/tests/common/mockscreen.cpp 1970-01-01 00:00:00 +0000
+++ maliit-keyboard/tests/common/mockscreen.cpp 2013-08-09 11:00:42 +0000
@@ -0,0 +1,64 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "mockscreen.h"
18
19MockScreen::MockScreen(QObject* parent)
20 : QObject(parent)
21 , m_orientation(Qt::PortraitOrientation)
22 , m_primaryOrientation(Qt::PortraitOrientation)
23 , m_geometry(QRect(0,0,0,0))
24{
25}
26
27Qt::ScreenOrientation MockScreen::orientation() const
28{
29 return m_orientation;
30}
31
32void MockScreen::setOrientation(Qt::ScreenOrientation orientation)
33{
34 m_orientation = orientation;
35 Q_EMIT orientationChanged(orientation);
36}
37
38Qt::ScreenOrientation MockScreen::primaryOrientation() const
39{
40 return m_primaryOrientation;
41}
42
43void MockScreen::setPrimaryOrientation(Qt::ScreenOrientation orientation)
44{
45 m_primaryOrientation = orientation;
46 Q_EMIT primaryOrientationChanged(orientation);
47}
48
49QRect MockScreen::geometry() const
50{
51 return m_geometry;
52}
53
54void MockScreen::setGeometry(const QRect& geometry)
55{
56 m_geometry = geometry;
57 Q_EMIT geometryChanged(geometry);
58}
59
60
61
62
63
64
065
=== added file 'maliit-keyboard/tests/common/mockscreen.h'
--- maliit-keyboard/tests/common/mockscreen.h 1970-01-01 00:00:00 +0000
+++ maliit-keyboard/tests/common/mockscreen.h 2013-08-09 11:00:42 +0000
@@ -0,0 +1,57 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MOCKSCREEN_H
18#define MOCKSCREEN_H
19
20#include <QScreen>
21
22
23/**
24 * @brief The MockScreen class
25 * this is not a real QScreen, but it can be used to change properties and fire related signals
26 */
27
28class MockScreen : public QObject
29{
30 Q_OBJECT
31
32 Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
33 Q_PROPERTY(Qt::ScreenOrientation primaryOrientation READ primaryOrientation WRITE setPrimaryOrientation NOTIFY primaryOrientationChanged)
34 Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry NOTIFY geometryChanged)
35
36public:
37 MockScreen(QObject* parent = 0);
38
39 Qt::ScreenOrientation orientation() const;
40 Q_SLOT void setOrientation(Qt::ScreenOrientation orientation);
41 Q_SIGNAL void orientationChanged(Qt::ScreenOrientation orientation);
42
43 Qt::ScreenOrientation primaryOrientation() const;
44 Q_SLOT void setPrimaryOrientation(Qt::ScreenOrientation orientation);
45 Q_SIGNAL void primaryOrientationChanged(Qt::ScreenOrientation orientation);
46
47 QRect geometry() const;
48 Q_SLOT void setGeometry(const QRect& geometry);
49 Q_SIGNAL void geometryChanged(const QRect& geometry);
50
51private:
52 Qt::ScreenOrientation m_orientation;
53 Qt::ScreenOrientation m_primaryOrientation;
54 QRect m_geometry;
55};
56
57#endif // MOCKSCREEN_H
058
=== added directory 'maliit-keyboard/tests/dynamic-layout'
=== added file 'maliit-keyboard/tests/dynamic-layout/dynamic-layout.pro'
--- maliit-keyboard/tests/dynamic-layout/dynamic-layout.pro 1970-01-01 00:00:00 +0000
+++ maliit-keyboard/tests/dynamic-layout/dynamic-layout.pro 2013-08-09 11:00:42 +0000
@@ -0,0 +1,17 @@
1include(../../config.pri)
2include(../common-check.pri)
3include(../../config-plugin.pri)
4
5#CONFIG += testlib
6TEMPLATE = app
7TARGET = ut_dynamiclayout
8INCLUDEPATH += . ../ ../../lib ../../
9QT = core testlib gui quick
10
11
12TOP_BUILDDIR = $${OUT_PWD}/../..
13LIBS += -L$${TOP_BUILDDIR}/plugin -lmaliit-keyboard-plugin
14
15OTHER_FILES += test-ui-constants.qml
16
17SOURCES += test.cpp
018
=== added file 'maliit-keyboard/tests/dynamic-layout/test-ui-constants.qml'
--- maliit-keyboard/tests/dynamic-layout/test-ui-constants.qml 1970-01-01 00:00:00 +0000
+++ maliit-keyboard/tests/dynamic-layout/test-ui-constants.qml 2013-08-09 11:00:42 +0000
@@ -0,0 +1,79 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19
20
21/**
22 * these items only hold variables
23 */
24
25Item {
26 id: keyboard_constants
27
28 property real key_area_borders: units.gu( 1.222 );
29 property string font_color: "#666666"
30 property string font_family: "Ubuntu Medium"
31
32 property int reference_width: 720
33 property int reference_height: 468
34
35 property int portrait_invisible_touch_area: units.gu( 6.777 );
36 property int portrait_keyboard_visible_height: units.gu( 26.0 );
37 property real portrait_keyboard_screen_width_ratio: 1.0
38
39 property real portrait_top_margin: units.gu( 1.35 );
40 property real landscape_top_margin: units.gu( 4.35 );
41 property real portrait_bottom_margin: units.gu( 2.00 );
42 property real landscape_bottom_margin: units.gu( 2.00 );
43
44 property real key_height: units.gu( 4.888 ); // not used
45
46 // make sure when you change these, also change the unittest
47 property real key_width_small: 10
48 property real key_width_medium: 12
49 property real key_width_large: 15 // shift
50 property real key_width_xlarge: 18 // 123 key
51 property real key_width_xxlarge: 24 // space
52 property real key_width_stretched: 30 // ?
53
54 property real font_size: 12;
55 property real font_size_small: 10;
56
57 property int landscape_invisible_touch_area: units.gu( 6.777 );
58 property int landscape_keyboard_visible_height: units.gu( 33.4 );
59 property real landscape_keyboard_screen_width_ratio: 1.0
60
61 property real landscape_space_between_rows: units.dp( 0.00 );
62 property real landscape_space_between_keys: units.dp( 0.00 );
63 property real portrait_space_between_rows: units.dp( 2.00 );
64 property real portrait_space_between_keys: units.dp( 10.00 );
65
66 property string key_background_normal: "keybg@18.png"
67 property string key_background_special: "keybg_action@18.png"
68 property string key_background_deadkey: ""
69
70 property real phone_keyboard_height_portrait: 0.365;
71 property real phone_keyboard_height_landscape: 0.50;
72
73 property real tablet_keyboard_height_portrait: 0.28;
74 property real tablet_keyboard_height_landscape: 0.38;
75
76 property int landscape_wordribbon_height: units.gu( 4.0 );
77 property int portrait_wordribbon_height: units.gu( 4.0 );
78}
79
080
=== added file 'maliit-keyboard/tests/dynamic-layout/test.cpp'
--- maliit-keyboard/tests/dynamic-layout/test.cpp 1970-01-01 00:00:00 +0000
+++ maliit-keyboard/tests/dynamic-layout/test.cpp 2013-08-09 11:00:42 +0000
@@ -0,0 +1,186 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17
18#include "plugin/inputmethod.h"
19#include "lib/models/wordribbon.h"
20#include "lib/models/styleattributes.h"
21
22#include "lib/logic/dynamiclayout.h"
23#include "lib/logic/keyboardloader.h"
24#include "lib/logic/layouthelper.h"
25#include "lib/logic/keyareaconverter.h"
26#include "lib/logic/style.h"
27
28#include "common/inputmethodhostprobe.h"
29#include "common/mockscreen.h"
30
31#include <maliit/plugins/abstractinputmethodhost.h>
32
33#include <QtTest/QtTest>
34
35using namespace MaliitKeyboard;
36using namespace MaliitKeyboard::Logic;
37
38const QRect referenceScreenGeometry(0,0,720,1280);
39
40class TestDynamicLayout: public QObject
41{
42 Q_OBJECT
43private:
44
45 void connectUiConstToScreen(const MockScreen& mockScreen)
46 {
47 const QScreen* screen = qGuiApp->primaryScreen();
48 disconnect( screen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)), uiConst, SLOT(onPrimaryOrientationChanged(Qt::ScreenOrientation)) );
49 disconnect( screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)), uiConst, SLOT(onPrimaryOrientationChanged(Qt::ScreenOrientation)) );
50 disconnect( screen, SIGNAL(geometryChanged(QRect)), uiConst, SLOT(onGeometryChanged(QRect)) );
51
52 connect( &mockScreen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)), uiConst, SLOT(onPrimaryOrientationChanged(Qt::ScreenOrientation)) );
53 connect( &mockScreen, SIGNAL(orientationChanged(Qt::ScreenOrientation)), uiConst, SLOT(onPrimaryOrientationChanged(Qt::ScreenOrientation)) );
54 connect( &mockScreen, SIGNAL(geometryChanged(QRect)), uiConst, SLOT(onGeometryChanged(QRect)) );
55 }
56
57 Q_SLOT void dynamicLayout()
58 {
59 uiConst->instance();
60 QVERIFY(uiConst);
61
62 MockScreen mockScreen;
63 connectUiConstToScreen(mockScreen);
64
65 mockScreen.setGeometry(QRect(0,0, 300,400));
66 mockScreen.setOrientation(Qt::PortraitOrientation);
67 mockScreen.setPrimaryOrientation(Qt::PortraitOrientation);
68
69 uiConst->initDynamicLayout( "maliit-keyboard/tests/dynamic-layout/test-ui-constants.qml" );
70 QCOMPARE( uiConst->windowGeometryRect(Qt::PortraitOrientation).width(), 300 );
71
72 KeyboardLoader loader;
73 loader.setActiveId("en_us"); // TODO add a test layout
74 Keyboard kb = loader.keyboard();
75
76 QVERIFY(kb.keys.size() > 0);
77 QVERIFY2(kb.keys.size() == 33, "test if en_us layout contains 33 keys");
78
79 uiConst->reset();
80 connectUiConstToScreen(mockScreen);
81
82 // this is important, so uiConst gets signals and changes internally
83 mockScreen.setGeometry( referenceScreenGeometry );
84 mockScreen.setOrientation(Qt::PortraitOrientation);
85 mockScreen.setPrimaryOrientation(Qt::PortraitOrientation);
86
87 uiConst->initDynamicLayout( "maliit-keyboard/tests/dynamic-layout/test-ui-constants.qml" );
88
89 QCOMPARE( uiConst->windowGeometryRect(Qt::PortraitOrientation).width(), 720 );
90
91 // this should remain the same even if we rotate the screen, as we depend on contentOrientation
92 mockScreen.setOrientation(Qt::LandscapeOrientation);
93 QCOMPARE( uiConst->windowGeometryRect(Qt::PortraitOrientation).width(), 720 );
94
95 // virtual width depending on contentOrientation
96 QCOMPARE( uiConst->windowWidth(LayoutHelper::Portrait), 720 );
97 QCOMPARE( uiConst->windowWidth(LayoutHelper::Landscape), 1280 );
98
99 // not sure if we need this in future
100 QVector<int> margins = uiConst->calculateMargins(LayoutHelper::Portrait, kb);
101 QVERIFY( margins[0] > 0 );
102
103 // TODO orientation argument not needed, qreal not needed
104 QCOMPARE( uiConst->keyWidth(LayoutHelper::Portrait, KeyDescription::Small), 10.0 );
105 QCOMPARE( uiConst->keyWidth(LayoutHelper::Portrait, KeyDescription::Medium), 12.0 );
106 QCOMPARE( uiConst->keyWidth(LayoutHelper::Portrait, KeyDescription::Large), 15.0 );
107 QCOMPARE( uiConst->keyWidth(LayoutHelper::Portrait, KeyDescription::XLarge), 18.0 );
108 QCOMPARE( uiConst->keyWidth(LayoutHelper::Portrait, KeyDescription::XXLarge), 24.0 );
109 QCOMPARE( uiConst->keyWidth(LayoutHelper::Portrait, KeyDescription::Stretched), 30.0 );
110
111 // keyHeight() not tested, calculated
112
113 QCOMPARE( uiConst->fontSize(LayoutHelper::Portrait), 12.0 );
114 QCOMPARE( uiConst->fontSizeSmall(LayoutHelper::Portrait), 10.0 );
115 }
116
117 /*
118 * Area
119 * size QSize
120 * background QByteArray
121 * backgroundBorders QMargins
122 *
123 * Key
124 * origin QPoint
125 * area Area
126 * label Label
127 * action Action
128 * style Key::Style (normal, special, dead)
129 * margins QMargins
130 * icon QByteArray
131 * has_extended_keys bool
132 * flags_padding int
133 * command_sequence QString
134 *
135 * Label
136 * text QString
137 * font Font
138 * rect QRect
139 *
140 * Font
141 * name QByteArray
142 * size int
143 * color QByteArray
144 * stretch int
145 *
146 * KeyDescription
147 * row int
148 * flags: left|right spacer, rtl-icon
149 * width KeyDescription::Width (Small, Medium, ...)
150 * icon KeyDescription::Icon (no, return, backspace, shift, ...)
151 * font_group KeyDescription::FontGroup (normal, big)
152 *
153 * Keyboard
154 * style name QString
155 * keys vector of Key
156 * descriptions vector of KeyDescription
157 *
158 * KeyArea
159 * keys vector of Keys
160 * origin QPoint
161 * area Area
162 * margin qreal
163 **/
164
165
166 Q_SLOT void keyAreaConverter()
167 {
168 KeyboardLoader loader;
169 loader.setActiveId("en_us");
170
171 // this really seems overkill
172 Style* style = new Style;
173 style->setProfile("ubuntu");
174
175 KeyAreaConverter converter(style->attributes(), &loader);
176 converter.setLayoutOrientation(MaliitKeyboard::Logic::LayoutHelper::Portrait);
177
178 KeyArea area = converter.keyArea();
179
180 QVERIFY2( area.keys().size() == 33, "Make sure all keys are in keyarea" );
181 }
182};
183
184
185QTEST_MAIN(TestDynamicLayout)
186#include "test.moc"
0187
=== modified file 'maliit-keyboard/tests/tests.pro'
--- maliit-keyboard/tests/tests.pro 2013-08-06 19:58:25 +0000
+++ maliit-keyboard/tests/tests.pro 2013-08-09 11:00:42 +0000
@@ -10,6 +10,7 @@
10 qml-test-app \10 qml-test-app \
11 qml-api-tests \11 qml-api-tests \
12 wordengine \12 wordengine \
13 dynamic-layout \
1314
14CONFIG += ordered15CONFIG += ordered
15QMAKE_EXTRA_TARGETS += check16QMAKE_EXTRA_TARGETS += check
1617
=== modified file 'unittests.sh'
--- unittests.sh 2013-08-06 19:58:25 +0000
+++ unittests.sh 2013-08-09 11:00:42 +0000
@@ -9,3 +9,4 @@
9qmltestrunner -import maliit-keyboard/tests/qml-api-tests/imports/ -input maliit-keyboard/tests/qml-api-tests/tst_inputMethodHints.qml9qmltestrunner -import maliit-keyboard/tests/qml-api-tests/imports/ -input maliit-keyboard/tests/qml-api-tests/tst_inputMethodHints.qml
1010
1111
12

Subscribers

People subscribed via source and target branches