Merge lp:~elopio/ubuntu-ui-toolkit/fix1324556-get_top_container into lp:ubuntu-ui-toolkit

Proposed by Leo Arias
Status: Superseded
Proposed branch: lp:~elopio/ubuntu-ui-toolkit/fix1324556-get_top_container
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 619 lines (+219/-98)
17 files modified
CHANGES (+1/-1)
components.api (+7/-14)
modules/Ubuntu/Components/AnimatedItem.qml (+1/-38)
modules/Ubuntu/Components/ListItems/Base.qml (+1/-1)
modules/Ubuntu/Components/PageStack.qml (+1/-0)
modules/Ubuntu/Components/Pickers/DatePicker.qml (+4/-2)
modules/Ubuntu/Components/plugin/i18n.cpp (+6/-5)
modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp (+6/-3)
modules/Ubuntu/Components/qmldir (+1/-2)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_common.py (+16/-0)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py (+0/-17)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py (+2/-9)
tests/autopilot/ubuntuuitoolkit/fixture_setup.py (+45/-0)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HeaderInCustomMainViewTestCase.qml (+27/-0)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py (+23/-0)
tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py (+72/-1)
tests/qmlapicheck.py (+6/-5)
To merge this branch: bzr merge lp:~elopio/ubuntu-ui-toolkit/fix1324556-get_top_container
Reviewer Review Type Date Requested Status
Ubuntu SDK team Pending
Review via email: mp+221425@code.launchpad.net

This proposal has been superseded by a proposal from 2014-05-29.

Commit message

On the header autopilot helper, use the top container instead of the main view.

To post a comment you must log in.
1091. By Leo Arias

Reverted the change on the test init.

1092. By Leo Arias

Fixed pep8.

1093. By Leo Arias

Typo.

1094. By Leo Arias

Fixed the regression test.

1095. By Leo Arias

Prunned the custom main view.

1096. By Leo Arias

removed the header.

1097. By Leo Arias

