on bbbdccd help sign in
unity8/tests/qmltests/Components/tst_ModeSwitchWarningDialog.qml
75 lines 2.4 kB history raw
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 */
17import QtQuick 2.4
18import QtTest 1.0
19import "../../../qml/Components"
20import Unity.Test 0.1 as UT
21import Ubuntu.Components 1.3
22import Ubuntu.Components.Popups 1.3
24Rectangle {
25 id: root
26 width: units.gu(40)
27 height: units.gu(70)
28 color: "lightgrey"
30 ListModel {
31 id: fakeModel
32 ListElement { icon: "../../tests/graphics/applicationIcons/facebook.png"; name: "Facebook" }
33 ListElement { icon: "../../tests/graphics/applicationIcons/gmail.png"; name: "Mail" }
34 }
36 function openWarning() {
37 return PopupUtils.open(Qt.resolvedUrl("../../../qml/Components/ModeSwitchWarningDialog.qml"), root, { model: fakeModel });
38 }
40 Button {
41 anchors.centerIn: parent
42 text: "trigger warning"
43 onClicked: {
44 openWarning();
45 }
46 }
48 SignalSpy {
49 id: spy
50 signalName: "forceClose"
51 }
53 UT.UnityTestCase {
54 name: "ModeSwitchWarning"
55 when: windowShown
57 function test_labelChangesOnClick() {
58 var popup = openWarning();
59 var reconnectLabel = findChild(popup, "reconnectLabel");
60 tryCompare(reconnectLabel, "text", reconnectLabel.notClickedText)
61 mouseClick(reconnectLabel, reconnectLabel.width / 2, reconnectLabel.height / 2)
62 tryCompare(reconnectLabel, "text", reconnectLabel.clickedText)
63 }
65 function test_closeButtonEmitsSignal() {
66 var popup = openWarning();
67 spy.target = popup;
68 spy.clear();
69 var closeButton = findChild(popup, "forceCloseButton");
70 mouseClick(closeButton, closeButton.width / 2, closeButton.height / 2)
71 tryCompare(spy, "count", 1)
73 }
74 }