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 127 128
|
/*
* Copyright 2014 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.0
import QtTest 1.0
import Lomiri.Test 1.0
import Lomiri.Components 1.1
import Lomiri.Components.ListItems 1.0
MainView {
width: units.gu(40)
height: units.gu(71)
Column {
anchors {
fill: parent
margins: units.gu(1)
}
LomiriListView {
id: listView
width: parent.width
height: units.gu(20)
clip: true
model: 10
delegate: Standard {
control: Slider {
objectName: "testSlider" + index
}
}
}
LomiriListView {
id: listView2
width: parent.width
height: units.gu(20)
clip: true
model: 10
delegate: Slider {
objectName: "testSlider" + index
}
}
Flickable {
id: flickable
width: parent.width
height: units.gu(20)
clip: true
contentHeight: column.height
Column {
id: column
width: parent.width
height: childrenRect.height
Repeater {
model: 10
Standard {
control: Slider {
objectName: "testSlider" + index
}
}
}
}
}
Flickable {
id: flickable2
width: parent.width
height: units.gu(20)
clip: true
contentHeight: column2.height
Column {
id: column2
width: parent.width
height: childrenRect.height
Repeater {
model: 10
Slider {
objectName: "testSlider" + index
}
}
}
}
}
LomiriTestCase {
name: "SliderAPI"
when: windowShown
SignalSpy {
id: flickSpy
signalName: "onMovementStarted"
}
function cleanup() {
flickSpy.target = null;
flickSpy.clear();
}
function test_slider_blocks_flickable_data() {
return [
{tag: "ListView with Slider in ListItem", flickable: listView},
{tag: "ListView with Slider alone", flickable: listView2},
{tag: "Flickable with Column of Slider in ListItem", flickable: flickable},
{tag: "Flickable with Column of Slider alone", flickable: flickable2},
];
}
function test_slider_blocks_flickable(data) {
flickSpy.target = data.flickable;
var slider = findChild(data.flickable, "testSlider1");
verify(slider, "cannot find test slider in " + data.tag);
var sliderPos = slider.mapToItem(data.flickable, units.gu(10), 0);
mouseDrag(data.flickable, sliderPos.x, sliderPos.y, units.gu(20), units.gu(20));
waitForRendering(data.flickable, 200);
compare(flickSpy.count, 0, "The Flickable should not move while Slider is active.");
compare(data.flickable.interactive, true, "The Flickable aint got back to interactive mode.");
}
}
}
|