~mimecar/curso-ubuntu-phone-touch/trunk

« back to all changes in this revision

Viewing changes to HolaMundo/HolaMundo/tests/unit/tst_main.qml

  • Committer: Miguel Menéndez
  • Date: 2016-08-06 18:13:47 UTC
  • Revision ID: mimecar@innerzaurus.com-20160806181347-rjip9phmicolbfjt
Proyecto de introducción al curso de programación de Ubuntu Touch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.4
 
2
import QtTest 1.0
 
3
import Ubuntu.Test 1.0
 
4
import "../../"
 
5
// See more details at https://developer.ubuntu.com/api/qml/sdk-14.10/Ubuntu.Test.UbuntuTestCase
 
6
 
 
7
// Execute these tests with:
 
8
//   qmltestrunner
 
9
 
 
10
Item {
 
11
 
 
12
    width: units.gu(100)
 
13
    height: units.gu(75)
 
14
 
 
15
    // The objects
 
16
    Main {
 
17
        id: main
 
18
    }
 
19
 
 
20
    UbuntuTestCase {
 
21
        name: "MainTestCase"
 
22
 
 
23
        when: windowShown
 
24
 
 
25
 
 
26
        function init() {
 
27
            var label = findChild(main, "label");
 
28
            // See the compare method documentation at https://developer.ubuntu.com/api/qml/sdk-14.10/QtTest.TestCase/#compare-method
 
29
            compare("Hello..", label.text);
 
30
        }
 
31
 
 
32
        function test_clickButtonMustChangeLabel() {
 
33
            var button = findChild(main, "button");
 
34
            var buttonCenter = centerOf(button)
 
35
            mouseClick(button, buttonCenter.x, buttonCenter.y);
 
36
            var label = findChild(main, "label");
 
37
            // See the tryCompare method documentation at https://developer.ubuntu.com/api/qml/sdk-14.10/QtTest.TestCase/#tryCompare-method
 
38
            tryCompare(label, "text", "..world!", 1);
 
39
        }
 
40
    }
 
41
}
 
42