2
* Copyright (C) 2015 Canonical Ltd.
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.
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.
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/>.
18
import Ubuntu.Components 1.3
19
import Ubuntu.Test 1.0
31
objectName: "my_rectangle"
38
color: UbuntuColors.red
43
objectName: "my_page_header"
45
trailingActionBar.actions: [
60
title: "Page with header"
68
topMargin: units.gu(10)
69
leftMargin: units.gu(10)
70
rightMargin: units.gu(10)
72
height: childrenRect.height
80
onClicked: page.header = myPageHeader
88
onClicked: page.header = myRectangle
96
onClicked: page.header = null
102
name: "PageWithHeader"
106
property var appHeader;
107
function initTestCase() {
108
var pageHeader = findChild(page, "my_page_header");
109
compare(pageHeader, myPageHeader,
110
"My PageHeader not initialized with Page as its parent.");
111
appHeader = findChild(root, "MainView_Header");
112
compare(appHeader.visible, false,
113
"AppHeader is not hidden initially when Page.header is set.");
117
page.header = myPageHeader;
118
var pageHeader = findChild(page, "my_page_header");
119
compare(pageHeader, myPageHeader,
120
"PageHeader is not correctly re-parented to the Page when setting Page.header.");
121
compare(myPageHeader.visible, true,
122
"PageHeader is not visible after being re-parented to the Page.");
123
compare(appHeader.visible, false,
124
"AppHeader is not hidden when Page.header is set.");
127
function test_page_with_no_header() {
129
compare(myPageHeader.parent, invisible,
130
"Header parent is not correctly reverted when unsetting Page.header.");
131
compare(myPageHeader.visible, false,
132
"My PageHeader is still visible after re-parenting it to an invisible Item.");
133
compare(appHeader.visible, true,
134
"AppHeader does not become visible when Page.header is null.");
137
function test_page_with_alternative_header() {
138
page.header = myRectangle;
139
compare(myPageHeader.parent, invisible,
140
"Header parent not correctly reverted when setting a different Page.header.");
141
compare(myRectangle.parent, page,
142
"Rectangle parent is not correctly set to page after setting it as Page.header.");
143
compare(appHeader.visible, false,
144
"Setting a different Page.header Item shows the AppHeader.");
146
page.header = myPageHeader;
147
compare(myRectangle.parent, invisible,
148
"Rectangle parent is not correctly reverted after unsetting it as Page.header.");
149
// myPageHeader parent is checked in cleanup().