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

Proposed by Cris Dywan
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 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

Launchpad automatic translations update.

1168. By Timo Jyrinki

No-change rebuild against Qt 5.4.1.

1169. By Florian Boucault

Bugfixes for the fresh 1.2 UITK

1170. By CI Train Bot Account

Releasing 1.2.1450+15.04.20150318-0ubuntu1

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

Launchpad automatic translations update.

1172. By Leo Arias

The very last bugfix landing for Vivid

1173. By CI Train Bot Account

Releasing 1.2.1458+15.04.20150327-0ubuntu1

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

Launchpad automatic translations update.

1175. By Daniel d'Andrada

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

1176. By Daniel d'Andrada

fix code and improve fake orientation logic

1177. By Cris Dywan

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

1178. By Cris Dywan

Fix erroneous changes from branch merge

1179. By Cris Dywan

Set rotation on PopupBase directly with no transition

1180. By Cris Dywan

Fix components.api

1181. By Cris Dywan

Revise AP tests for consistency and comments for clarity

1182. By Cris Dywan

Wait for OrientationHelper to finnish animating

1183. By Cris Dywan

Verify that orientation really was changed

1184. By Cris Dywan

Split up orientation test functions and use lower case

1185. By Cris Dywan

Split up orientation test functions and use lower case

1186. By Cris Dywan

Use parent OrientationHelper as fakeCursor parent

1187. By Cris Dywan

Use objectName to select OrientationHelper in MainView CPO

1188. By Cris Dywan

Correctly use hasOwnProperty to check for automaticOrientation

1189. By Cris Dywan

Wait on internal flipDimensions after rotation

1190. By Cris Dywan

Drop now redundant wait on rotating

1191. By Cris Dywan

Fix nonsensical typo fix so it says FOLLOW_SCREEN_ORIENTATION as intended

1192. By Cris Dywan

Add license header to test_main_view.orientation.qml

1193. By Cris Dywan

Only test non-default orientation for clear results

Otherwise some properties may not change if nothing did rotate.

1194. By Cris Dywan

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

1195. By Cris Dywan

Take Component-based popover rootItem from the caller

1196. By Cris Dywan

FakeCursor parent should fallback to toplevel

1197. By Cris Dywan

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

1198. By Cris Dywan

Put back accidentally removed "import os"

1199. By Cris Dywan

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

1200. By Cris Dywan

Empty commit

1201. By Cris Dywan

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

1202. By Cris Dywan

Update components.api

1203. By Cris Dywan

Undo accidental changes

1204. By Cris Dywan

Move all orientation tests to 1.3

1205. By Cris Dywan

Revert bogus components.api changes

1206. By Cris Dywan

Normalize rotation angle in tests

1207. By Cris Dywan

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

1208. By Cris Dywan

Use Popups 1.3 in test_popover.qml

1209. By Cris Dywan

Assert focus after tapping TextField in popover tests

1210. By Cris Dywan

Anchor Column in test_textinput.textfield.qml to the top

1211. By Cris Dywan

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

1212. By Cris Dywan

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

1213. By Cris Dywan

Use Eventually and wait_ instead of time.sleep

1214. By Cris Dywan

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

1215. By Cris Dywan

Make flake8 happy once again

1216. By Cris Dywan

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

Unmerged revisions

1216. By Cris Dywan

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

1215. By Cris Dywan

Make flake8 happy once again

1214. By Cris Dywan

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

1213. By Cris Dywan

Use Eventually and wait_ instead of time.sleep

1212. By Cris Dywan

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

1211. By Cris Dywan

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

1210. By Cris Dywan

Anchor Column in test_textinput.textfield.qml to the top

1209. By Cris Dywan

Assert focus after tapping TextField in popover tests

1208. By Cris Dywan

Use Popups 1.3 in test_popover.qml

