~zsombi/ubuntu-ui-toolkit/ima-enhancement

« back to all changes in this revision

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

Add UbuntuTestCase.waitForHeaderAnimation().

Approved by PS Jenkins bot, Christian Dywan.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2014 Canonical Ltd.
 
2
 * Copyright 2014-2015 Canonical Ltd.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU Lesser General Public License as published by
14
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
15
 */
16
16
 
17
 
import QtQuick 2.2
 
17
import QtQuick 2.4
18
18
import Ubuntu.Test 1.0
19
 
import Ubuntu.Components 1.1
 
19
import Ubuntu.Components 1.2
20
20
 
21
21
// NOTE: Other parts of the page head API are tested with autopilot in
22
22
// ubuntuuitoolkit.tests.components.test_header
28
28
    MainView {
29
29
        id: mainView
30
30
        anchors.fill: parent
31
 
        useDeprecatedToolbar: false
32
31
 
33
32
        PageStack {
34
33
            id: pageStack
61
60
        when: windowShown
62
61
        id: testCase
63
62
 
64
 
        property var app_header
65
63
        property var back_button
66
64
        property var custom_back_button
67
 
        property var head_style
68
65
 
69
66
        function initTestCase() {
70
 
            testCase.app_header = findChild(mainView, "MainView_Header");
 
67
            var app_header = findChild(mainView, "MainView_Header");
71
68
            testCase.back_button = findChild(app_header, "backButton");
72
69
            testCase.custom_back_button = findChild(app_header, "customBackButton");
73
 
            testCase.head_style = findChild(app_header, "PageHeadStyle");
74
70
 
75
 
            wait_for_animation();
 
71
            waitForHeaderAnimation(mainView);
76
72
            compare(page2.head.backAction, null, "Back action set by default.");
77
73
            compare(back_button.visible, false, "Back button visible with only 1 page on the stack.");
78
74
            compare(custom_back_button.visible, false, "Custom back button visible without custom back action.")
79
75
        }
80
76
 
81
 
        function wait_for_animation() {
82
 
            tryCompareFunction(function(){return testCase.head_style.animating}, false);
83
 
        }
84
 
 
85
77
        function test_default_back_button() {
86
78
            pageStack.push(page2);
87
 
            wait_for_animation();
 
79
            waitForHeaderAnimation(mainView);
88
80
            compare(back_button.visible, true, "Back button not visible with 2 pages on stack.");
89
81
            compare(custom_back_button.visible, false, "Showing custom back button without custom back action.");
90
82
            pageStack.pop();
91
 
            wait_for_animation();
 
83
            waitForHeaderAnimation(mainView);
92
84
        }
93
85
 
94
86
        function test_custom_back_button() {
95
87
            page2.head.backAction = customBackAction;
96
88
            pageStack.push(page2);
97
 
            wait_for_animation();
 
89
            waitForHeaderAnimation(mainView);
98
90
            compare(back_button.visible, false, "Default back button visible with custom back action.");
99
91
            compare(custom_back_button.visible, true, "Custom back button invisible with back action.");
100
92
            pageStack.pop();
101
 
            wait_for_animation();
 
93
            waitForHeaderAnimation(mainView);
102
94
            page2.head.backAction = null;
103
95
        }
104
96
 
105
97
        function test_no_back_button() {
106
98
            page2.head.backAction = invisibleAction;
107
99
            pageStack.push(page2);
108
 
            wait_for_animation();
 
100
            waitForHeaderAnimation(mainView);
109
101
            compare(back_button.visible, false, "Default back button visible with invisible custom back action.");
110
102
            compare(custom_back_button.visible, false, "Custom back button visible with invisible custom back action.");
111
103
            pageStack.pop();
112
 
            wait_for_animation();
 
104
            waitForHeaderAnimation(mainView);
113
105
            page2.head.backAction = null;
114
106
        }
115
107
    }