~ci-train-bot/unity8/unity8-ubuntu-zesty-2167

« back to all changes in this revision

Viewing changes to tests/qmltests/Components/tst_Tile.qml

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2013 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
 */
 
16
 
 
17
import QtQuick 2.0
 
18
import QtTest 1.0
 
19
import ".."
 
20
import "../../../Components"
 
21
import Ubuntu.Components 0.1
 
22
import Unity.Test 0.1 as UT
 
23
 
 
24
Item {
 
25
    id: root
 
26
    width: units.gu(20)
 
27
    height: units.gu(24)
 
28
 
 
29
    property bool helper: false
 
30
 
 
31
    Tile {
 
32
        id: tile
 
33
        anchors.fill: parent
 
34
        source: "../../../graphics/clock@18.png"
 
35
        text: "Testing rocks, debugging sucks!"
 
36
        imageWidth: width
 
37
        imageHeight: width
 
38
    }
 
39
 
 
40
    UT.UnityTestCase {
 
41
        name: "Tile"
 
42
        when: windowShown
 
43
 
 
44
        function test_click_highlight() {
 
45
            var border = findChild(tile, "borderPressed")
 
46
            compare(border.opacity, 0)
 
47
            mousePress(root, 1, 1)
 
48
            tryCompare(border, "opacity", 1)
 
49
            mouseRelease(root, 1, 1)
 
50
            tryCompare(border, "opacity", 0)
 
51
        }
 
52
 
 
53
        function test_resize_image_data() {
 
54
            return [
 
55
                {tag: "small", w: 1, h: 1, click: true},
 
56
                {tag: "large", w: units.gu(20), h: units.gu(20), click: true},
 
57
                // If image is too large to fit, text will be moved outside of the scene and click should fail
 
58
                {tag: "too large", w: units.gu(40), h: units.gu(40), click: false}
 
59
            ]
 
60
        }
 
61
 
 
62
        function test_resize_image(data) {
 
63
            tile.imageWidth = data.w
 
64
            tile.imageHeight = data.h
 
65
            var label = findChild(tile, "label")
 
66
            mousePress(label, 1, 1)
 
67
            tryCompare(tile, "pressed", data.click)
 
68
            mouseRelease(label, 1, 1)
 
69
        }
 
70
    }
 
71
}