1207. By Cris Dywan

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
=== modified file 'examples/ubuntu-ui-toolkit-gallery/po/es.po'
--- examples/ubuntu-ui-toolkit-gallery/po/es.po 2015-03-14 05:29:12 +0000
+++ examples/ubuntu-ui-toolkit-gallery/po/es.po 2015-03-31 12:57:21 +0000
@@ -8,14 +8,14 @@
8"Project-Id-Version: ubuntu-ui-toolkit\n"8"Project-Id-Version: ubuntu-ui-toolkit\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2014-11-11 11:21+0100\n"10"POT-Creation-Date: 2014-11-11 11:21+0100\n"
11"PO-Revision-Date: 2015-01-16 03:32+0000\n"11"PO-Revision-Date: 2015-03-28 06:18+0000\n"
12"Last-Translator: Adolfo Jayme <fitoschido@gmail.com>\n"12"Last-Translator: Adolfo Jayme <fitoschido@gmail.com>\n"
13"Language-Team: Spanish <es@li.org>\n"13"Language-Team: Spanish <es@li.org>\n"
14"MIME-Version: 1.0\n"14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"16"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2015-03-14 05:29+0000\n"17"X-Launchpad-Export-Date: 2015-03-29 05:42+0000\n"
18"X-Generator: Launchpad (build 17389)\n"18"X-Generator: Launchpad (build 17413)\n"
1919
20#: Animations.qml:2420#: Animations.qml:24
21msgid "NumberAnimation"21msgid "NumberAnimation"
@@ -349,7 +349,7 @@
349349
350#: Styles.qml:40350#: Styles.qml:40
351msgid "Switch between themes"351msgid "Switch between themes"
352msgstr ""352msgstr "Cambiar de tema"
353353
354#: TextInputs.qml:49354#: TextInputs.qml:49
355msgid "Type me in..."355msgid "Type me in..."
@@ -401,12 +401,12 @@
401401
402#: UbuntuShape.qml:49402#: UbuntuShape.qml:49
403msgid "Image"403msgid "Image"
404msgstr ""404msgstr "Imagen"
405405
406#: UbuntuShape.qml:64406#: UbuntuShape.qml:64
407msgid "Radius"407msgid "Radius"
408msgstr ""408msgstr "Radio"
409409
410#: UbuntuShape.qml:97410#: UbuntuShape.qml:97
411msgid "Sizes"411msgid "Sizes"
412msgstr ""412msgstr "Tamaños"
413413
=== modified file 'modules/Ubuntu/Components/MainViewBase.qml'
--- modules/Ubuntu/Components/MainViewBase.qml 2015-03-03 13:47:48 +0000
+++ modules/Ubuntu/Components/MainViewBase.qml 2015-03-31 12:57:21 +0000
@@ -56,6 +56,20 @@
56 Theme.name = "Ubuntu.Components.Themes.%1".arg(theme);56 Theme.name = "Ubuntu.Components.Themes.%1".arg(theme);
57 }57 }
58 }58 }
59
60 // Functions to allow Autopilot to handle orientation
61 objectName: "MainViewBaseStyledItem"
62 function setOrientation(newOrientation) {
63 if (newOrientation == 'Landscape')
64 UbuntuApplication.orientation = Qt.LandscapeOrientation
65 else if (newOrientation == 'Portrait')
66 UbuntuApplication.orientation = Qt.PortraitOrientation
67 else
68 UbuntuApplication.orientation = newOrientation
69 }
70 function getOrientation() {
71 return UbuntuApplication.orientation
72 }
59 }73 }
6074
61 active: true75 active: true
6276
=== modified file 'modules/Ubuntu/Components/OrientationHelper.qml'
--- modules/Ubuntu/Components/OrientationHelper.qml 2015-03-06 07:55:23 +0000
+++ modules/Ubuntu/Components/OrientationHelper.qml 2015-03-31 12:57:21 +0000
@@ -83,11 +83,14 @@
8383
84 Calculates the current orientation angle.84 Calculates the current orientation angle.
85 */85 */
86 property int orientationAngle: automaticOrientation ? Screen.angleBetween(Screen.primaryOrientation, Screen.orientation) : 086 readonly property int orientationAngle: automaticOrientation
87 ? Screen.angleBetween(Screen.primaryOrientation, UbuntuApplication.orientation)
88 : 0
87 // Screen.primaryOrientation and Screen.orientation can change one right after the other,89 // Screen.primaryOrientation and Screen.orientation can change one right after the other,
88 // causing orientationAngle to momentarily change. To avoid responding to such90 // causing orientationAngle to momentarily change. To avoid responding to such
89 // intermediate states, wait for its value to stabilize before rotating to it.91 // intermediate states, wait for its value to stabilize before rotating to it.
90 onOrientationAngleChanged: { automaticOrientation ? stableOrientationAngleTimer.restart() : d.tryUpdateState(); }92 onOrientationAngleChanged: automaticOrientation ? stableOrientationAngleTimer.restart()
93 : d.tryUpdateState();
9194
92 /*!95 /*!
93 The property holds if the OrientationHelper should automatically resize the96 The property holds if the OrientationHelper should automatically resize the
@@ -102,13 +105,6 @@
102 width: parent ? (d.flipDimensions ? d.availableParentHeight : parent.width) : 0105 width: parent ? (d.flipDimensions ? d.availableParentHeight : parent.width) : 0
103 height: parent ? (d.flipDimensions ? parent.width : d.availableParentHeight) : 0106 height: parent ? (d.flipDimensions ? parent.width : d.availableParentHeight) : 0
104107
105 /*
106 The attached property Screen.orientation is only valid inside Item or
107 derived components. Inside Object it evaluates to 0 with no error.
108 Also be aware that some apps eg. webbrowser-app set window.contentOrientation
109 and thus can hide failure to update it from this code.
110 See http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick-window2-screen.html
111 */
112 Item {108 Item {
113 id: d109 id: d
114110
@@ -138,7 +134,7 @@
138 */134 */
139 function applyOrientation() {135 function applyOrientation() {
140 if (windowActive && window)136 if (windowActive && window)
141 window.contentOrientation = Screen.orientation137 window.contentOrientation = UbuntuApplication.orientation
142 }138 }
143139
144 onWindowActiveChanged: {140 onWindowActiveChanged: {
145141
=== modified file 'modules/Ubuntu/Components/Popups/PopupBase.qml'
--- modules/Ubuntu/Components/Popups/PopupBase.qml 2015-03-03 13:47:48 +0000
+++ modules/Ubuntu/Components/Popups/PopupBase.qml 2015-03-31 12:57:21 +0000
@@ -47,11 +47,6 @@
47 */47 */
48 property PropertyAnimation fadingAnimation: PropertyAnimation{duration: 0}48 property PropertyAnimation fadingAnimation: PropertyAnimation{duration: 0}
4949
50 // without specifying width and height below, some width calculations go wrong in Sheet.
51 // I guess popupBase.width is not correctly set initially
52 width: parent ? parent.width : undefined
53 height: parent ? parent.height : undefined
54
55 // copy value of automaticOrientation from root object (typically a MainView)50 // copy value of automaticOrientation from root object (typically a MainView)
56 automaticOrientation: stateWrapper.rootItem && stateWrapper.rootItem.automaticOrientation ?51 automaticOrientation: stateWrapper.rootItem && stateWrapper.rootItem.automaticOrientation ?
57 stateWrapper.rootItem.automaticOrientation : false52 stateWrapper.rootItem.automaticOrientation : false
5853
=== modified file 'modules/Ubuntu/Components/TextCursor.qml'
--- modules/Ubuntu/Components/TextCursor.qml 2015-03-18 15:51:07 +0000
+++ modules/Ubuntu/Components/TextCursor.qml 2015-03-31 12:57:21 +0000
@@ -293,7 +293,12 @@
293 Item {293 Item {
294 id: fakeCursor294 id: fakeCursor
295 objectName: positionProperty + "FakeCursor"295 objectName: positionProperty + "FakeCursor"
296 parent: QuickUtils.rootItem(handler.main)296 // Parent to the contentsItem to be able to inherit rotation
297 parent: {
298 var mainView = QuickUtils.rootItem(handler.main);
299 // Check in case the root isn't a MainView
300 return mainView.contentsItem ? mainView.contentsItem[0] : mainView;
301 }
297 width: cursorItem.width302 width: cursorItem.width
298 height: cursorItem.height303 height: cursorItem.height
299 Component.onCompleted: caret.parent = fakeCursor304 Component.onCompleted: caret.parent = fakeCursor
300305
=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
--- modules/Ubuntu/Components/plugin/plugin.cpp 2015-03-04 19:07:58 +0000
+++ modules/Ubuntu/Components/plugin/plugin.cpp 2015-03-31 12:57:21 +0000
@@ -244,12 +244,5 @@
244 // register icon provider244 // register icon provider
245 engine->addImageProvider(QLatin1String("theme"), new UnityThemeIconProvider);245 engine->addImageProvider(QLatin1String("theme"), new UnityThemeIconProvider);
246246
247 // Necessary for Screen.orientation (from import QtQuick.Window 2.0) to work
248 QGuiApplication::primaryScreen()->setOrientationUpdateMask(
249 Qt::PortraitOrientation |
250 Qt::LandscapeOrientation |
251 Qt::InvertedPortraitOrientation |
252 Qt::InvertedLandscapeOrientation);
253
254 registerWindowContextProperty();247 registerWindowContextProperty();
255}248}
256249
=== modified file 'modules/Ubuntu/Components/plugin/ucapplication.cpp'
--- modules/Ubuntu/Components/plugin/ucapplication.cpp 2014-10-02 10:14:51 +0000
+++ modules/Ubuntu/Components/plugin/ucapplication.cpp 2015-03-31 12:57:21 +0000
@@ -19,10 +19,13 @@
19#include "ucapplication.h"19#include "ucapplication.h"
2020
21#include <QtCore/QCoreApplication>21#include <QtCore/QCoreApplication>
22#include <QtGui/QGuiApplication>
23#include <QWindow>
22#include <QDebug>24#include <QDebug>
23#include <QtQml/QQmlContext>25#include <QtQml/QQmlContext>
24#include <QtQml/QQmlEngine>26#include <QtQml/QQmlEngine>
25#include <QtCore/QStandardPaths>27#include <QtCore/QStandardPaths>
28#include <QScreen>
2629
27/*!30/*!
28 * \qmltype UbuntuApplication31 * \qmltype UbuntuApplication
@@ -33,11 +36,20 @@
33 *36 *
34 * UbuntuApplication is a context property in QML.37 * UbuntuApplication is a context property in QML.
35 */38 */
36UCApplication::UCApplication(QObject* parent) : QObject(parent), m_context(0)39UCApplication::UCApplication(QObject* parent) : QObject(parent), m_context(0), m_orientation(-1)
37{40{
38 // Make sure we receive application name changes from C++ modules41 // Make sure we receive application name changes from C++ modules
39 connect(QCoreApplication::instance(), &QCoreApplication::applicationNameChanged,42 connect(QCoreApplication::instance(), &QCoreApplication::applicationNameChanged,
40 this, &UCApplication::applicationNameChanged);43 this, &UCApplication::applicationNameChanged);
44
45 // Follow primary screen orientation changes
46 QGuiApplication::primaryScreen()->setOrientationUpdateMask(
47 Qt::PortraitOrientation |
48 Qt::LandscapeOrientation |
49 Qt::InvertedPortraitOrientation |
50 Qt::InvertedLandscapeOrientation);
51 connect(QGuiApplication::primaryScreen(), &QScreen::orientationChanged,
52 this, &UCApplication::orientationChanged);
41}53}
4254
43void UCApplication::setContext(QQmlContext* context) {55void UCApplication::setContext(QQmlContext* context) {
@@ -73,3 +85,29 @@
73 QCoreApplication::setOrganizationDomain(applicationName);85 QCoreApplication::setOrganizationDomain(applicationName);
74}86}
7587
88/*!
89 * \qmlproperty Qt.ScreenOrientation Application::orientation
90 * \internal
91 * The current orientation of the application - can be overridden manually for testing.
92 */
93Qt::ScreenOrientation UCApplication::orientation() {
94 if (m_orientation == -1) {
95 return QGuiApplication::primaryScreen()->orientation();
96 } else {
97 return static_cast<Qt::ScreenOrientation>(m_orientation);
98 }
99}
100
101void UCApplication::setOrientation(Qt::ScreenOrientation orientation) {
102 if (m_orientation == -1) {
103 // we're now in manual override mode
104 disconnect(QGuiApplication::primaryScreen(), &QScreen::orientationChanged,
105 this, &UCApplication::orientationChanged);
106 }
107
108 if (m_orientation != orientation) {
109 m_orientation = orientation;
110 Q_EMIT orientationChanged(orientation);
111 }
112}
113
76114
=== modified file 'modules/Ubuntu/Components/plugin/ucapplication.h'
--- modules/Ubuntu/Components/plugin/ucapplication.h 2013-10-18 08:56:39 +0000
+++ modules/Ubuntu/Components/plugin/ucapplication.h 2015-03-31 12:57:21 +0000
@@ -28,6 +28,7 @@
28{28{
29 Q_OBJECT29 Q_OBJECT
30 Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName NOTIFY applicationNameChanged)30 Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName NOTIFY applicationNameChanged)
31 Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
3132
32private:33private:
33 Q_DISABLE_COPY(UCApplication)34 Q_DISABLE_COPY(UCApplication)
@@ -42,16 +43,20 @@
4243
43 // getter44 // getter
44 QString applicationName();45 QString applicationName();
46 Qt::ScreenOrientation orientation();
4547
46 // setter48 // setter
47 void setContext(QQmlContext* context);49 void setContext(QQmlContext* context);
48 void setApplicationName(const QString& applicationName);50 void setApplicationName(const QString& applicationName);
51 void setOrientation(Qt::ScreenOrientation orientation);
4952
50private:53private:
51 QQmlContext* m_context;54 QQmlContext* m_context;
55 int m_orientation;
5256
53Q_SIGNALS:57Q_SIGNALS:
54 void applicationNameChanged();58 void applicationNameChanged();
59 void orientationChanged(Qt::ScreenOrientation orientation);
55};60};
5661
57#endif // UBUNTU_COMPONENTS_I18N_H62#endif // UBUNTU_COMPONENTS_I18N_H
5863
=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_mainview.py'
--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_mainview.py 2015-02-11 23:37:40 +0000
+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_mainview.py 2015-03-31 12:57:21 +0000
@@ -17,6 +17,7 @@
17"""Ubuntu UI Toolkit Autopilot custom proxy objects."""17"""Ubuntu UI Toolkit Autopilot custom proxy objects."""
1818
19import logging19import logging
20import time
2021
21from autopilot import logging as autopilot_logging22from autopilot import logging as autopilot_logging
22from autopilot.introspection import dbus23from autopilot.introspection import dbus
@@ -56,6 +57,18 @@
5657
57 return False58 return False
5859
60 def _set_orientation(self, orientation):
61 self.select_single(
62 objectName='MainViewBaseStyledItem').slots.setOrientation(
63 orientation)
64 # Short delay to ensure introspection is uptodate
65 time.sleep(1)
66
67 @property
68 def _orientation(self):
69 return self.select_single(
70 objectName='MainViewBaseStyledItem').orientation
71
59 def get_header(self):72 def get_header(self):
60 """Return the AppHeader custom proxy object of the MainView."""73 """Return the AppHeader custom proxy object of the MainView."""
61 try:74 try:
6275
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.py'
--- tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.py 2014-10-06 10:44:31 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.py 2015-03-31 12:57:21 +0000
@@ -17,10 +17,44 @@
17"""Tests for the Ubuntu UI Toolkit Header component."""17"""Tests for the Ubuntu UI Toolkit Header component."""
1818
19import os19import os
20import time
2021
21from ubuntuuitoolkit import tests22from ubuntuuitoolkit import tests
2223
2324
25class PopoverOpenTestCase(tests.QMLFileAppTestCase):
26
27 path = os.path.abspath(__file__)
28 dir_path = os.path.dirname(path)
29 test_qml_file_path = os.path.join(
30 dir_path, 'test_popover.qml')
31
32 scenarios = [
33 ('Popover', dict(button='button', popover='popover')),
34 ('Small dialog', dict(button='button_small', popover='dialog_small')),
35 ('Huge dialog', dict(button='button_huge', popover='dialog_huge')),
36 ]
37
38 def setUp(self):
39 super(PopoverOpenTestCase, self).setUp()
40
41 def _rotate(self, orientation):
42 self.main_view._set_orientation(orientation)
43 button = self.main_view.select_single(objectName=self.button)
44 self.pointing_device.click_object(button)
45 # Give rendering a chance to finish
46 time.sleep(2)
47 popover = self.main_view.select_single(objectName=self.popover)
48 self.assertEqual(popover.rotationAngle, self.main_view.select_single(
49 'OrientationHelper').rotation)
50
51 def test_popover_rotate_landscape(self):
52 self._rotate('Landscape')
53
54 def test_popover_rotate_portrait(self):
55 self._rotate('Portrait')
56
57
24class DialogScrollTestCase(tests.QMLFileAppTestCase):58class DialogScrollTestCase(tests.QMLFileAppTestCase):
2559
26 path = os.path.abspath(__file__)60 path = os.path.abspath(__file__)
2761
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.qml'
--- tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.qml 2015-03-03 13:20:06 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.qml 2015-03-31 12:57:21 +0000
@@ -15,19 +15,28 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Components 1.118import Ubuntu.Components 1.2
19import Ubuntu.Components.Popups 1.019import Ubuntu.Components.Popups 1.0
20import Ubuntu.Test 1.0
2021
21MainView {22MainView {
22 width: units.gu(48)23 id: root
23 height: units.gu(60)24 width: units.gu(60)
25 height: units.gu(40)
24 objectName: "mainView"26 objectName: "mainView"
2527
28 automaticOrientation: true
29
26 Page {30 Page {
27 title: "Popover"31 title: "Popover"
2832
29 Column {33 Column {
30 Button {34 Button {
35 objectName: "button"
36 text: "Pop over"
37 onClicked: PopupUtils.open(popoverComponent)
38 }
39 Button {
31 objectName: "button_small"40 objectName: "button_small"
32 text: "Small"41 text: "Small"
33 onClicked: PopupUtils.open(smallDialogComponent)42 onClicked: PopupUtils.open(smallDialogComponent)
@@ -37,15 +46,54 @@
37 text: "Huge"46 text: "Huge"
38 onClicked: PopupUtils.open(hugeDialogComponent)47 onClicked: PopupUtils.open(hugeDialogComponent)
39 }48 }
49 Button {
50 text: "Landscape"
51 onClicked: UbuntuApplication.orientation = Qt.LandscapeOrientation;
52 }
53 Button {
54 text: "Portrait"
55 onClicked: UbuntuApplication.orientation = Qt.PortraitOrientation;
56 }
57 }
58
59 Component {
60 id: popoverComponent
61 Popover {
62 objectName: "popover"
63 Column {
64 Button {
65 text: "Just a button"
66 onClicked: {
67 if (UbuntuApplication.orientation === Qt.LandscapeOrientation) {
68 UbuntuApplication.orientation = Qt.PortraitOrientation;
69 } else {
70 UbuntuApplication.orientation = Qt.LandscapeOrientation
71 }
72 }
73 }
74 }
75 }
40 }76 }
4177
42 Component {78 Component {
43 id: smallDialogComponent79 id: smallDialogComponent
44 Dialog {80 Dialog {
81 id: smallDialog
45 objectName: "dialog_small"82 objectName: "dialog_small"
46 Column {83 Row {
47 Button {84 Button {
48 text: "Just a button"85 text: "Just a button"
86 onClicked: {
87 if (UbuntuApplication.orientation === Qt.LandscapeOrientation) {
88 UbuntuApplication.orientation = Qt.PortraitOrientation;
89 } else {
90 UbuntuApplication.orientation = Qt.LandscapeOrientation
91 }
92 }
93 }
94 Button {
95 text: "close"
96 onClicked: PopupUtils.close(smallDialog)
49 }97 }
50 }98 }
51 }99 }
52100
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.py'
--- tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.py 2015-03-16 10:01:09 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.py 2015-03-31 12:57:21 +0000
@@ -166,6 +166,26 @@
166 self.assertTrue(popover.globalRect.y > 0,166 self.assertTrue(popover.globalRect.y > 0,
167 '%s <= 0' % popover.globalRect.y)167 '%s <= 0' % popover.globalRect.y)
168168
169 def _rotate(self, orientation):
170 if self.test_qml_file_path != self.textfield_qml_file_path:
171 self.skipTest('FIXME: Header behavior breaks some rotation cases')
172 self.main_view._set_orientation(orientation)
173 self.pointing_device.click_object(self.textfield)
174 cursor = self.select_cursor('cursorPosition')
175 self.pointing_device.click_object(cursor)
176 # Give rendering a chance to finish
177 sleep(2)
178 popover = self.main_view.get_text_input_context_menu(
179 'text_input_contextmenu')
180 self.assertEqual(popover.rotation, self.main_view.select_single(
181 'OrientationHelper').rotation)
182
183 def test_rotate_landscape(self):
184 self._rotate('Landscape')
185
186 def test_rotate_portrait(self):
187 self._rotate('Portrait')
188
169 def test_header_undisturbed_by_text_handlers(self):189 def test_header_undisturbed_by_text_handlers(self):
170 # Verify that handlers aren't accidentally placed at absolute 0/0190 # Verify that handlers aren't accidentally placed at absolute 0/0
171 self.pointing_device.click_object(self.textfield)191 self.pointing_device.click_object(self.textfield)
172192
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textarea.qml'
--- tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textarea.qml 2015-03-10 16:29:24 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textarea.qml 2015-03-31 12:57:21 +0000
@@ -22,6 +22,8 @@
22 height: units.gu(60)22 height: units.gu(60)
23 objectName: "mainView"23 objectName: "mainView"
2424
25 automaticOrientation: true
26
25 Page {27 Page {
26 title: "Textarea"28 title: "Textarea"
27 head.backAction: Action {29 head.backAction: Action {
2830
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield.qml'
--- tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield.qml 2015-03-10 16:29:24 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield.qml 2015-03-31 12:57:21 +0000
@@ -18,10 +18,12 @@
18import Ubuntu.Components 1.218import Ubuntu.Components 1.2
1919
20MainView {20MainView {
21 width: units.gu(48)21 width: units.gu(60)
22 height: units.gu(60)22 height: units.gu(40)
23 objectName: "mainView"23 objectName: "mainView"
2424
25 automaticOrientation: true
26
25 Page {27 Page {
26 title: "Textfield"28 title: "Textfield"
27 head.backAction: Action {29 head.backAction: Action {
@@ -31,11 +33,17 @@
31 }33 }
3234
33 Column {35 Column {
36 anchors.bottom: parent.bottom
37 spacing: units.gu(2)
38
34 TextField {39 TextField {
35 objectName: "textfield"40 objectName: "textfield"
36 placeholderText: "Type here"41 placeholderText: "Type here"
37 width: units.gu(35)42 width: units.gu(35)
38 }43 }
44 Label {
45 text: i18n.tr("Text fields are awesome")
46 }
39 }47 }
40 }48 }
41}49}
4250
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield_custom.qml'
--- tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield_custom.qml 2015-03-10 16:29:24 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield_custom.qml 2015-03-31 12:57:21 +0000
@@ -23,6 +23,8 @@
23 height: units.gu(60)23 height: units.gu(60)
24 objectName: "mainView"24 objectName: "mainView"
2525
26 automaticOrientation: true
27
26 Page {28 Page {
27 title: "Textfield"29 title: "Textfield"
28 head.backAction: Action {30 head.backAction: Action {

Subscribers

People subscribed via source and target branches