2
* Copyright 2013 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU 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 General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
import "../../../Dash"
22
import Ubuntu.Components 0.1
23
import Unity.Test 0.1 as UT
38
onItemSelected: currentIndex = index
47
signalName: "itemSelected"
55
property alias model: dashBar.model
56
property alias currentIndex: dashBar.currentIndex
58
readonly property alias lineHeight: dashBar.lineHeight
59
readonly property alias itemSize: dashBar.itemSize
60
readonly property alias iconSize: dashBar.iconSize
61
readonly property var panel: findChild(dashBar, "panel");
63
function initTestCase() {
67
function waitForAnimationToEnd() {
68
compare(panel.animating, true) // check the animation started
69
tryCompare(panel, "animating", false) // wait till the animation ends
72
function closePanel() {
73
dashBar.finishNavigation()
74
waitForAnimationToEnd()
75
tryCompare(panel, "opened", false)
78
function openPanel() {
79
dashBar.startNavigation()
80
waitForAnimationToEnd()
81
tryCompare(panel, "opened", true)
84
function test_navigationAndHide() {
89
function test_itemSelected() {
92
var row = findChild(dashBar, "row");
93
tryCompareFunction(function(){return row.width > 0;}, true);
94
for (var i = 0; i < model.rowCount(); i++) {
95
// coordinate x in the middle of item with index 'i'
96
var x = row.x + (row.width / model.rowCount()) * i + itemSize / 2
98
// FIXME workaround for a bug in SignalSpy
101
// (item, x, y, button, modifiers, delay)
102
mouseClick(panel, x, row.height / 2, Qt.LeftButton, Qt.NoModifier, 0)
103
compare(signalSpy.count > 0, true, "signal itemSelected not triggered")
104
compare(signalSpy.signalArguments[0][0], i, "signal itemSelected emitted unexpected index");
105
tryCompare(dashBar, "currentIndex", i);