14
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
import Ubuntu.Test 1.0
19
import Ubuntu.Components 1.1
19
import Ubuntu.Components 1.2
21
21
// NOTE: Other parts of the page head API are tested with autopilot in
22
22
// ubuntuuitoolkit.tests.components.test_header
64
property var app_header
65
63
property var back_button
66
64
property var custom_back_button
67
property var head_style
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");
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.")
81
function wait_for_animation() {
82
tryCompareFunction(function(){return testCase.head_style.animating}, false);
85
77
function test_default_back_button() {
86
78
pageStack.push(page2);
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.");
83
waitForHeaderAnimation(mainView);
94
86
function test_custom_back_button() {
95
87
page2.head.backAction = customBackAction;
96
88
pageStack.push(page2);
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.");
101
wait_for_animation();
93
waitForHeaderAnimation(mainView);
102
94
page2.head.backAction = null;
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.");
112
wait_for_animation();
104
waitForHeaderAnimation(mainView);
113
105
page2.head.backAction = null;