1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
/*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.4
import Lomiri.Test 1.3
import Lomiri.Components 1.3
Item {
width: 400
height: 600
Flickable {
id: testFlickable
}
MainView {
anchors.fill: parent
id: mainView
Page {
id: page
Flickable {
id: pageFlickable
anchors.fill: parent
contentHeight: column.height
Column {
id: column
Repeater {
model: 100
Label {
text: "line "+index
}
}
}
}
}
}
LomiriTestCase {
id: testCase
name: "Page13API"
when: windowShown
function init() {
compare(page.title, "", "Page title is set by default.");
compare(page.active, true, "Page is inactive by default.");
compare(page.pageStack, null, "Page has a PageStack by default.");
}
function test_title() {
var newTitle = "Hello World!";
page.title = newTitle;
compare(page.title, newTitle, "Could not set page title.");
page.title = "";
compare(page.title, "", "Could not unset page title.");
}
function test_header_title() {
var newTitle = "Hello header!";
page.title = newTitle;
var header = mainView.__propagated.header;
compare(header.title, newTitle, "Header title does not match active page title.");
page.title = "";
}
function test_flickable_bug1200642_bug1192591() {
var header = page.__propagated.header;
compare(page.flickable, pageFlickable,
"Flickable is not correctly detected.");
compare(header.flickable, pageFlickable,
"Header flickable is not correctly set.");
page.flickable = testFlickable;
compare(page.flickable, testFlickable, "Flickable could not be set.");
compare(header.flickable, testFlickable,
"Header flickable was not updated correctly.");
page.flickable = null;
compare(page.flickable, null, "Flickable cannot be unset.");
compare(header.flickable, null,
"Header flickable was not correctly unset.");
}
function test_flickableY_bug1201452() {
var header = findChild(mainView, "MainView_Header");
var headerHeight = header.height;
var flickableY = 150;
page.flickable.contentY = flickableY;
compare(page.flickable.contentY, flickableY,
"Flickable.contentY could not be set.");
compare(page.flickable.topMargin, headerHeight,
"topMargin of the flickable does not equal header height.");
page.head.locked = true;
page.head.visible = false;
waitForHeaderAnimation(mainView);
compare(page.flickable.topMargin, 0,
"topMargin is not 0 when header is locked hidden.");
compare(page.flickable.contentY, flickableY + headerHeight,
"contentY was not updated properly when header was hidden.");
page.head.locked = false;
page.head.visible = true;
waitForHeaderAnimation(mainView);
compare(page.flickable.contentY, flickableY,
"Hiding and showing header changes flickable.contentY.");
compare(page.flickable.topMargin, headerHeight,
"topMargin was not updated when header became visible.");
}
}
}
|