Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/orientationManual into lp:ubuntu-ui-toolkit/staging

Proposed by Christian Dywan on 2015-03-09
Status: Superseded
Proposed branch: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/orientationManual
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 535 lines (+210/-37)
15 files modified
examples/ubuntu-ui-toolkit-gallery/po/es.po (+7/-7)
modules/Ubuntu/Components/MainViewBase.qml (+14/-0)
modules/Ubuntu/Components/OrientationHelper.qml (+6/-10)
modules/Ubuntu/Components/Popups/PopupBase.qml (+0/-5)
modules/Ubuntu/Components/TextCursor.qml (+6/-1)
modules/Ubuntu/Components/plugin/plugin.cpp (+0/-7)
modules/Ubuntu/Components/plugin/ucapplication.cpp (+39/-1)
modules/Ubuntu/Components/plugin/ucapplication.h (+5/-0)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_mainview.py (+13/-0)
tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.py (+34/-0)
tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.qml (+52/-4)
tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.py (+20/-0)
tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textarea.qml (+2/-0)
tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield.qml (+10/-2)
tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield_custom.qml (+2/-0)
To merge this branch: bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/orientationManual
Reviewer Review Type Date Requested Status
Ubuntu SDK team 2015-03-09 Pending
Review via email: mp+252270@code.launchpad.net

This proposal has been superseded by a proposal from 2015-03-31.

Commit Message

Allow manual orientation changes through OrientationHelper.orientation

Description of the Change

Autopilot tests for orientation issues in both text input and popovers/ dialogs:
env APP_ID=uitl LANGUAGE=en ./run_tests.sh ubuntuuitoolkit.tests.components.test_textinput.InsertModeTextInputTestCase.test_rotate_portrait -v
env APP_ID=uitl LANGUAGE=en ./run_tests.sh ubuntuuitoolkit.tests.components.test_popover.PopoverOpenTestCase.test_popover_rotate_portrait -v

To post a comment you must log in.
1167. By Launchpad Translations on behalf of ubuntu-sdk-team on 2015-03-14

Launchpad automatic translations update.

1168. By Timo Jyrinki on 2015-03-18

No-change rebuild against Qt 5.4.1.

1169. By Florian Boucault on 2015-03-18

Bugfixes for the fresh 1.2 UITK

1170. By CI Train Bot Account on 2015-03-18

Releasing 1.2.1450+15.04.20150318-0ubuntu1

1171. By Launchpad Translations on behalf of ubuntu-sdk-team on 2015-03-22

Launchpad automatic translations update.

1172. By Leo Arias on 2015-03-27

The very last bugfix landing for Vivid

1173. By CI Train Bot Account on 2015-03-27

Releasing 1.2.1458+15.04.20150327-0ubuntu1

1174. By Launchpad Translations on behalf of ubuntu-sdk-team on 2015-03-29

Launchpad automatic translations update.

1175. By Daniel d'Andrada on 2015-03-30

merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/orientationManual

1176. By Daniel d'Andrada on 2015-03-30

fix code and improve fake orientation logic

1177. By Christian Dywan on 2015-04-02

Add automaticOrientation to textinput AP tests and check rotation instead of rotationAngle

1178. By Christian Dywan on 2015-04-02

Fix erroneous changes from branch merge

1179. By Christian Dywan on 2015-04-02

Set rotation on PopupBase directly with no transition

1180. By Christian Dywan on 2015-04-02

Fix components.api

1181. By Christian Dywan on 2015-04-02

Revise AP tests for consistency and comments for clarity

1182. By Christian Dywan on 2015-04-02

Wait for OrientationHelper to finnish animating

1183. By Christian Dywan on 2015-04-02

Verify that orientation really was changed

1184. By Christian Dywan on 2015-04-13

Split up orientation test functions and use lower case

1185. By Christian Dywan on 2015-04-13

Split up orientation test functions and use lower case

1186. By Christian Dywan on 2015-04-13

Use parent OrientationHelper as fakeCursor parent