Kick jenkins.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CHANGES'
--- CHANGES 2014-05-20 08:35:14 +0000
+++ CHANGES 2014-05-29 16:26:04 +0000
@@ -12,7 +12,7 @@
1212
13Compatibility Breaks13Compatibility Breaks
14********************14********************
1515* Header component API was made internal (as it was always documented)
1616
17Ubuntu.Components 1.017Ubuntu.Components 1.0
18#####################18#####################
1919
=== modified file 'components.api'
--- components.api 2014-05-26 11:36:53 +0000
+++ components.api 2014-05-29 16:26:04 +0000
@@ -31,6 +31,7 @@
31AbstractButton31AbstractButton
32 property color color32 property color color
33 property Gradient gradient33 property Gradient gradient
34 property font font
34 property string iconPosition35 property string iconPosition
35CheckBox 0.1 1.036CheckBox 0.1 1.0
36AbstractButton37AbstractButton
@@ -61,19 +62,6 @@
61 readonly property bool running62 readonly property bool running
62 property size sourceSize63 property size sourceSize
63 readonly property int status64 readonly property int status
64Header 0.1 1.0
65StyledItem
66 property bool animate
67 function show()
68 function hide()
69 property string title
70 property Item contents
71 property var tabsModel
72 property var pageStack
73 property var actions
74 property var __customBackAction
75 property Flickable flickable
76 property bool useDeprecatedToolbar
77Icon 0.1 1.065Icon 0.1 1.0
78Item66Item
79 property string name67 property string name
@@ -94,7 +82,7 @@
94 property real __leftIconMargin82 property real __leftIconMargin
95 property real __rightIconMargin83 property real __rightIconMargin
96 property bool __iconIsItem84 property bool __iconIsItem
97 property internal children85 default property internal children
98Caption 0.1 1.086Caption 0.1 1.0
99Item87Item
100 property string text88 property string text
@@ -140,6 +128,7 @@
140 property bool expanded128 property bool expanded
141 property bool multiSelection129 property bool multiSelection
142 property bool colourImage130 property bool colourImage
131 property Component delegate
143 property real containerHeight132 property real containerHeight
144 property int selectedIndex133 property int selectedIndex
145 property bool currentlyExpanded134 property bool currentlyExpanded
@@ -204,12 +193,14 @@
204Object 0.1 1.0193Object 0.1 1.0
205QtObject194QtObject
206 default property internal children195 default property internal children
196 property list<QtObject> __defaultPropertyFix
207OptionSelector 0.1 1.0197OptionSelector 0.1 1.0
208ListItem.Empty198ListItem.Empty
209 property var model199 property var model
210 property bool expanded200 property bool expanded
211 property bool multiSelection201 property bool multiSelection
212 property bool colourImage202 property bool colourImage
203 property Component delegate
213 property real containerHeight204 property real containerHeight
214 property int selectedIndex205 property int selectedIndex
215 property bool currentlyExpanded206 property bool currentlyExpanded
@@ -235,6 +226,7 @@
235Page 0.1 1.0226Page 0.1 1.0
236PageTreeNode227PageTreeNode
237 property string title228 property string title
229 property Item tools
238 property Item __customHeaderContents230 property Item __customHeaderContents
239 property Flickable flickable231 property Flickable flickable
240 property list<Action> actions232 property list<Action> actions
@@ -355,6 +347,7 @@
355OrientationHelper347OrientationHelper
356 property Item dismissArea348 property Item dismissArea
357 property bool grabDismissAreaEvents349 property bool grabDismissAreaEvents
350 property PropertyAnimation fadingAnimation
358 function show()351 function show()
359 function hide()352 function hide()
360 function __closeIfHidden()353 function __closeIfHidden()
361354
=== modified file 'modules/Ubuntu/Components/AnimatedItem.qml'
--- modules/Ubuntu/Components/AnimatedItem.qml 2014-04-23 08:50:20 +0000
+++ modules/Ubuntu/Components/AnimatedItem.qml 2014-05-29 16:26:04 +0000
@@ -30,45 +30,8 @@
30 id: root30 id: root
31 /*!31 /*!
32 \preliminary32 \preliminary
33 \deprecated
33 Specifies whether the component is on the visible area of the Flickable or not.34 Specifies whether the component is on the visible area of the Flickable or not.
34 */35 */
35 property bool onScreen: true36 property bool onScreen: true
36
37 QtObject {
38 id: internal
39 property Flickable flickable
40
41 // returns whether the component is in the visible area of the flickable
42 function checkOnScreen()
43 {
44 var pos = root.mapToItem(flickable, 0, 0)
45 root.onScreen = (pos.y + root.height >= 0) && (pos.y <= internal.flickable.height) &&
46 (pos.x + root.width >= 0) && (pos.x <= internal.flickable.width)
47 }
48 // lookup for a flickable parent
49 function updateFlickableParent()
50 {
51 var flickable = root.parent
52 while (flickable) {
53 if (flickable.hasOwnProperty("flicking") && flickable.hasOwnProperty("flickableDirection")) {
54 // non-interactive flickables must be skipped as those do not provide
55 // on-screen detection support
56 if (flickable.interactive)
57 break
58 }
59 flickable = flickable.parent
60 }
61 internal.flickable = flickable
62 }
63 }
64
65 Connections {
66 target: internal.flickable
67
68 onContentXChanged: internal.checkOnScreen()
69 onContentYChanged: internal.checkOnScreen()
70 }
71
72 Component.onCompleted: internal.updateFlickableParent()
73 onParentChanged: internal.updateFlickableParent()
74}37}
7538
=== modified file 'modules/Ubuntu/Components/ListItems/Base.qml'
--- modules/Ubuntu/Components/ListItems/Base.qml 2014-04-28 19:24:56 +0000
+++ modules/Ubuntu/Components/ListItems/Base.qml 2014-05-29 16:26:04 +0000
@@ -159,7 +159,7 @@
159 /*!159 /*!
160 \internal160 \internal
161 */161 */
162 property alias children: middle.data162 default property alias children: middle.data
163 Item {163 Item {
164 id: middle164 id: middle
165 property bool anchorToIconHelper: !__iconIsItem && iconHelper.source != ""165 property bool anchorToIconHelper: !__iconIsItem && iconHelper.source != ""
166166
=== modified file 'modules/Ubuntu/Components/PageStack.qml'
--- modules/Ubuntu/Components/PageStack.qml 2014-05-13 09:09:35 +0000
+++ modules/Ubuntu/Components/PageStack.qml 2014-05-29 16:26:04 +0000
@@ -192,6 +192,7 @@
192 */192 */
193 default property alias data: inactiveNode.data193 default property alias data: inactiveNode.data
194 PageTreeNode {194 PageTreeNode {
195 anchors.fill: parent
195 id: inactiveNode196 id: inactiveNode
196 active: false197 active: false
197 }198 }
198199
=== modified file 'modules/Ubuntu/Components/Pickers/DatePicker.qml'
--- modules/Ubuntu/Components/Pickers/DatePicker.qml 2014-05-07 10:42:31 +0000
+++ modules/Ubuntu/Components/Pickers/DatePicker.qml 2014-05-29 16:26:04 +0000
@@ -523,7 +523,8 @@
523 function updatePickers() {523 function updatePickers() {
524 if (completed) {524 if (completed) {
525 // check mode flags first525 // check mode flags first
526 var modes = datePicker.mode.split(/\W/g);526 // FIXME: The js split(/\W/g) terminates the process on armhf with Qt 5.3 (v4 js) (https://bugreports.qt-project.org/browse/QTBUG-39255)
527 var modes = datePicker.mode.match(/\w+/g);
527528
528 showYearPicker = showMonthPicker = showDayPicker =529 showYearPicker = showMonthPicker = showDayPicker =
529 showHoursPicker = showMinutesPicker = showSecondsPicker = false;530 showHoursPicker = showMinutesPicker = showSecondsPicker = false;
@@ -607,7 +608,8 @@
607 completed = false;608 completed = false;
608609
609 // use short format to exclude any extra characters610 // use short format to exclude any extra characters
610 var format = datePicker.locale.dateFormat(Locale.ShortFormat).split(/\W/g);611 // FIXME: The js split(/\W/g) terminates the process on armhf with Qt 5.3 (v4 js) (https://bugreports.qt-project.org/browse/QTBUG-39255)
612 var format = datePicker.locale.dateFormat(Locale.ShortFormat).match(/\w+/g);
611 // loop through the format to decide the position of the tumbler613 // loop through the format to decide the position of the tumbler
612 var formatIndex = 0;614 var formatIndex = 0;
613 for (var i in format) {615 for (var i in format) {
614616
=== modified file 'modules/Ubuntu/Components/plugin/i18n.cpp'
--- modules/Ubuntu/Components/plugin/i18n.cpp 2014-05-22 15:54:13 +0000
+++ modules/Ubuntu/Components/plugin/i18n.cpp 2014-05-29 16:26:04 +0000
@@ -103,13 +103,14 @@
103 /*103 /*
104 The default is /usr/share/locale if we don't set a folder104 The default is /usr/share/locale if we don't set a folder
105 For click we use APP_DIR/share/locale105 For click we use APP_DIR/share/locale
106 eg. /usr/share/click/preinstalled/com.example.foo/current/share/locale106 e.g. /usr/share/click/preinstalled/com.example.foo/current/share/locale
107 */107 */
108 QDir appDir(getenv("APP_DIR"));108 QString appDir(getenv("APP_DIR"));
109 if (appDir.exists()) {109 if (!QDir::isAbsolutePath (appDir)) {
110 QString localePath(appDir.filePath("share/locale"));110 appDir = "/usr";
111 C::bindtextdomain(domain.toUtf8(), localePath.toUtf8());
112 }111 }
112 QString localePath(QDir(appDir).filePath("share/locale"));
113 C::bindtextdomain(domain.toUtf8(), localePath.toUtf8());
113 Q_EMIT domainChanged();114 Q_EMIT domainChanged();
114}115}
115116
116117
=== modified file 'modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp'
--- modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp 2014-02-25 09:14:23 +0000
+++ modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp 2014-05-29 16:26:04 +0000
@@ -43,12 +43,15 @@
43 * is the only way around the issue for now. */43 * is the only way around the issue for now. */
44 std::string src_path(QUrl(id).path().toUtf8().data());44 std::string src_path(QUrl(id).path().toUtf8().data());
45 std::string tgt_path;45 std::string tgt_path;
46 const int xlarge_cutoff = 512;
47 const int large_cutoff = 256;
48 const int small_cutoff = 128;
46 try {49 try {
47 ThumbnailSize desiredSize;50 ThumbnailSize desiredSize;
48 const int large_cutoff = 256;51 if(requestedSize.width() > xlarge_cutoff || requestedSize.height() > xlarge_cutoff) {
49 const int small_cutoff = 128;
50 if(requestedSize.width() > large_cutoff || requestedSize.height() > large_cutoff) {
51 desiredSize = TN_SIZE_ORIGINAL;52 desiredSize = TN_SIZE_ORIGINAL;
53 } else if(requestedSize.width() > large_cutoff || requestedSize.height() > large_cutoff) {
54 desiredSize = TN_SIZE_XLARGE;
52 } else if(requestedSize.width() > small_cutoff || requestedSize.height() > small_cutoff) {55 } else if(requestedSize.width() > small_cutoff || requestedSize.height() > small_cutoff) {
53 desiredSize = TN_SIZE_LARGE;56 desiredSize = TN_SIZE_LARGE;
54 } else {57 } else {
5558
=== modified file 'modules/Ubuntu/Components/qmldir'
--- modules/Ubuntu/Components/qmldir 2014-04-25 12:53:58 +0000
+++ modules/Ubuntu/Components/qmldir 2014-05-29 16:26:04 +0000
@@ -29,7 +29,7 @@
29internal PageTreeNode PageTreeNode.qml29internal PageTreeNode PageTreeNode.qml
30PageStack 0.1 PageStack.qml30PageStack 0.1 PageStack.qml
31internal Toolbar Toolbar.qml31internal Toolbar Toolbar.qml
32Header 0.1 Header.qml32internal Header Header.qml
33internal AnimatedItem AnimatedItem.qml33internal AnimatedItem AnimatedItem.qml
34internal PageWrapper PageWrapper.qml34internal PageWrapper PageWrapper.qml
35UbuntuShape 0.1 UbuntuShape.qml35UbuntuShape 0.1 UbuntuShape.qml
@@ -76,7 +76,6 @@
76OptionSelectorDelegate 1.0 OptionSelectorDelegate.qml76OptionSelectorDelegate 1.0 OptionSelectorDelegate.qml
77Page 1.0 Page.qml77Page 1.0 Page.qml
78PageStack 1.0 PageStack.qml78PageStack 1.0 PageStack.qml
79Header 1.0 Header.qml
80UbuntuShape 1.0 UbuntuShape.qml79UbuntuShape 1.0 UbuntuShape.qml
81CrossFadeImage 1.0 CrossFadeImage.qml80CrossFadeImage 1.0 CrossFadeImage.qml
82Icon 1.0 Icon.qml81Icon 1.0 Icon.qml
8382
=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_common.py'
--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_common.py 2014-04-29 23:03:58 +0000
+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_common.py 2014-05-29 16:26:04 +0000
@@ -111,3 +111,19 @@
111 raise ToolkitException(111 raise ToolkitException(
112 "The element is not contained in a Flickable so it can't be "112 "The element is not contained in a Flickable so it can't be "
113 "swiped into view.")113 "swiped into view.")
114
115 def _get_top_container(self):
116 """Return the top-most container with a globalRect."""
117 root = self.get_root_instance()
118 parent = self.get_parent()
119 top_container = None
120 while parent.id != root.id:
121 if hasattr(parent, 'globalRect'):
122 top_container = parent
123
124 parent = parent.get_parent()
125
126 if top_container is None:
127 raise ToolkitException('Could not find the top-most container.')
128 else:
129 return top_container
114130
=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py'
--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2014-05-20 07:31:55 +0000
+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2014-05-29 16:26:04 +0000
@@ -51,23 +51,6 @@
51 containers = [self._get_top_container(), self]51 containers = [self._get_top_container(), self]
52 return containers52 return containers
5353
54 def _get_top_container(self):
55 """Return the top-most container with a globalRect."""
56 root = self.get_root_instance()
57 parent = self.get_parent()
58 top_container = None
59 while parent.id != root.id:
60 if hasattr(parent, 'globalRect'):
61 top_container = parent
62
63 parent = parent.get_parent()
64
65 if top_container is None:
66 raise _common.ToolkitException(
67 "Couldn't find the top-most container.")
68 else:
69 return top_container
70
71 def _is_child_visible(self, child, containers):54 def _is_child_visible(self, child, containers):
72 """Check if the center of the child is visible.55 """Check if the center of the child is visible.
7356
7457
=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py'
--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py 2014-05-13 12:43:31 +0000
+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py 2014-05-29 16:26:04 +0000
@@ -21,7 +21,6 @@
2121
22from ubuntuuitoolkit._custom_proxy_objects import (22from ubuntuuitoolkit._custom_proxy_objects import (
23 _common,23 _common,
24 _mainview,
25 _tabbar24 _tabbar
26)25)
2726
@@ -35,13 +34,6 @@
35class Header(_common.UbuntuUIToolkitCustomProxyObjectBase):34class Header(_common.UbuntuUIToolkitCustomProxyObjectBase):
36 """Header Autopilot emulator."""35 """Header Autopilot emulator."""
3736
38 def __init__(self, *args):
39 super(Header, self).__init__(*args)
40 # XXX we need a better way to keep reference to the main view.
41 # --elopio - 2014-02-26
42 self.main_view = self.get_root_instance().select_single(
43 _mainview.MainView)
44
45 def _show_if_not_visible(self):37 def _show_if_not_visible(self):
46 if not self._is_visible():38 if not self._is_visible():
47 self._show()39 self._show()
@@ -53,8 +45,9 @@
53 # FIXME This will fail if the header is not linked to a flickable that45 # FIXME This will fail if the header is not linked to a flickable that
54 # fills the main view. The header has a flickable property but it46 # fills the main view. The header has a flickable property but it
55 # can't be read by autopilot. See bug http://pad.lv/131882947 # can't be read by autopilot. See bug http://pad.lv/1318829
48 top_container = self._get_top_container()
56 start_x = stop_x = (self.globalRect.x + self.globalRect.width) // 249 start_x = stop_x = (self.globalRect.x + self.globalRect.width) // 2
57 start_y = self.main_view.globalRect.y + 550 start_y = top_container.globalRect.y + 5
58 stop_y = start_y + self.globalRect.height51 stop_y = start_y + self.globalRect.height
59 self.pointing_device.drag(start_x, start_y, stop_x, stop_y)52 self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
60 self.y.wait_for(0)53 self.y.wait_for(0)
6154
=== modified file 'tests/autopilot/ubuntuuitoolkit/fixture_setup.py'
--- tests/autopilot/ubuntuuitoolkit/fixture_setup.py 2014-04-23 08:50:20 +0000
+++ tests/autopilot/ubuntuuitoolkit/fixture_setup.py 2014-05-29 16:26:04 +0000
@@ -16,6 +16,7 @@
1616
17import copy17import copy
18import os18import os
19import shutil
19import tempfile20import tempfile
2021
21import fixtures22import fixtures
@@ -118,3 +119,47 @@
118 original_value)119 original_value)
119 else:120 else:
120 self.addCleanup(environment.unset_initctl_env_var, variable)121 self.addCleanup(environment.unset_initctl_env_var, variable)
122
123
124class FakeHome(fixtures.Fixture):
125
126 # We copy the Xauthority file to allow executions using XVFB. If it is not
127 # on the user's HOME directory, nothing will happen.
128 should_copy_xauthority_file = True
129
130 def __init__(self, directory=None):
131 super(FakeHome, self).__init__()
132 self.directory = directory
133
134 def setUp(self):
135 super(FakeHome, self).setUp()
136 self.directory = self._make_directory_if_not_specified()
137 if self.should_copy_xauthority_file:
138 self._copy_xauthority_file(self.directory)
139 # We patch both environment variables so it works on the desktop and on
140 # the phone.
141 self.useFixture(
142 InitctlEnvironmentVariable(HOME=self.directory))
143 self.useFixture(
144 fixtures.EnvironmentVariable('HOME', newvalue=self.directory))
145
146 def _make_directory_if_not_specified(self):
147 if self.directory is None:
148 parent_directory = os.path.join(
149 os.environ.get('HOME'), 'autopilot', 'fakeenv')
150 if not os.path.exists(parent_directory):
151 os.makedirs(parent_directory)
152 temp_dir_fixture = fixtures.TempDir(parent_directory)
153 self.useFixture(temp_dir_fixture)
154 return temp_dir_fixture.path
155 else:
156 return self.directory
157
158 def _copy_xauthority_file(self, directory):
159 """Copy the .Xauthority file if it exists in the user's home."""
160 xauthority_file_path = os.path.join(
161 os.environ.get('HOME'), '.Xauthority')
162 if os.path.isfile(xauthority_file_path):
163 shutil.copyfile(
164 xauthority_file_path,
165 os.path.join(directory, '.Xauthority'))
121166
=== added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HeaderInCustomMainViewTestCase.qml'
--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HeaderInCustomMainViewTestCase.qml 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HeaderInCustomMainViewTestCase.qml 2014-05-29 16:26:04 +0000
@@ -0,0 +1,27 @@
1/*
2 * Copyright 2014Canonical 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 1.1
19
20Item {
21
22 objectName: 'mainView'
23
24 Header {
25 title: 'test header'
26 }
27}
028
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py'
--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py 2014-05-20 08:56:28 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py 2014-05-29 16:26:04 +0000
@@ -14,6 +14,8 @@
14# You should have received a copy of the GNU Lesser General Public License14# You should have received a copy of the GNU Lesser General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
17import os
18
17import ubuntuuitoolkit19import ubuntuuitoolkit
18from ubuntuuitoolkit import tests20from ubuntuuitoolkit import tests
1921
@@ -157,3 +159,24 @@
157159
158 # only three actions are visible160 # only three actions are visible
159 self.assertEqual(overflow_button.visible, False)161 self.assertEqual(overflow_button.visible, False)
162
163
164class HeaderInCustomMainViewTestCase(tests.QMLFileAppTestCase):
165
166 path = os.path.abspath(__file__)
167 dir_path = os.path.dirname(path)
168 test_qml_file_path = os.path.join(
169 dir_path, 'test_header.HeaderInCustomMainViewTestCase.qml')
170
171 @property
172 def main_view(self):
173 return self.app.select_single('QQuickItem', objectName='mainView')
174
175 def test_get_header_from_custom_main_view(self):
176 """Test that we can get the header from a custom main view.
177
178 This prevents a regression of http://pad.lv/1324556.
179
180 """
181 header = self.app.select_single(ubuntuuitoolkit.Header)
182 self.assertIsInstance(header, ubuntuuitoolkit.Header)
160183
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py'
--- tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py 2014-03-10 16:51:01 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py 2014-05-29 16:26:04 +0000
@@ -15,6 +15,7 @@
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
17import os17import os
18import tempfile
1819
19try:20try:
20 # Python 3.21 # Python 3.
@@ -24,7 +25,7 @@
24 import mock25 import mock
25import testtools26import testtools
26from autopilot import testcase as autopilot_testcase27from autopilot import testcase as autopilot_testcase
27from testtools.matchers import Contains, Not, FileExists28from testtools.matchers import Contains, FileExists, Not
2829
29from ubuntuuitoolkit import base, environment, fixture_setup30from ubuntuuitoolkit import base, environment, fixture_setup
3031
@@ -233,3 +234,73 @@
233 self.assertEqual(234 self.assertEqual(
234 'original test value',235 'original test value',
235 environment.get_initctl_env_var('testenvvarforfixture'))236 environment.get_initctl_env_var('testenvvarforfixture'))
237
238
239class FakeHomeTestCase(testtools.TestCase):
240
241 def test_fake_home_fixture_patches_initctl_env_var(self):
242 original_home = environment.get_initctl_env_var('HOME')
243 fake_home = original_home + 'fake'
244 result = testtools.TestResult()
245
246 def inner_test():
247 class TestWithFakeHome(testtools.TestCase):
248 def test_it(self):
249 fake_home_fixture = fixture_setup.FakeHome(fake_home)
250 fake_home_fixture.should_copy_xauthority_file = False
251 self.useFixture(fake_home_fixture)
252 self.assertEqual(
253 fake_home, environment.get_initctl_env_var('HOME'))
254 return TestWithFakeHome('test_it')
255
256 inner_test().run(result)
257
258 self.assertTrue(
259 result.wasSuccessful(),
260 'Failed to fake the home: {}'.format(result.errors))
261 self.assertEqual(
262 original_home,
263 environment.get_initctl_env_var('HOME'))
264
265 def test_fake_home_fixture_patches_env_var(self):
266 original_home = os.environ.get('HOME')
267 fake_home = tempfile.gettempdir()
268 result = testtools.TestResult()
269
270 def inner_test():
271 class TestWithFakeHome(testtools.TestCase):
272 def test_it(self):
273 fake_home_fixture = fixture_setup.FakeHome(fake_home)
274 fake_home_fixture.should_copy_xauthority_file = False
275 self.useFixture(fake_home_fixture)
276 self.assertEqual(
277 fake_home, os.environ.get('HOME'))
278 return TestWithFakeHome('test_it')
279
280 inner_test().run(result)
281
282 self.assertTrue(
283 result.wasSuccessful(),
284 'Failed to fake the home: {}'.format(result.failures))
285 self.assertEqual(original_home, os.environ.get('HOME'))
286
287 def test_fake_home_fixture_must_create_default_directory(self):
288 original_home = os.environ.get('HOME')
289 self.useFixture(fixture_setup.FakeHome())
290
291 home_parent_directory, _ = os.path.split(os.environ.get('HOME'))
292 self.assertEqual(
293 home_parent_directory,
294 os.path.join(original_home, 'autopilot', 'fakeenv'))
295
296 def test_fake_home_fixture_must_copy_xauthority(self):
297 # Fake the home first so we don't write the xauthority on the real
298 # home.
299 self.useFixture(fixture_setup.FakeHome())
300
301 open(os.path.join(os.environ.get('HOME'), '.Xauthority')).close()
302
303 self.useFixture(fixture_setup.FakeHome())
304 self.assertTrue(
305 os.path.exists(
306 os.path.join(os.environ.get('HOME'), '.Xauthority')))
236307
=== modified file 'tests/qmlapicheck.py'
--- tests/qmlapicheck.py 2014-04-24 09:18:38 +0000
+++ tests/qmlapicheck.py 2014-05-29 16:26:04 +0000
@@ -130,10 +130,10 @@
130 if '{' in line and '}' in line:130 if '{' in line and '}' in line:
131 if filetype == 'qmltypes' and not in_builtin_type:131 if filetype == 'qmltypes' and not in_builtin_type:
132 print(' ' + line.strip())132 print(' ' + line.strip())
133 continue133 continue
134134
135 # End of function/ signal/ Item block135 # End of function/ signal/ Item block
136 if '}' in line:136 if '}' in line and not '{' in line:
137 in_block -= 1137 in_block -= 1
138 block_meta = {}138 block_meta = {}
139 if in_block == 1 and in_builtin_type:139 if in_block == 1 and in_builtin_type:
@@ -143,7 +143,7 @@
143 # Only root "Item {" is inspected for QML, otherwise all children143 # Only root "Item {" is inspected for QML, otherwise all children
144 if in_block == 1 or filetype == 'qmltypes':144 if in_block == 1 or filetype == 'qmltypes':
145 # Left hand side specifies a keyword, a type and a variable name145 # Left hand side specifies a keyword, a type and a variable name
146 declaration = line.split(':')[0]146 declaration = line.split(':', 1)[0]
147 words = declaration.strip().split(' ')147 words = declaration.strip().split(' ')
148 # Skip types with prefixes considered builtin148 # Skip types with prefixes considered builtin
149 if filetype == 'qmltypes' and words[0] == 'name':149 if filetype == 'qmltypes' and words[0] == 'name':
@@ -175,7 +175,8 @@
175 for word in words:175 for word in words:
176 if word in keywords:176 if word in keywords:
177 if filetype == 'qml':177 if filetype == 'qml':
178 signature = declaration.split('{')[0].strip()178 separator = '{' if 'function' in declaration else ':'
179 signature = declaration.split(separator, 1)[0].strip()
179 if 'alias' in line:180 if 'alias' in line:
180 no_mods = signature181 no_mods = signature
181 for mod in ['readonly', 'default']:182 for mod in ['readonly', 'default']:
@@ -198,7 +199,7 @@
198 break199 break
199200
200 # Start of function/ signal/ Item block201 # Start of function/ signal/ Item block
201 if '{' in line:202 if '{' in line and not '}' in line:
202 in_block += 1203 in_block += 1
203 block_meta = {}204 block_meta = {}
204 # The parent type can affect API205 # The parent type can affect API

Subscribers

People subscribed via source and target branches

to status/vote changes: