~ubuntu-branches/ubuntu/utopic/ubuntu-ui-toolkit/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/unit_x11/tst_components/tst_headActions.qml

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Michał Sawicz, Tim Peeters, Christian Dywan, Florian Boucault, Albert Astals, Martin Pitt, Omer Akram
  • Date: 2014-07-31 11:12:39 UTC
  • mfrom: (1.1.98)
  • Revision ID: package-import@ubuntu.com-20140731111239-cw0jqjr78g5lip9x
Tags: 0.1.51+14.10.20140731.1-0ubuntu1
[ Michał Sawicz ]
* Add "source" property to the Icon component.

[ Tim Peeters ]
* Reduce header height by 0.5 grid units.
* Visual updates: colors, icon sizes, semi-transparent buttons.
* Allow app developers to disable the back button by setting an 
  invisible back action for the page.
* Fix icon loading problems. 
  Fixes: https://bugs.launchpad.net/bugs/1349769
* New visuals for sections in the header divider.

[ Christian Dywan ] 
* Implement optional strokeColor in AbstractButton. 
  Fixes: https://bugs.launchpad.net/bugs/1332580

[ Florian Boucault]
* StateSaver: also save the type of each property along with its 
  value so that we can convert them back to the right type during
  state restoration. This makes some problematic cases such as 
  enumeration to work.

[ Albert Astals ]
* Placeholder is also shown on focus

[ Martin Pitt ]
* Fix installability of ubuntu-ui-toolkit-examples with 
  qtdeclarative5-ubuntu-ui-toolkit-plugin-gles. 
  Fixes: https://bugs.launchpad.net/bugs/1346650

[ Omer Akram ]
* Add helper methods for TextArea. There is a separate 'clear' 
  method because the one that exists in TextField class checks
  the property hasClearButton which TextArea does not have.
  Fixes: https://bugs.launchpad.net/bugs/1327354

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2014 Canonical 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
 
 
17
import QtQuick 2.2
 
18
import Ubuntu.Test 1.0
 
19
import Ubuntu.Components 1.1
 
20
 
 
21
// NOTE: Other parts of the page head API are tested with autopilot in
 
22
// ubuntuuitoolkit.tests.components.test_header
 
23
 
 
24
Item {
 
25
    width: units.gu(50)
 
26
    height: units.gu(80)
 
27
 
 
28
    MainView {
 
29
        id: mainView
 
30
        anchors.fill: parent
 
31
        useDeprecatedToolbar: false
 
32
 
 
33
        PageStack {
 
34
            id: pageStack
 
35
            Page {
 
36
                id: page1
 
37
                title: "First page"
 
38
            }
 
39
            Page {
 
40
                id: page2
 
41
                title: "Second page"
 
42
 
 
43
                Action {
 
44
                    id: customBackAction
 
45
                    iconName: "search"
 
46
                    text: "Search"
 
47
                }
 
48
                Action {
 
49
                    id: invisibleAction
 
50
                    visible: false
 
51
                }
 
52
            }
 
53
        }
 
54
        Component.onCompleted: {
 
55
            pageStack.push(page1);
 
56
        }
 
57
    }
 
58
 
 
59
    UbuntuTestCase {
 
60
        name: "HeaderBackButton"
 
61
        when: windowShown
 
62
        id: testCase
 
63
 
 
64
        property var app_header
 
65
        property var back_button
 
66
        property var custom_back_button
 
67
 
 
68
        function initTestCase() {
 
69
            testCase.app_header = findChild(mainView, "MainView_Header");
 
70
            testCase.back_button = findChild(app_header, "backButton");
 
71
            testCase.custom_back_button = findChild(app_header, "customBackButton");
 
72
 
 
73
            compare(page2.head.backAction, null, "Back action set by default.");
 
74
            compare(back_button.visible, false, "Back button visible with only 1 page on the stack.");
 
75
            compare(custom_back_button.visible, false, "Custom back button visible without custom back action.")
 
76
        }
 
77
 
 
78
        function test_default_back_button() {
 
79
            pageStack.push(page2);
 
80
            compare(back_button.visible, true, "Back button not visible with 2 pages on stack.");
 
81
            compare(custom_back_button.visible, false, "Showing custom back button without custom back action.");
 
82
            pageStack.pop();
 
83
        }
 
84
 
 
85
        function test_custom_back_button() {
 
86
            page2.head.backAction = customBackAction;
 
87
            pageStack.push(page2);
 
88
            compare(back_button.visible, false, "Default back button visible with custom back action.");
 
89
            compare(custom_back_button.visible, true, "Custom back button invisible with back action.");
 
90
            pageStack.pop();
 
91
            page2.head.backAction = null;
 
92
        }
 
93
 
 
94
        function test_no_back_button() {
 
95
            page2.head.backAction = invisibleAction;
 
96
            pageStack.push(page2);
 
97
            compare(back_button.visible, false, "Default back button visible with invisible custom back action.");
 
98
            compare(custom_back_button.visible, false, "Custom back button visible with invisible custom back action.");
 
99
            pageStack.pop();
 
100
            page2.head.backAction = null;
 
101
        }
 
102
    }
 
103
}