1187. By Christian Dywan on 2015-04-13

Use objectName to select OrientationHelper in MainView CPO

1188. By Christian Dywan on 2015-04-13

Correctly use hasOwnProperty to check for automaticOrientation

1189. By Christian Dywan on 2015-04-13

Wait on internal flipDimensions after rotation

1190. By Christian Dywan on 2015-04-13

Drop now redundant wait on rotating

1191. By Christian Dywan on 2015-04-13

Fix nonsensical typo fix so it says FOLLOW_SCREEN_ORIENTATION as intended

1192. By Christian Dywan on 2015-04-14

Add license header to test_main_view.orientation.qml

1193. By Christian Dywan on 2015-04-15

Only test non-default orientation for clear results

Otherwise some properties may not change if nothing did rotate.

1194. By Christian Dywan on 2015-04-17

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

1195. By Christian Dywan on 2015-04-20

Take Component-based popover rootItem from the caller

1196. By Christian Dywan on 2015-04-20

FakeCursor parent should fallback to toplevel

1197. By Christian Dywan on 2015-04-20

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

1198. By Christian Dywan on 2015-04-20

Put back accidentally removed "import os"

1199. By Christian Dywan on 2015-05-12

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

1200. By Christian Dywan on 2015-05-13

Empty commit

1201. By Christian Dywan on 2015-05-21

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

1202. By Christian Dywan on 2015-05-21

Update components.api

1203. By Christian Dywan on 2015-05-21

Undo accidental changes

1204. By Christian Dywan on 2015-05-21

Move all orientation tests to 1.3

1205. By Christian Dywan on 2015-05-22

Revert bogus components.api changes

1206. By Christian Dywan on 2015-06-01

Normalize rotation angle in tests

1207. By Christian Dywan on 2015-06-02

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

1208. By Christian Dywan on 2015-06-02

Use Popups 1.3 in test_popover.qml

1209. By Christian Dywan on 2015-06-02

Assert focus after tapping TextField in popover tests

1210. By Christian Dywan on 2015-06-03

Anchor Column in test_textinput.textfield.qml to the top

1211. By Christian Dywan on 2015-06-05

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

1212. By Christian Dywan on 2015-06-10

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

1213. By Christian Dywan on 2015-06-11

Use Eventually and wait_ instead of time.sleep

1214. By Christian Dywan on 2015-06-11

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

1215. By Christian Dywan on 2015-06-12

Make flake8 happy once again

1216. By Christian Dywan on 2015-06-18

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

Unmerged revisions

1216. By Christian Dywan on 2015-06-18

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

1215. By Christian Dywan on 2015-06-12

Make flake8 happy once again

1214. By Christian Dywan on 2015-06-11

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

1213. By Christian Dywan on 2015-06-11

Use Eventually and wait_ instead of time.sleep

1212. By Christian Dywan on 2015-06-10

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

1211. By Christian Dywan on 2015-06-05

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

1210. By Christian Dywan on 2015-06-03

Anchor Column in test_textinput.textfield.qml to the top

1209. By Christian Dywan on 2015-06-02

Assert focus after tapping TextField in popover tests

1208. By Christian Dywan on 2015-06-02

Use Popups 1.3 in test_popover.qml

