Merge lp:~elopio/ubuntu-ui-toolkit/fix1324556-get_top_container into lp:ubuntu-ui-toolkit
- fix1324556-get_top_container
- Merge into trunk
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 |
Related bugs: |
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.
Description of the change
To post a comment you must log in.
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CHANGES' | |||
2 | --- CHANGES 2014-05-20 08:35:14 +0000 | |||
3 | +++ CHANGES 2014-05-29 16:26:04 +0000 | |||
4 | @@ -12,7 +12,7 @@ | |||
5 | 12 | 12 | ||
6 | 13 | Compatibility Breaks | 13 | Compatibility Breaks |
7 | 14 | ******************** | 14 | ******************** |
9 | 15 | 15 | * Header component API was made internal (as it was always documented) | |
10 | 16 | 16 | ||
11 | 17 | Ubuntu.Components 1.0 | 17 | Ubuntu.Components 1.0 |
12 | 18 | ##################### | 18 | ##################### |
13 | 19 | 19 | ||
14 | === modified file 'components.api' | |||
15 | --- components.api 2014-05-26 11:36:53 +0000 | |||
16 | +++ components.api 2014-05-29 16:26:04 +0000 | |||
17 | @@ -31,6 +31,7 @@ | |||
18 | 31 | AbstractButton | 31 | AbstractButton |
19 | 32 | property color color | 32 | property color color |
20 | 33 | property Gradient gradient | 33 | property Gradient gradient |
21 | 34 | property font font | ||
22 | 34 | property string iconPosition | 35 | property string iconPosition |
23 | 35 | CheckBox 0.1 1.0 | 36 | CheckBox 0.1 1.0 |
24 | 36 | AbstractButton | 37 | AbstractButton |
25 | @@ -61,19 +62,6 @@ | |||
26 | 61 | readonly property bool running | 62 | readonly property bool running |
27 | 62 | property size sourceSize | 63 | property size sourceSize |
28 | 63 | readonly property int status | 64 | readonly property int status |
29 | 64 | Header 0.1 1.0 | ||
30 | 65 | StyledItem | ||
31 | 66 | property bool animate | ||
32 | 67 | function show() | ||
33 | 68 | function hide() | ||
34 | 69 | property string title | ||
35 | 70 | property Item contents | ||
36 | 71 | property var tabsModel | ||
37 | 72 | property var pageStack | ||
38 | 73 | property var actions | ||
39 | 74 | property var __customBackAction | ||
40 | 75 | property Flickable flickable | ||
41 | 76 | property bool useDeprecatedToolbar | ||
42 | 77 | Icon 0.1 1.0 | 65 | Icon 0.1 1.0 |
43 | 78 | Item | 66 | Item |
44 | 79 | property string name | 67 | property string name |
45 | @@ -94,7 +82,7 @@ | |||
46 | 94 | property real __leftIconMargin | 82 | property real __leftIconMargin |
47 | 95 | property real __rightIconMargin | 83 | property real __rightIconMargin |
48 | 96 | property bool __iconIsItem | 84 | property bool __iconIsItem |
50 | 97 | property internal children | 85 | default property internal children |
51 | 98 | Caption 0.1 1.0 | 86 | Caption 0.1 1.0 |
52 | 99 | Item | 87 | Item |
53 | 100 | property string text | 88 | property string text |
54 | @@ -140,6 +128,7 @@ | |||
55 | 140 | property bool expanded | 128 | property bool expanded |
56 | 141 | property bool multiSelection | 129 | property bool multiSelection |
57 | 142 | property bool colourImage | 130 | property bool colourImage |
58 | 131 | property Component delegate | ||
59 | 143 | property real containerHeight | 132 | property real containerHeight |
60 | 144 | property int selectedIndex | 133 | property int selectedIndex |
61 | 145 | property bool currentlyExpanded | 134 | property bool currentlyExpanded |
62 | @@ -204,12 +193,14 @@ | |||
63 | 204 | Object 0.1 1.0 | 193 | Object 0.1 1.0 |
64 | 205 | QtObject | 194 | QtObject |
65 | 206 | default property internal children | 195 | default property internal children |
66 | 196 | property list<QtObject> __defaultPropertyFix | ||
67 | 207 | OptionSelector 0.1 1.0 | 197 | OptionSelector 0.1 1.0 |
68 | 208 | ListItem.Empty | 198 | ListItem.Empty |
69 | 209 | property var model | 199 | property var model |
70 | 210 | property bool expanded | 200 | property bool expanded |
71 | 211 | property bool multiSelection | 201 | property bool multiSelection |
72 | 212 | property bool colourImage | 202 | property bool colourImage |
73 | 203 | property Component delegate | ||
74 | 213 | property real containerHeight | 204 | property real containerHeight |
75 | 214 | property int selectedIndex | 205 | property int selectedIndex |
76 | 215 | property bool currentlyExpanded | 206 | property bool currentlyExpanded |
77 | @@ -235,6 +226,7 @@ | |||
78 | 235 | Page 0.1 1.0 | 226 | Page 0.1 1.0 |
79 | 236 | PageTreeNode | 227 | PageTreeNode |
80 | 237 | property string title | 228 | property string title |
81 | 229 | property Item tools | ||
82 | 238 | property Item __customHeaderContents | 230 | property Item __customHeaderContents |
83 | 239 | property Flickable flickable | 231 | property Flickable flickable |
84 | 240 | property list<Action> actions | 232 | property list<Action> actions |
85 | @@ -355,6 +347,7 @@ | |||
86 | 355 | OrientationHelper | 347 | OrientationHelper |
87 | 356 | property Item dismissArea | 348 | property Item dismissArea |
88 | 357 | property bool grabDismissAreaEvents | 349 | property bool grabDismissAreaEvents |
89 | 350 | property PropertyAnimation fadingAnimation | ||
90 | 358 | function show() | 351 | function show() |
91 | 359 | function hide() | 352 | function hide() |
92 | 360 | function __closeIfHidden() | 353 | function __closeIfHidden() |
93 | 361 | 354 | ||
94 | === modified file 'modules/Ubuntu/Components/AnimatedItem.qml' | |||
95 | --- modules/Ubuntu/Components/AnimatedItem.qml 2014-04-23 08:50:20 +0000 | |||
96 | +++ modules/Ubuntu/Components/AnimatedItem.qml 2014-05-29 16:26:04 +0000 | |||
97 | @@ -30,45 +30,8 @@ | |||
98 | 30 | id: root | 30 | id: root |
99 | 31 | /*! | 31 | /*! |
100 | 32 | \preliminary | 32 | \preliminary |
101 | 33 | \deprecated | ||
102 | 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. |
103 | 34 | */ | 35 | */ |
104 | 35 | property bool onScreen: true | 36 | property bool onScreen: true |
105 | 36 | |||
106 | 37 | QtObject { | ||
107 | 38 | id: internal | ||
108 | 39 | property Flickable flickable | ||
109 | 40 | |||
110 | 41 | // returns whether the component is in the visible area of the flickable | ||
111 | 42 | function checkOnScreen() | ||
112 | 43 | { | ||
113 | 44 | var pos = root.mapToItem(flickable, 0, 0) | ||
114 | 45 | root.onScreen = (pos.y + root.height >= 0) && (pos.y <= internal.flickable.height) && | ||
115 | 46 | (pos.x + root.width >= 0) && (pos.x <= internal.flickable.width) | ||
116 | 47 | } | ||
117 | 48 | // lookup for a flickable parent | ||
118 | 49 | function updateFlickableParent() | ||
119 | 50 | { | ||
120 | 51 | var flickable = root.parent | ||
121 | 52 | while (flickable) { | ||
122 | 53 | if (flickable.hasOwnProperty("flicking") && flickable.hasOwnProperty("flickableDirection")) { | ||
123 | 54 | // non-interactive flickables must be skipped as those do not provide | ||
124 | 55 | // on-screen detection support | ||
125 | 56 | if (flickable.interactive) | ||
126 | 57 | break | ||
127 | 58 | } | ||
128 | 59 | flickable = flickable.parent | ||
129 | 60 | } | ||
130 | 61 | internal.flickable = flickable | ||
131 | 62 | } | ||
132 | 63 | } | ||
133 | 64 | |||
134 | 65 | Connections { | ||
135 | 66 | target: internal.flickable | ||
136 | 67 | |||
137 | 68 | onContentXChanged: internal.checkOnScreen() | ||
138 | 69 | onContentYChanged: internal.checkOnScreen() | ||
139 | 70 | } | ||
140 | 71 | |||
141 | 72 | Component.onCompleted: internal.updateFlickableParent() | ||
142 | 73 | onParentChanged: internal.updateFlickableParent() | ||
143 | 74 | } | 37 | } |
144 | 75 | 38 | ||
145 | === modified file 'modules/Ubuntu/Components/ListItems/Base.qml' | |||
146 | --- modules/Ubuntu/Components/ListItems/Base.qml 2014-04-28 19:24:56 +0000 | |||
147 | +++ modules/Ubuntu/Components/ListItems/Base.qml 2014-05-29 16:26:04 +0000 | |||
148 | @@ -159,7 +159,7 @@ | |||
149 | 159 | /*! | 159 | /*! |
150 | 160 | \internal | 160 | \internal |
151 | 161 | */ | 161 | */ |
153 | 162 | property alias children: middle.data | 162 | default property alias children: middle.data |
154 | 163 | Item { | 163 | Item { |
155 | 164 | id: middle | 164 | id: middle |
156 | 165 | property bool anchorToIconHelper: !__iconIsItem && iconHelper.source != "" | 165 | property bool anchorToIconHelper: !__iconIsItem && iconHelper.source != "" |
157 | 166 | 166 | ||
158 | === modified file 'modules/Ubuntu/Components/PageStack.qml' | |||
159 | --- modules/Ubuntu/Components/PageStack.qml 2014-05-13 09:09:35 +0000 | |||
160 | +++ modules/Ubuntu/Components/PageStack.qml 2014-05-29 16:26:04 +0000 | |||
161 | @@ -192,6 +192,7 @@ | |||
162 | 192 | */ | 192 | */ |
163 | 193 | default property alias data: inactiveNode.data | 193 | default property alias data: inactiveNode.data |
164 | 194 | PageTreeNode { | 194 | PageTreeNode { |
165 | 195 | anchors.fill: parent | ||
166 | 195 | id: inactiveNode | 196 | id: inactiveNode |
167 | 196 | active: false | 197 | active: false |
168 | 197 | } | 198 | } |
169 | 198 | 199 | ||
170 | === modified file 'modules/Ubuntu/Components/Pickers/DatePicker.qml' | |||
171 | --- modules/Ubuntu/Components/Pickers/DatePicker.qml 2014-05-07 10:42:31 +0000 | |||
172 | +++ modules/Ubuntu/Components/Pickers/DatePicker.qml 2014-05-29 16:26:04 +0000 | |||
173 | @@ -523,7 +523,8 @@ | |||
174 | 523 | function updatePickers() { | 523 | function updatePickers() { |
175 | 524 | if (completed) { | 524 | if (completed) { |
176 | 525 | // check mode flags first | 525 | // check mode flags first |
178 | 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) |
179 | 527 | var modes = datePicker.mode.match(/\w+/g); | ||
180 | 527 | 528 | ||
181 | 528 | showYearPicker = showMonthPicker = showDayPicker = | 529 | showYearPicker = showMonthPicker = showDayPicker = |
182 | 529 | showHoursPicker = showMinutesPicker = showSecondsPicker = false; | 530 | showHoursPicker = showMinutesPicker = showSecondsPicker = false; |
183 | @@ -607,7 +608,8 @@ | |||
184 | 607 | completed = false; | 608 | completed = false; |
185 | 608 | 609 | ||
186 | 609 | // use short format to exclude any extra characters | 610 | // use short format to exclude any extra characters |
188 | 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) |
189 | 612 | var format = datePicker.locale.dateFormat(Locale.ShortFormat).match(/\w+/g); | ||
190 | 611 | // loop through the format to decide the position of the tumbler | 613 | // loop through the format to decide the position of the tumbler |
191 | 612 | var formatIndex = 0; | 614 | var formatIndex = 0; |
192 | 613 | for (var i in format) { | 615 | for (var i in format) { |
193 | 614 | 616 | ||
194 | === modified file 'modules/Ubuntu/Components/plugin/i18n.cpp' | |||
195 | --- modules/Ubuntu/Components/plugin/i18n.cpp 2014-05-22 15:54:13 +0000 | |||
196 | +++ modules/Ubuntu/Components/plugin/i18n.cpp 2014-05-29 16:26:04 +0000 | |||
197 | @@ -103,13 +103,14 @@ | |||
198 | 103 | /* | 103 | /* |
199 | 104 | The default is /usr/share/locale if we don't set a folder | 104 | The default is /usr/share/locale if we don't set a folder |
200 | 105 | For click we use APP_DIR/share/locale | 105 | For click we use APP_DIR/share/locale |
202 | 106 | eg. /usr/share/click/preinstalled/com.example.foo/current/share/locale | 106 | e.g. /usr/share/click/preinstalled/com.example.foo/current/share/locale |
203 | 107 | */ | 107 | */ |
208 | 108 | QDir appDir(getenv("APP_DIR")); | 108 | QString appDir(getenv("APP_DIR")); |
209 | 109 | if (appDir.exists()) { | 109 | if (!QDir::isAbsolutePath (appDir)) { |
210 | 110 | QString localePath(appDir.filePath("share/locale")); | 110 | appDir = "/usr"; |
207 | 111 | C::bindtextdomain(domain.toUtf8(), localePath.toUtf8()); | ||
211 | 112 | } | 111 | } |
212 | 112 | QString localePath(QDir(appDir).filePath("share/locale")); | ||
213 | 113 | C::bindtextdomain(domain.toUtf8(), localePath.toUtf8()); | ||
214 | 113 | Q_EMIT domainChanged(); | 114 | Q_EMIT domainChanged(); |
215 | 114 | } | 115 | } |
216 | 115 | 116 | ||
217 | 116 | 117 | ||
218 | === modified file 'modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp' | |||
219 | --- modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp 2014-02-25 09:14:23 +0000 | |||
220 | +++ modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp 2014-05-29 16:26:04 +0000 | |||
221 | @@ -43,12 +43,15 @@ | |||
222 | 43 | * is the only way around the issue for now. */ | 43 | * is the only way around the issue for now. */ |
223 | 44 | std::string src_path(QUrl(id).path().toUtf8().data()); | 44 | std::string src_path(QUrl(id).path().toUtf8().data()); |
224 | 45 | std::string tgt_path; | 45 | std::string tgt_path; |
225 | 46 | const int xlarge_cutoff = 512; | ||
226 | 47 | const int large_cutoff = 256; | ||
227 | 48 | const int small_cutoff = 128; | ||
228 | 46 | try { | 49 | try { |
229 | 47 | ThumbnailSize desiredSize; | 50 | ThumbnailSize desiredSize; |
233 | 48 | const int large_cutoff = 256; | 51 | if(requestedSize.width() > xlarge_cutoff || requestedSize.height() > xlarge_cutoff) { |
231 | 49 | const int small_cutoff = 128; | ||
232 | 50 | if(requestedSize.width() > large_cutoff || requestedSize.height() > large_cutoff) { | ||
234 | 51 | desiredSize = TN_SIZE_ORIGINAL; | 52 | desiredSize = TN_SIZE_ORIGINAL; |
235 | 53 | } else if(requestedSize.width() > large_cutoff || requestedSize.height() > large_cutoff) { | ||
236 | 54 | desiredSize = TN_SIZE_XLARGE; | ||
237 | 52 | } else if(requestedSize.width() > small_cutoff || requestedSize.height() > small_cutoff) { | 55 | } else if(requestedSize.width() > small_cutoff || requestedSize.height() > small_cutoff) { |
238 | 53 | desiredSize = TN_SIZE_LARGE; | 56 | desiredSize = TN_SIZE_LARGE; |
239 | 54 | } else { | 57 | } else { |
240 | 55 | 58 | ||
241 | === modified file 'modules/Ubuntu/Components/qmldir' | |||
242 | --- modules/Ubuntu/Components/qmldir 2014-04-25 12:53:58 +0000 | |||
243 | +++ modules/Ubuntu/Components/qmldir 2014-05-29 16:26:04 +0000 | |||
244 | @@ -29,7 +29,7 @@ | |||
245 | 29 | internal PageTreeNode PageTreeNode.qml | 29 | internal PageTreeNode PageTreeNode.qml |
246 | 30 | PageStack 0.1 PageStack.qml | 30 | PageStack 0.1 PageStack.qml |
247 | 31 | internal Toolbar Toolbar.qml | 31 | internal Toolbar Toolbar.qml |
249 | 32 | Header 0.1 Header.qml | 32 | internal Header Header.qml |
250 | 33 | internal AnimatedItem AnimatedItem.qml | 33 | internal AnimatedItem AnimatedItem.qml |
251 | 34 | internal PageWrapper PageWrapper.qml | 34 | internal PageWrapper PageWrapper.qml |
252 | 35 | UbuntuShape 0.1 UbuntuShape.qml | 35 | UbuntuShape 0.1 UbuntuShape.qml |
253 | @@ -76,7 +76,6 @@ | |||
254 | 76 | OptionSelectorDelegate 1.0 OptionSelectorDelegate.qml | 76 | OptionSelectorDelegate 1.0 OptionSelectorDelegate.qml |
255 | 77 | Page 1.0 Page.qml | 77 | Page 1.0 Page.qml |
256 | 78 | PageStack 1.0 PageStack.qml | 78 | PageStack 1.0 PageStack.qml |
257 | 79 | Header 1.0 Header.qml | ||
258 | 80 | UbuntuShape 1.0 UbuntuShape.qml | 79 | UbuntuShape 1.0 UbuntuShape.qml |
259 | 81 | CrossFadeImage 1.0 CrossFadeImage.qml | 80 | CrossFadeImage 1.0 CrossFadeImage.qml |
260 | 82 | Icon 1.0 Icon.qml | 81 | Icon 1.0 Icon.qml |
261 | 83 | 82 | ||
262 | === modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_common.py' | |||
263 | --- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_common.py 2014-04-29 23:03:58 +0000 | |||
264 | +++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_common.py 2014-05-29 16:26:04 +0000 | |||
265 | @@ -111,3 +111,19 @@ | |||
266 | 111 | raise ToolkitException( | 111 | raise ToolkitException( |
267 | 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 " |
268 | 113 | "swiped into view.") | 113 | "swiped into view.") |
269 | 114 | |||
270 | 115 | def _get_top_container(self): | ||
271 | 116 | """Return the top-most container with a globalRect.""" | ||
272 | 117 | root = self.get_root_instance() | ||
273 | 118 | parent = self.get_parent() | ||
274 | 119 | top_container = None | ||
275 | 120 | while parent.id != root.id: | ||
276 | 121 | if hasattr(parent, 'globalRect'): | ||
277 | 122 | top_container = parent | ||
278 | 123 | |||
279 | 124 | parent = parent.get_parent() | ||
280 | 125 | |||
281 | 126 | if top_container is None: | ||
282 | 127 | raise ToolkitException('Could not find the top-most container.') | ||
283 | 128 | else: | ||
284 | 129 | return top_container | ||
285 | 114 | 130 | ||
286 | === modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py' | |||
287 | --- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2014-05-20 07:31:55 +0000 | |||
288 | +++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2014-05-29 16:26:04 +0000 | |||
289 | @@ -51,23 +51,6 @@ | |||
290 | 51 | containers = [self._get_top_container(), self] | 51 | containers = [self._get_top_container(), self] |
291 | 52 | return containers | 52 | return containers |
292 | 53 | 53 | ||
293 | 54 | def _get_top_container(self): | ||
294 | 55 | """Return the top-most container with a globalRect.""" | ||
295 | 56 | root = self.get_root_instance() | ||
296 | 57 | parent = self.get_parent() | ||
297 | 58 | top_container = None | ||
298 | 59 | while parent.id != root.id: | ||
299 | 60 | if hasattr(parent, 'globalRect'): | ||
300 | 61 | top_container = parent | ||
301 | 62 | |||
302 | 63 | parent = parent.get_parent() | ||
303 | 64 | |||
304 | 65 | if top_container is None: | ||
305 | 66 | raise _common.ToolkitException( | ||
306 | 67 | "Couldn't find the top-most container.") | ||
307 | 68 | else: | ||
308 | 69 | return top_container | ||
309 | 70 | |||
310 | 71 | def _is_child_visible(self, child, containers): | 54 | def _is_child_visible(self, child, containers): |
311 | 72 | """Check if the center of the child is visible. | 55 | """Check if the center of the child is visible. |
312 | 73 | 56 | ||
313 | 74 | 57 | ||
314 | === modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py' | |||
315 | --- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py 2014-05-13 12:43:31 +0000 | |||
316 | +++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py 2014-05-29 16:26:04 +0000 | |||
317 | @@ -21,7 +21,6 @@ | |||
318 | 21 | 21 | ||
319 | 22 | from ubuntuuitoolkit._custom_proxy_objects import ( | 22 | from ubuntuuitoolkit._custom_proxy_objects import ( |
320 | 23 | _common, | 23 | _common, |
321 | 24 | _mainview, | ||
322 | 25 | _tabbar | 24 | _tabbar |
323 | 26 | ) | 25 | ) |
324 | 27 | 26 | ||
325 | @@ -35,13 +34,6 @@ | |||
326 | 35 | class Header(_common.UbuntuUIToolkitCustomProxyObjectBase): | 34 | class Header(_common.UbuntuUIToolkitCustomProxyObjectBase): |
327 | 36 | """Header Autopilot emulator.""" | 35 | """Header Autopilot emulator.""" |
328 | 37 | 36 | ||
329 | 38 | def __init__(self, *args): | ||
330 | 39 | super(Header, self).__init__(*args) | ||
331 | 40 | # XXX we need a better way to keep reference to the main view. | ||
332 | 41 | # --elopio - 2014-02-26 | ||
333 | 42 | self.main_view = self.get_root_instance().select_single( | ||
334 | 43 | _mainview.MainView) | ||
335 | 44 | |||
336 | 45 | def _show_if_not_visible(self): | 37 | def _show_if_not_visible(self): |
337 | 46 | if not self._is_visible(): | 38 | if not self._is_visible(): |
338 | 47 | self._show() | 39 | self._show() |
339 | @@ -53,8 +45,9 @@ | |||
340 | 53 | # FIXME This will fail if the header is not linked to a flickable that | 45 | # FIXME This will fail if the header is not linked to a flickable that |
341 | 54 | # fills the main view. The header has a flickable property but it | 46 | # fills the main view. The header has a flickable property but it |
342 | 55 | # can't be read by autopilot. See bug http://pad.lv/1318829 | 47 | # can't be read by autopilot. See bug http://pad.lv/1318829 |
343 | 48 | top_container = self._get_top_container() | ||
344 | 56 | start_x = stop_x = (self.globalRect.x + self.globalRect.width) // 2 | 49 | start_x = stop_x = (self.globalRect.x + self.globalRect.width) // 2 |
346 | 57 | start_y = self.main_view.globalRect.y + 5 | 50 | start_y = top_container.globalRect.y + 5 |
347 | 58 | stop_y = start_y + self.globalRect.height | 51 | stop_y = start_y + self.globalRect.height |
348 | 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) |
349 | 60 | self.y.wait_for(0) | 53 | self.y.wait_for(0) |
350 | 61 | 54 | ||
351 | === modified file 'tests/autopilot/ubuntuuitoolkit/fixture_setup.py' | |||
352 | --- tests/autopilot/ubuntuuitoolkit/fixture_setup.py 2014-04-23 08:50:20 +0000 | |||
353 | +++ tests/autopilot/ubuntuuitoolkit/fixture_setup.py 2014-05-29 16:26:04 +0000 | |||
354 | @@ -16,6 +16,7 @@ | |||
355 | 16 | 16 | ||
356 | 17 | import copy | 17 | import copy |
357 | 18 | import os | 18 | import os |
358 | 19 | import shutil | ||
359 | 19 | import tempfile | 20 | import tempfile |
360 | 20 | 21 | ||
361 | 21 | import fixtures | 22 | import fixtures |
362 | @@ -118,3 +119,47 @@ | |||
363 | 118 | original_value) | 119 | original_value) |
364 | 119 | else: | 120 | else: |
365 | 120 | self.addCleanup(environment.unset_initctl_env_var, variable) | 121 | self.addCleanup(environment.unset_initctl_env_var, variable) |
366 | 122 | |||
367 | 123 | |||
368 | 124 | class FakeHome(fixtures.Fixture): | ||
369 | 125 | |||
370 | 126 | # We copy the Xauthority file to allow executions using XVFB. If it is not | ||
371 | 127 | # on the user's HOME directory, nothing will happen. | ||
372 | 128 | should_copy_xauthority_file = True | ||
373 | 129 | |||
374 | 130 | def __init__(self, directory=None): | ||
375 | 131 | super(FakeHome, self).__init__() | ||
376 | 132 | self.directory = directory | ||
377 | 133 | |||
378 | 134 | def setUp(self): | ||
379 | 135 | super(FakeHome, self).setUp() | ||
380 | 136 | self.directory = self._make_directory_if_not_specified() | ||
381 | 137 | if self.should_copy_xauthority_file: | ||
382 | 138 | self._copy_xauthority_file(self.directory) | ||
383 | 139 | # We patch both environment variables so it works on the desktop and on | ||
384 | 140 | # the phone. | ||
385 | 141 | self.useFixture( | ||
386 | 142 | InitctlEnvironmentVariable(HOME=self.directory)) | ||
387 | 143 | self.useFixture( | ||
388 | 144 | fixtures.EnvironmentVariable('HOME', newvalue=self.directory)) | ||
389 | 145 | |||
390 | 146 | def _make_directory_if_not_specified(self): | ||
391 | 147 | if self.directory is None: | ||
392 | 148 | parent_directory = os.path.join( | ||
393 | 149 | os.environ.get('HOME'), 'autopilot', 'fakeenv') | ||
394 | 150 | if not os.path.exists(parent_directory): | ||
395 | 151 | os.makedirs(parent_directory) | ||
396 | 152 | temp_dir_fixture = fixtures.TempDir(parent_directory) | ||
397 | 153 | self.useFixture(temp_dir_fixture) | ||
398 | 154 | return temp_dir_fixture.path | ||
399 | 155 | else: | ||
400 | 156 | return self.directory | ||
401 | 157 | |||
402 | 158 | def _copy_xauthority_file(self, directory): | ||
403 | 159 | """Copy the .Xauthority file if it exists in the user's home.""" | ||
404 | 160 | xauthority_file_path = os.path.join( | ||
405 | 161 | os.environ.get('HOME'), '.Xauthority') | ||
406 | 162 | if os.path.isfile(xauthority_file_path): | ||
407 | 163 | shutil.copyfile( | ||
408 | 164 | xauthority_file_path, | ||
409 | 165 | os.path.join(directory, '.Xauthority')) | ||
410 | 121 | 166 | ||
411 | === added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HeaderInCustomMainViewTestCase.qml' | |||
412 | --- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HeaderInCustomMainViewTestCase.qml 1970-01-01 00:00:00 +0000 | |||
413 | +++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HeaderInCustomMainViewTestCase.qml 2014-05-29 16:26:04 +0000 | |||
414 | @@ -0,0 +1,27 @@ | |||
415 | 1 | /* | ||
416 | 2 | * Copyright 2014Canonical Ltd. | ||
417 | 3 | * | ||
418 | 4 | * This program is free software; you can redistribute it and/or modify | ||
419 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
420 | 6 | * the Free Software Foundation; version 3. | ||
421 | 7 | * | ||
422 | 8 | * This program is distributed in the hope that it will be useful, | ||
423 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
424 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
425 | 11 | * GNU Lesser General Public License for more details. | ||
426 | 12 | * | ||
427 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
428 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
429 | 15 | */ | ||
430 | 16 | |||
431 | 17 | import QtQuick 2.0 | ||
432 | 18 | import Ubuntu.Components 1.1 | ||
433 | 19 | |||
434 | 20 | Item { | ||
435 | 21 | |||
436 | 22 | objectName: 'mainView' | ||
437 | 23 | |||
438 | 24 | Header { | ||
439 | 25 | title: 'test header' | ||
440 | 26 | } | ||
441 | 27 | } | ||
442 | 0 | 28 | ||
443 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py' | |||
444 | --- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py 2014-05-20 08:56:28 +0000 | |||
445 | +++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py 2014-05-29 16:26:04 +0000 | |||
446 | @@ -14,6 +14,8 @@ | |||
447 | 14 | # You should have received a copy of the GNU Lesser General Public License | 14 | # You should have received a copy of the GNU Lesser General Public License |
448 | 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/>. |
449 | 16 | 16 | ||
450 | 17 | import os | ||
451 | 18 | |||
452 | 17 | import ubuntuuitoolkit | 19 | import ubuntuuitoolkit |
453 | 18 | from ubuntuuitoolkit import tests | 20 | from ubuntuuitoolkit import tests |
454 | 19 | 21 | ||
455 | @@ -157,3 +159,24 @@ | |||
456 | 157 | 159 | ||
457 | 158 | # only three actions are visible | 160 | # only three actions are visible |
458 | 159 | self.assertEqual(overflow_button.visible, False) | 161 | self.assertEqual(overflow_button.visible, False) |
459 | 162 | |||
460 | 163 | |||
461 | 164 | class HeaderInCustomMainViewTestCase(tests.QMLFileAppTestCase): | ||
462 | 165 | |||
463 | 166 | path = os.path.abspath(__file__) | ||
464 | 167 | dir_path = os.path.dirname(path) | ||
465 | 168 | test_qml_file_path = os.path.join( | ||
466 | 169 | dir_path, 'test_header.HeaderInCustomMainViewTestCase.qml') | ||
467 | 170 | |||
468 | 171 | @property | ||
469 | 172 | def main_view(self): | ||
470 | 173 | return self.app.select_single('QQuickItem', objectName='mainView') | ||
471 | 174 | |||
472 | 175 | def test_get_header_from_custom_main_view(self): | ||
473 | 176 | """Test that we can get the header from a custom main view. | ||
474 | 177 | |||
475 | 178 | This prevents a regression of http://pad.lv/1324556. | ||
476 | 179 | |||
477 | 180 | """ | ||
478 | 181 | header = self.app.select_single(ubuntuuitoolkit.Header) | ||
479 | 182 | self.assertIsInstance(header, ubuntuuitoolkit.Header) | ||
480 | 160 | 183 | ||
481 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py' | |||
482 | --- tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py 2014-03-10 16:51:01 +0000 | |||
483 | +++ tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py 2014-05-29 16:26:04 +0000 | |||
484 | @@ -15,6 +15,7 @@ | |||
485 | 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/>. |
486 | 16 | 16 | ||
487 | 17 | import os | 17 | import os |
488 | 18 | import tempfile | ||
489 | 18 | 19 | ||
490 | 19 | try: | 20 | try: |
491 | 20 | # Python 3. | 21 | # Python 3. |
492 | @@ -24,7 +25,7 @@ | |||
493 | 24 | import mock | 25 | import mock |
494 | 25 | import testtools | 26 | import testtools |
495 | 26 | from autopilot import testcase as autopilot_testcase | 27 | from autopilot import testcase as autopilot_testcase |
497 | 27 | from testtools.matchers import Contains, Not, FileExists | 28 | from testtools.matchers import Contains, FileExists, Not |
498 | 28 | 29 | ||
499 | 29 | from ubuntuuitoolkit import base, environment, fixture_setup | 30 | from ubuntuuitoolkit import base, environment, fixture_setup |
500 | 30 | 31 | ||
501 | @@ -233,3 +234,73 @@ | |||
502 | 233 | self.assertEqual( | 234 | self.assertEqual( |
503 | 234 | 'original test value', | 235 | 'original test value', |
504 | 235 | environment.get_initctl_env_var('testenvvarforfixture')) | 236 | environment.get_initctl_env_var('testenvvarforfixture')) |
505 | 237 | |||
506 | 238 | |||
507 | 239 | class FakeHomeTestCase(testtools.TestCase): | ||
508 | 240 | |||
509 | 241 | def test_fake_home_fixture_patches_initctl_env_var(self): | ||
510 | 242 | original_home = environment.get_initctl_env_var('HOME') | ||
511 | 243 | fake_home = original_home + 'fake' | ||
512 | 244 | result = testtools.TestResult() | ||
513 | 245 | |||
514 | 246 | def inner_test(): | ||
515 | 247 | class TestWithFakeHome(testtools.TestCase): | ||
516 | 248 | def test_it(self): | ||
517 | 249 | fake_home_fixture = fixture_setup.FakeHome(fake_home) | ||
518 | 250 | fake_home_fixture.should_copy_xauthority_file = False | ||
519 | 251 | self.useFixture(fake_home_fixture) | ||
520 | 252 | self.assertEqual( | ||
521 | 253 | fake_home, environment.get_initctl_env_var('HOME')) | ||
522 | 254 | return TestWithFakeHome('test_it') | ||
523 | 255 | |||
524 | 256 | inner_test().run(result) | ||
525 | 257 | |||
526 | 258 | self.assertTrue( | ||
527 | 259 | result.wasSuccessful(), | ||
528 | 260 | 'Failed to fake the home: {}'.format(result.errors)) | ||
529 | 261 | self.assertEqual( | ||
530 | 262 | original_home, | ||
531 | 263 | environment.get_initctl_env_var('HOME')) | ||
532 | 264 | |||
533 | 265 | def test_fake_home_fixture_patches_env_var(self): | ||
534 | 266 | original_home = os.environ.get('HOME') | ||
535 | 267 | fake_home = tempfile.gettempdir() | ||
536 | 268 | result = testtools.TestResult() | ||
537 | 269 | |||
538 | 270 | def inner_test(): | ||
539 | 271 | class TestWithFakeHome(testtools.TestCase): | ||
540 | 272 | def test_it(self): | ||
541 | 273 | fake_home_fixture = fixture_setup.FakeHome(fake_home) | ||
542 | 274 | fake_home_fixture.should_copy_xauthority_file = False | ||
543 | 275 | self.useFixture(fake_home_fixture) | ||
544 | 276 | self.assertEqual( | ||
545 | 277 | fake_home, os.environ.get('HOME')) | ||
546 | 278 | return TestWithFakeHome('test_it') | ||
547 | 279 | |||
548 | 280 | inner_test().run(result) | ||
549 | 281 | |||
550 | 282 | self.assertTrue( | ||
551 | 283 | result.wasSuccessful(), | ||
552 | 284 | 'Failed to fake the home: {}'.format(result.failures)) | ||
553 | 285 | self.assertEqual(original_home, os.environ.get('HOME')) | ||
554 | 286 | |||
555 | 287 | def test_fake_home_fixture_must_create_default_directory(self): | ||
556 | 288 | original_home = os.environ.get('HOME') | ||
557 | 289 | self.useFixture(fixture_setup.FakeHome()) | ||
558 | 290 | |||
559 | 291 | home_parent_directory, _ = os.path.split(os.environ.get('HOME')) | ||
560 | 292 | self.assertEqual( | ||
561 | 293 | home_parent_directory, | ||
562 | 294 | os.path.join(original_home, 'autopilot', 'fakeenv')) | ||
563 | 295 | |||
564 | 296 | def test_fake_home_fixture_must_copy_xauthority(self): | ||
565 | 297 | # Fake the home first so we don't write the xauthority on the real | ||
566 | 298 | # home. | ||
567 | 299 | self.useFixture(fixture_setup.FakeHome()) | ||
568 | 300 | |||
569 | 301 | open(os.path.join(os.environ.get('HOME'), '.Xauthority')).close() | ||
570 | 302 | |||
571 | 303 | self.useFixture(fixture_setup.FakeHome()) | ||
572 | 304 | self.assertTrue( | ||
573 | 305 | os.path.exists( | ||
574 | 306 | os.path.join(os.environ.get('HOME'), '.Xauthority'))) | ||
575 | 236 | 307 | ||
576 | === modified file 'tests/qmlapicheck.py' | |||
577 | --- tests/qmlapicheck.py 2014-04-24 09:18:38 +0000 | |||
578 | +++ tests/qmlapicheck.py 2014-05-29 16:26:04 +0000 | |||
579 | @@ -130,10 +130,10 @@ | |||
580 | 130 | if '{' in line and '}' in line: | 130 | if '{' in line and '}' in line: |
581 | 131 | if filetype == 'qmltypes' and not in_builtin_type: | 131 | if filetype == 'qmltypes' and not in_builtin_type: |
582 | 132 | print(' ' + line.strip()) | 132 | print(' ' + line.strip()) |
584 | 133 | continue | 133 | continue |
585 | 134 | 134 | ||
586 | 135 | # End of function/ signal/ Item block | 135 | # End of function/ signal/ Item block |
588 | 136 | if '}' in line: | 136 | if '}' in line and not '{' in line: |
589 | 137 | in_block -= 1 | 137 | in_block -= 1 |
590 | 138 | block_meta = {} | 138 | block_meta = {} |
591 | 139 | if in_block == 1 and in_builtin_type: | 139 | if in_block == 1 and in_builtin_type: |
592 | @@ -143,7 +143,7 @@ | |||
593 | 143 | # Only root "Item {" is inspected for QML, otherwise all children | 143 | # Only root "Item {" is inspected for QML, otherwise all children |
594 | 144 | if in_block == 1 or filetype == 'qmltypes': | 144 | if in_block == 1 or filetype == 'qmltypes': |
595 | 145 | # Left hand side specifies a keyword, a type and a variable name | 145 | # Left hand side specifies a keyword, a type and a variable name |
597 | 146 | declaration = line.split(':')[0] | 146 | declaration = line.split(':', 1)[0] |
598 | 147 | words = declaration.strip().split(' ') | 147 | words = declaration.strip().split(' ') |
599 | 148 | # Skip types with prefixes considered builtin | 148 | # Skip types with prefixes considered builtin |
600 | 149 | if filetype == 'qmltypes' and words[0] == 'name': | 149 | if filetype == 'qmltypes' and words[0] == 'name': |
601 | @@ -175,7 +175,8 @@ | |||
602 | 175 | for word in words: | 175 | for word in words: |
603 | 176 | if word in keywords: | 176 | if word in keywords: |
604 | 177 | if filetype == 'qml': | 177 | if filetype == 'qml': |
606 | 178 | signature = declaration.split('{')[0].strip() | 178 | separator = '{' if 'function' in declaration else ':' |
607 | 179 | signature = declaration.split(separator, 1)[0].strip() | ||
608 | 179 | if 'alias' in line: | 180 | if 'alias' in line: |
609 | 180 | no_mods = signature | 181 | no_mods = signature |
610 | 181 | for mod in ['readonly', 'default']: | 182 | for mod in ['readonly', 'default']: |
611 | @@ -198,7 +199,7 @@ | |||
612 | 198 | break | 199 | break |
613 | 199 | 200 | ||
614 | 200 | # Start of function/ signal/ Item block | 201 | # Start of function/ signal/ Item block |
616 | 201 | if '{' in line: | 202 | if '{' in line and not '}' in line: |
617 | 202 | in_block += 1 | 203 | in_block += 1 |
618 | 203 | block_meta = {} | 204 | block_meta = {} |
619 | 204 | # The parent type can affect API | 205 | # The parent type can affect API |