Merge lp:~tpeeters/ubuntu-ui-toolkit/headContentsWidth into lp:ubuntu-ui-toolkit/staging

Proposed by Tim Peeters on 2015-01-13
Status: Merged
Approved by: Zsombor Egri on 2015-01-14
Approved revision: 1379
Merged at revision: 1377
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/headContentsWidth
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 115 lines (+100/-0)
2 files modified
modules/Ubuntu/Components/Themes/Ambiance/PageHeadStyle.qml (+3/-0)
tests/unit_x11/tst_components/tst_header_contents_width.qml (+97/-0)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/headContentsWidth
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-01-14
Zsombor Egri (community) 2015-01-13 Approve on 2015-01-14
Andrew Hayzen (community) Approve on 2015-01-13
Review via email: mp+246322@code.launchpad.net

Commit Message

Fix incorrect header contents width when navigating back from a page with a lot of actions.

To post a comment you must log in.
Andrew Hayzen (ahayzen) wrote :

This fixes the issue detailed in the bug, thanks :)

review: Approve
Zsombor Egri (zsombi) wrote :

Too simple! You should make it more complicated ;)

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/PageHeadStyle.qml'
2--- modules/Ubuntu/Components/Themes/Ambiance/PageHeadStyle.qml 2014-11-25 15:20:11 +0000
3+++ modules/Ubuntu/Components/Themes/Ambiance/PageHeadStyle.qml 2015-01-13 15:54:13 +0000
4@@ -512,6 +512,9 @@
5 id: actionsOverflowButton
6 objectName: "actions_overflow_button"
7 visible: numberOfSlots.requested > numberOfSlots.right
8+ // Ensure resetting of X when this button is not visible to avoid
9+ // miscalculation of actionsContainer.width. Fixes bug #1408481.
10+ onVisibleChanged: if (!visible) x = 0
11 iconName: "contextual-menu"
12 color: headerStyle.buttonColor
13 height: actionsContainer.height
14
15=== added file 'tests/unit_x11/tst_components/tst_header_contents_width.qml'
16--- tests/unit_x11/tst_components/tst_header_contents_width.qml 1970-01-01 00:00:00 +0000
17+++ tests/unit_x11/tst_components/tst_header_contents_width.qml 2015-01-13 15:54:13 +0000
18@@ -0,0 +1,97 @@
19+/*
20+ * Copyright 2015 Canonical Ltd.
21+ *
22+ * This program is free software; you can redistribute it and/or modify
23+ * it under the terms of the GNU Lesser General Public License as published by
24+ * the Free Software Foundation; version 3.
25+ *
26+ * This program is distributed in the hope that it will be useful,
27+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
28+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29+ * GNU Lesser General Public License for more details.
30+ *
31+ * You should have received a copy of the GNU Lesser General Public License
32+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
33+ */
34+
35+import QtQuick 2.2
36+import Ubuntu.Test 1.0
37+import Ubuntu.Components 1.1
38+
39+Item {
40+ width: units.gu(50)
41+ height: units.gu(80)
42+
43+ MainView {
44+ id: mainView
45+ anchors.fill: parent
46+ useDeprecatedToolbar: false
47+
48+ Tabs {
49+ id: tabs
50+ Tab {
51+ title: "Search"
52+ page: Page {
53+ head.contents: TextField {
54+ id: searchField
55+ anchors {
56+ left: parent ? parent.left : undefined
57+ right: parent ? parent.right : undefined
58+ rightMargin: units.gu(1)
59+ }
60+ placeholderText: i18n.tr("Search...")
61+ }
62+ }
63+ }
64+ Tab {
65+ title: "Actions"
66+ page: Page {
67+ head.actions: [
68+ Action {
69+ iconName: "add"
70+ },
71+ Action {
72+ iconName: "clear"
73+ },
74+ Action {
75+ iconName: "delete"
76+ }
77+ ]
78+ }
79+ }
80+ }
81+ }
82+
83+ UbuntuTestCase {
84+ name: "HeaderSelectionPreset"
85+ when: windowShown
86+ id: testCase
87+
88+ property var head_style
89+
90+ function wait_for_animation() {
91+ tryCompareFunction(function(){return testCase.head_style.animating}, false);
92+ }
93+ function initTestCase() {
94+ testCase.head_style = findChild(mainView, "PageHeadStyle");
95+ testCase.wait_for_animation();
96+ }
97+
98+ function test_header_contents_width_bug1408481() {
99+ var initialWidth = searchField.width;
100+ testCase.verify(initialWidth > 0, "Initial width has a positive value.");
101+ // Select the tab that has more actions.
102+ tabs.selectedTabIndex = 1;
103+ testCase.wait_for_animation();
104+ // Now less space is available for the header contents, so that the action buttons fit.
105+ testCase.verify(searchField.width < initialWidth, "Contents width is reduced.");
106+ // Without this wait(), the test does not reproduce bug 1408481.
107+ wait(100);
108+ // Select the first tab again:
109+ tabs.selectedTabIndex = 0;
110+ testCase.wait_for_animation();
111+ // Without actions in tab one, the full width is available again for contents
112+ testCase.verify(searchField.width === initialWidth, "Contents width is reset.");
113+ }
114+ }
115+}

Subscribers

People subscribed via source and target branches