1207. By Christian Dywan on 2015-06-02

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/ubuntu-ui-toolkit-gallery/po/es.po'
2--- examples/ubuntu-ui-toolkit-gallery/po/es.po 2015-03-14 05:29:12 +0000
3+++ examples/ubuntu-ui-toolkit-gallery/po/es.po 2015-03-31 12:57:21 +0000
4@@ -8,14 +8,14 @@
5 "Project-Id-Version: ubuntu-ui-toolkit\n"
6 "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
7 "POT-Creation-Date: 2014-11-11 11:21+0100\n"
8-"PO-Revision-Date: 2015-01-16 03:32+0000\n"
9+"PO-Revision-Date: 2015-03-28 06:18+0000\n"
10 "Last-Translator: Adolfo Jayme <fitoschido@gmail.com>\n"
11 "Language-Team: Spanish <es@li.org>\n"
12 "MIME-Version: 1.0\n"
13 "Content-Type: text/plain; charset=UTF-8\n"
14 "Content-Transfer-Encoding: 8bit\n"
15-"X-Launchpad-Export-Date: 2015-03-14 05:29+0000\n"
16-"X-Generator: Launchpad (build 17389)\n"
17+"X-Launchpad-Export-Date: 2015-03-29 05:42+0000\n"
18+"X-Generator: Launchpad (build 17413)\n"
19
20 #: Animations.qml:24
21 msgid "NumberAnimation"
22@@ -349,7 +349,7 @@
23
24 #: Styles.qml:40
25 msgid "Switch between themes"
26-msgstr ""
27+msgstr "Cambiar de tema"
28
29 #: TextInputs.qml:49
30 msgid "Type me in..."
31@@ -401,12 +401,12 @@
32
33 #: UbuntuShape.qml:49
34 msgid "Image"
35-msgstr ""
36+msgstr "Imagen"
37
38 #: UbuntuShape.qml:64
39 msgid "Radius"
40-msgstr ""
41+msgstr "Radio"
42
43 #: UbuntuShape.qml:97
44 msgid "Sizes"
45-msgstr ""
46+msgstr "Tamaños"
47
48=== modified file 'modules/Ubuntu/Components/MainViewBase.qml'
49--- modules/Ubuntu/Components/MainViewBase.qml 2015-03-03 13:47:48 +0000
50+++ modules/Ubuntu/Components/MainViewBase.qml 2015-03-31 12:57:21 +0000
51@@ -56,6 +56,20 @@
52 Theme.name = "Ubuntu.Components.Themes.%1".arg(theme);
53 }
54 }
55+
56+ // Functions to allow Autopilot to handle orientation
57+ objectName: "MainViewBaseStyledItem"
58+ function setOrientation(newOrientation) {
59+ if (newOrientation == 'Landscape')
60+ UbuntuApplication.orientation = Qt.LandscapeOrientation
61+ else if (newOrientation == 'Portrait')
62+ UbuntuApplication.orientation = Qt.PortraitOrientation
63+ else
64+ UbuntuApplication.orientation = newOrientation
65+ }
66+ function getOrientation() {
67+ return UbuntuApplication.orientation
68+ }
69 }
70
71 active: true
72
73=== modified file 'modules/Ubuntu/Components/OrientationHelper.qml'
74--- modules/Ubuntu/Components/OrientationHelper.qml 2015-03-06 07:55:23 +0000
75+++ modules/Ubuntu/Components/OrientationHelper.qml 2015-03-31 12:57:21 +0000
76@@ -83,11 +83,14 @@
77
78 Calculates the current orientation angle.
79 */
80- property int orientationAngle: automaticOrientation ? Screen.angleBetween(Screen.primaryOrientation, Screen.orientation) : 0
81+ readonly property int orientationAngle: automaticOrientation
82+ ? Screen.angleBetween(Screen.primaryOrientation, UbuntuApplication.orientation)
83+ : 0
84 // Screen.primaryOrientation and Screen.orientation can change one right after the other,
85 // causing orientationAngle to momentarily change. To avoid responding to such
86 // intermediate states, wait for its value to stabilize before rotating to it.
87- onOrientationAngleChanged: { automaticOrientation ? stableOrientationAngleTimer.restart() : d.tryUpdateState(); }
88+ onOrientationAngleChanged: automaticOrientation ? stableOrientationAngleTimer.restart()
89+ : d.tryUpdateState();
90
91 /*!
92 The property holds if the OrientationHelper should automatically resize the
93@@ -102,13 +105,6 @@
94 width: parent ? (d.flipDimensions ? d.availableParentHeight : parent.width) : 0
95 height: parent ? (d.flipDimensions ? parent.width : d.availableParentHeight) : 0
96
97- /*
98- The attached property Screen.orientation is only valid inside Item or
99- derived components. Inside Object it evaluates to 0 with no error.
100- Also be aware that some apps eg. webbrowser-app set window.contentOrientation
101- and thus can hide failure to update it from this code.
102- See http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick-window2-screen.html
103- */
104 Item {
105 id: d
106
107@@ -138,7 +134,7 @@
108 */
109 function applyOrientation() {
110 if (windowActive && window)
111- window.contentOrientation = Screen.orientation
112+ window.contentOrientation = UbuntuApplication.orientation
113 }
114
115 onWindowActiveChanged: {
116
117=== modified file 'modules/Ubuntu/Components/Popups/PopupBase.qml'
118--- modules/Ubuntu/Components/Popups/PopupBase.qml 2015-03-03 13:47:48 +0000
119+++ modules/Ubuntu/Components/Popups/PopupBase.qml 2015-03-31 12:57:21 +0000
120@@ -47,11 +47,6 @@
121 */
122 property PropertyAnimation fadingAnimation: PropertyAnimation{duration: 0}
123
124- // without specifying width and height below, some width calculations go wrong in Sheet.
125- // I guess popupBase.width is not correctly set initially
126- width: parent ? parent.width : undefined
127- height: parent ? parent.height : undefined
128-
129 // copy value of automaticOrientation from root object (typically a MainView)
130 automaticOrientation: stateWrapper.rootItem && stateWrapper.rootItem.automaticOrientation ?
131 stateWrapper.rootItem.automaticOrientation : false
132
133=== modified file 'modules/Ubuntu/Components/TextCursor.qml'
134--- modules/Ubuntu/Components/TextCursor.qml 2015-03-18 15:51:07 +0000
135+++ modules/Ubuntu/Components/TextCursor.qml 2015-03-31 12:57:21 +0000
136@@ -293,7 +293,12 @@
137 Item {
138 id: fakeCursor
139 objectName: positionProperty + "FakeCursor"
140- parent: QuickUtils.rootItem(handler.main)
141+ // Parent to the contentsItem to be able to inherit rotation
142+ parent: {
143+ var mainView = QuickUtils.rootItem(handler.main);
144+ // Check in case the root isn't a MainView
145+ return mainView.contentsItem ? mainView.contentsItem[0] : mainView;
146+ }
147 width: cursorItem.width
148 height: cursorItem.height
149 Component.onCompleted: caret.parent = fakeCursor
150
151=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
152--- modules/Ubuntu/Components/plugin/plugin.cpp 2015-03-04 19:07:58 +0000
153+++ modules/Ubuntu/Components/plugin/plugin.cpp 2015-03-31 12:57:21 +0000
154@@ -244,12 +244,5 @@
155 // register icon provider
156 engine->addImageProvider(QLatin1String("theme"), new UnityThemeIconProvider);
157
158- // Necessary for Screen.orientation (from import QtQuick.Window 2.0) to work
159- QGuiApplication::primaryScreen()->setOrientationUpdateMask(
160- Qt::PortraitOrientation |
161- Qt::LandscapeOrientation |
162- Qt::InvertedPortraitOrientation |
163- Qt::InvertedLandscapeOrientation);
164-
165 registerWindowContextProperty();
166 }
167
168=== modified file 'modules/Ubuntu/Components/plugin/ucapplication.cpp'
169--- modules/Ubuntu/Components/plugin/ucapplication.cpp 2014-10-02 10:14:51 +0000
170+++ modules/Ubuntu/Components/plugin/ucapplication.cpp 2015-03-31 12:57:21 +0000
171@@ -19,10 +19,13 @@
172 #include "ucapplication.h"
173
174 #include <QtCore/QCoreApplication>
175+#include <QtGui/QGuiApplication>
176+#include <QWindow>
177 #include <QDebug>
178 #include <QtQml/QQmlContext>
179 #include <QtQml/QQmlEngine>
180 #include <QtCore/QStandardPaths>
181+#include <QScreen>
182
183 /*!
184 * \qmltype UbuntuApplication
185@@ -33,11 +36,20 @@
186 *
187 * UbuntuApplication is a context property in QML.
188 */
189-UCApplication::UCApplication(QObject* parent) : QObject(parent), m_context(0)
190+UCApplication::UCApplication(QObject* parent) : QObject(parent), m_context(0), m_orientation(-1)
191 {
192 // Make sure we receive application name changes from C++ modules
193 connect(QCoreApplication::instance(), &QCoreApplication::applicationNameChanged,
194 this, &UCApplication::applicationNameChanged);
195+
196+ // Follow primary screen orientation changes
197+ QGuiApplication::primaryScreen()->setOrientationUpdateMask(
198+ Qt::PortraitOrientation |
199+ Qt::LandscapeOrientation |
200+ Qt::InvertedPortraitOrientation |
201+ Qt::InvertedLandscapeOrientation);
202+ connect(QGuiApplication::primaryScreen(), &QScreen::orientationChanged,
203+ this, &UCApplication::orientationChanged);
204 }
205
206 void UCApplication::setContext(QQmlContext* context) {
207@@ -73,3 +85,29 @@
208 QCoreApplication::setOrganizationDomain(applicationName);
209 }
210
211+/*!
212+ * \qmlproperty Qt.ScreenOrientation Application::orientation
213+ * \internal
214+ * The current orientation of the application - can be overridden manually for testing.
215+ */
216+Qt::ScreenOrientation UCApplication::orientation() {
217+ if (m_orientation == -1) {
218+ return QGuiApplication::primaryScreen()->orientation();
219+ } else {
220+ return static_cast<Qt::ScreenOrientation>(m_orientation);
221+ }
222+}
223+
224+void UCApplication::setOrientation(Qt::ScreenOrientation orientation) {
225+ if (m_orientation == -1) {
226+ // we're now in manual override mode
227+ disconnect(QGuiApplication::primaryScreen(), &QScreen::orientationChanged,
228+ this, &UCApplication::orientationChanged);
229+ }
230+
231+ if (m_orientation != orientation) {
232+ m_orientation = orientation;
233+ Q_EMIT orientationChanged(orientation);
234+ }
235+}
236+
237
238=== modified file 'modules/Ubuntu/Components/plugin/ucapplication.h'
239--- modules/Ubuntu/Components/plugin/ucapplication.h 2013-10-18 08:56:39 +0000
240+++ modules/Ubuntu/Components/plugin/ucapplication.h 2015-03-31 12:57:21 +0000
241@@ -28,6 +28,7 @@
242 {
243 Q_OBJECT
244 Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName NOTIFY applicationNameChanged)
245+ Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
246
247 private:
248 Q_DISABLE_COPY(UCApplication)
249@@ -42,16 +43,20 @@
250
251 // getter
252 QString applicationName();
253+ Qt::ScreenOrientation orientation();
254
255 // setter
256 void setContext(QQmlContext* context);
257 void setApplicationName(const QString& applicationName);
258+ void setOrientation(Qt::ScreenOrientation orientation);
259
260 private:
261 QQmlContext* m_context;
262+ int m_orientation;
263
264 Q_SIGNALS:
265 void applicationNameChanged();
266+ void orientationChanged(Qt::ScreenOrientation orientation);
267 };
268
269 #endif // UBUNTU_COMPONENTS_I18N_H
270
271=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_mainview.py'
272--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_mainview.py 2015-02-11 23:37:40 +0000
273+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_mainview.py 2015-03-31 12:57:21 +0000
274@@ -17,6 +17,7 @@
275 """Ubuntu UI Toolkit Autopilot custom proxy objects."""
276
277 import logging
278+import time
279
280 from autopilot import logging as autopilot_logging
281 from autopilot.introspection import dbus
282@@ -56,6 +57,18 @@
283
284 return False
285
286+ def _set_orientation(self, orientation):
287+ self.select_single(
288+ objectName='MainViewBaseStyledItem').slots.setOrientation(
289+ orientation)
290+ # Short delay to ensure introspection is uptodate
291+ time.sleep(1)
292+
293+ @property
294+ def _orientation(self):
295+ return self.select_single(
296+ objectName='MainViewBaseStyledItem').orientation
297+
298 def get_header(self):
299 """Return the AppHeader custom proxy object of the MainView."""
300 try:
301
302=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.py'
303--- tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.py 2014-10-06 10:44:31 +0000
304+++ tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.py 2015-03-31 12:57:21 +0000
305@@ -17,10 +17,44 @@
306 """Tests for the Ubuntu UI Toolkit Header component."""
307
308 import os
309+import time
310
311 from ubuntuuitoolkit import tests
312
313
314+class PopoverOpenTestCase(tests.QMLFileAppTestCase):
315+
316+ path = os.path.abspath(__file__)
317+ dir_path = os.path.dirname(path)
318+ test_qml_file_path = os.path.join(
319+ dir_path, 'test_popover.qml')
320+
321+ scenarios = [
322+ ('Popover', dict(button='button', popover='popover')),
323+ ('Small dialog', dict(button='button_small', popover='dialog_small')),
324+ ('Huge dialog', dict(button='button_huge', popover='dialog_huge')),
325+ ]
326+
327+ def setUp(self):
328+ super(PopoverOpenTestCase, self).setUp()
329+
330+ def _rotate(self, orientation):
331+ self.main_view._set_orientation(orientation)
332+ button = self.main_view.select_single(objectName=self.button)
333+ self.pointing_device.click_object(button)
334+ # Give rendering a chance to finish
335+ time.sleep(2)
336+ popover = self.main_view.select_single(objectName=self.popover)
337+ self.assertEqual(popover.rotationAngle, self.main_view.select_single(
338+ 'OrientationHelper').rotation)
339+
340+ def test_popover_rotate_landscape(self):
341+ self._rotate('Landscape')
342+
343+ def test_popover_rotate_portrait(self):
344+ self._rotate('Portrait')
345+
346+
347 class DialogScrollTestCase(tests.QMLFileAppTestCase):
348
349 path = os.path.abspath(__file__)
350
351=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.qml'
352--- tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.qml 2015-03-03 13:20:06 +0000
353+++ tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.qml 2015-03-31 12:57:21 +0000
354@@ -15,19 +15,28 @@
355 */
356
357 import QtQuick 2.0
358-import Ubuntu.Components 1.1
359+import Ubuntu.Components 1.2
360 import Ubuntu.Components.Popups 1.0
361+import Ubuntu.Test 1.0
362
363 MainView {
364- width: units.gu(48)
365- height: units.gu(60)
366+ id: root
367+ width: units.gu(60)
368+ height: units.gu(40)
369 objectName: "mainView"
370
371+ automaticOrientation: true
372+
373 Page {
374 title: "Popover"
375
376 Column {
377 Button {
378+ objectName: "button"
379+ text: "Pop over"
380+ onClicked: PopupUtils.open(popoverComponent)
381+ }
382+ Button {
383 objectName: "button_small"
384 text: "Small"
385 onClicked: PopupUtils.open(smallDialogComponent)
386@@ -37,15 +46,54 @@
387 text: "Huge"
388 onClicked: PopupUtils.open(hugeDialogComponent)
389 }
390+ Button {
391+ text: "Landscape"
392+ onClicked: UbuntuApplication.orientation = Qt.LandscapeOrientation;
393+ }
394+ Button {
395+ text: "Portrait"
396+ onClicked: UbuntuApplication.orientation = Qt.PortraitOrientation;
397+ }
398+ }
399+
400+ Component {
401+ id: popoverComponent
402+ Popover {
403+ objectName: "popover"
404+ Column {
405+ Button {
406+ text: "Just a button"
407+ onClicked: {
408+ if (UbuntuApplication.orientation === Qt.LandscapeOrientation) {
409+ UbuntuApplication.orientation = Qt.PortraitOrientation;
410+ } else {
411+ UbuntuApplication.orientation = Qt.LandscapeOrientation
412+ }
413+ }
414+ }
415+ }
416+ }
417 }
418
419 Component {
420 id: smallDialogComponent
421 Dialog {
422+ id: smallDialog
423 objectName: "dialog_small"
424- Column {
425+ Row {
426 Button {
427 text: "Just a button"
428+ onClicked: {
429+ if (UbuntuApplication.orientation === Qt.LandscapeOrientation) {
430+ UbuntuApplication.orientation = Qt.PortraitOrientation;
431+ } else {
432+ UbuntuApplication.orientation = Qt.LandscapeOrientation
433+ }
434+ }
435+ }
436+ Button {
437+ text: "close"
438+ onClicked: PopupUtils.close(smallDialog)
439 }
440 }
441 }
442
443=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.py'
444--- tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.py 2015-03-16 10:01:09 +0000
445+++ tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.py 2015-03-31 12:57:21 +0000
446@@ -166,6 +166,26 @@
447 self.assertTrue(popover.globalRect.y > 0,
448 '%s <= 0' % popover.globalRect.y)
449
450+ def _rotate(self, orientation):
451+ if self.test_qml_file_path != self.textfield_qml_file_path:
452+ self.skipTest('FIXME: Header behavior breaks some rotation cases')
453+ self.main_view._set_orientation(orientation)
454+ self.pointing_device.click_object(self.textfield)
455+ cursor = self.select_cursor('cursorPosition')
456+ self.pointing_device.click_object(cursor)
457+ # Give rendering a chance to finish
458+ sleep(2)
459+ popover = self.main_view.get_text_input_context_menu(
460+ 'text_input_contextmenu')
461+ self.assertEqual(popover.rotation, self.main_view.select_single(
462+ 'OrientationHelper').rotation)
463+
464+ def test_rotate_landscape(self):
465+ self._rotate('Landscape')
466+
467+ def test_rotate_portrait(self):
468+ self._rotate('Portrait')
469+
470 def test_header_undisturbed_by_text_handlers(self):
471 # Verify that handlers aren't accidentally placed at absolute 0/0
472 self.pointing_device.click_object(self.textfield)
473
474=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textarea.qml'
475--- tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textarea.qml 2015-03-10 16:29:24 +0000
476+++ tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textarea.qml 2015-03-31 12:57:21 +0000
477@@ -22,6 +22,8 @@
478 height: units.gu(60)
479 objectName: "mainView"
480
481+ automaticOrientation: true
482+
483 Page {
484 title: "Textarea"
485 head.backAction: Action {
486
487=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield.qml'
488--- tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield.qml 2015-03-10 16:29:24 +0000
489+++ tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield.qml 2015-03-31 12:57:21 +0000
490@@ -18,10 +18,12 @@
491 import Ubuntu.Components 1.2
492
493 MainView {
494- width: units.gu(48)
495- height: units.gu(60)
496+ width: units.gu(60)
497+ height: units.gu(40)
498 objectName: "mainView"
499
500+ automaticOrientation: true
501+
502 Page {
503 title: "Textfield"
504 head.backAction: Action {
505@@ -31,11 +33,17 @@
506 }
507
508 Column {
509+ anchors.bottom: parent.bottom
510+ spacing: units.gu(2)
511+
512 TextField {
513 objectName: "textfield"
514 placeholderText: "Type here"
515 width: units.gu(35)
516 }
517+ Label {
518+ text: i18n.tr("Text fields are awesome")
519+ }
520 }
521 }
522 }
523
524=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield_custom.qml'
525--- tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield_custom.qml 2015-03-10 16:29:24 +0000
526+++ tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield_custom.qml 2015-03-31 12:57:21 +0000
527@@ -23,6 +23,8 @@
528 height: units.gu(60)
529 objectName: "mainView"
530
531+ automaticOrientation: true
532+
533 Page {
534 title: "Textfield"
535 head.backAction: Action {

Subscribers

People subscribed via source and target branches