~ubuntu-branches/ubuntu/trusty/autopilot-qt/trusty

« back to all changes in this revision

Viewing changes to tests/autopilot/libautopilot_qt/tests/test_main.py

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Michael Zanetti, Christopher Lee, Olivier Tilloy, Ubuntu daily release
  • Date: 2013-06-05 07:08:47 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130605070847-cm5heug9bku0q19d
Tags: 1.3daily13.06.05-0ubuntu1
[ Michael Zanetti ]
* update tests to work with AP 1.3.
* make it work with Qt 5.0.2.

[ Christopher Lee ]
* Adding GetVersion so we can check that the version of the DBus
  protocol is as expected.

[ Olivier Tilloy ]
* Do not override an existing property with the value of a parent
  object. (LP: #1170764)

[ Ubuntu daily release ]
* Automatic snapshot from revision 61

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
# Copyright 2013 Canonical
 
3
#
 
4
# This program is free software: you can redistribute it and/or modify it
 
5
# under the terms of the GNU General Public License version 3, as published
 
6
# by the Free Software Foundation.
 
7
 
 
8
from __future__ import absolute_import
 
9
 
 
10
from testtools.matchers import Equals, NotEquals
 
11
from autopilot.matchers import Eventually
 
12
 
 
13
from libautopilot_qt.tests import AutopilotQtTestCase
 
14
 
 
15
 
 
16
class TestQueries(AutopilotQtTestCase):
 
17
 
 
18
    def setUp(self):
 
19
        super(TestQueries, self).setUp()
 
20
        self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
 
21
 
 
22
    def tearDown(self):
 
23
        super(TestQueries, self).tearDown()
 
24
 
 
25
    def test_find_select_single(self):
 
26
        root_item = self.main_window.get_root_item()
 
27
        self.assertThat(root_item, NotEquals(None))
 
28
 
 
29
    def test_find_by_objectname(self):
 
30
        test_item = self.main_window.get_test_item_by_objectname()
 
31
        self.assertThat(test_item, NotEquals(None))
 
32
 
 
33
    def test_find_by_child_search(self):
 
34
        rectangle = self.main_window.get_test_rectangle_by_child_search()
 
35
        self.assertThat(rectangle, NotEquals(None))
 
36
 
 
37
 
 
38
class TestProperties(AutopilotQtTestCase):
 
39
 
 
40
    def setUp(self):
 
41
        super(TestProperties, self).setUp()
 
42
        self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
 
43
 
 
44
    def tearDown(self):
 
45
        super(TestProperties, self).tearDown()
 
46
 
 
47
    def test_basic_properties(self):
 
48
        test_item = self.main_window.get_test_item()
 
49
 
 
50
        self.assertThat(test_item.stringProperty, Equals("Testing rocks, debugging sucks!"))
 
51
        self.assertThat(test_item.intProperty, Equals(42))
 
52
        self.assertThat(test_item.boolProperty, Equals(False))
 
53
        self.assertThat(test_item.realProperty, Equals(0.42))
 
54
        self.assertThat(test_item.doubleProperty, Equals(0.42))
 
55
 
 
56
        rectangle = self.main_window.get_test_rectangle()
 
57
        self.assertThat(rectangle.color, Equals([0, 0, 255, 255]))
 
58
 
 
59
    def test_mouse_interaction(self):
 
60
        rectangle = self.main_window.get_test_rectangle()
 
61
        self.assertThat(rectangle.color, Equals([0, 0, 255, 255]))
 
62
 
 
63
        mousearea = self.main_window.get_test_mousearea()
 
64
        self.pointing_device.move_to_object(mousearea)
 
65
        self.pointing_device.click()
 
66
 
 
67
        self.assertThat(rectangle.color, Eventually(Equals([255, 0, 0, 255])))
 
68
 
 
69
 
 
70
class TestAppNameQtDefault(AutopilotQtTestCase):
 
71
 
 
72
    def setUp(self):
 
73
        super(TestAppNameQtDefault, self).setUp("--appname", "untitled1")
 
74
 
 
75
    def test_connection(self):
 
76
        self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
 
77
 
 
78
 
 
79
class TestAppNameTech(AutopilotQtTestCase):
 
80
 
 
81
    def setUp(self):
 
82
        super(TestAppNameTech, self).setUp("--appname", "qt-test-app")
 
83
 
 
84
    def test_connection(self):
 
85
        self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
 
86
 
 
87
 
 
88
class TestAppNameUserfriendly(AutopilotQtTestCase):
 
89
 
 
90
    def setUp(self):
 
91
        super(TestAppNameUserfriendly, self).setUp("--appname", "Qt Test App")
 
92
 
 
93
    def test_connection(self):
 
94
        self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
 
95
 
 
96
 
 
97
class TestAppNameFqdn(AutopilotQtTestCase):
 
98
 
 
99
    def setUp(self):
 
100
        super(TestAppNameFqdn, self).setUp("--appname", "com.ubuntu.qttestapp")
 
101
 
 
102
    def test_connection(self):
 
103
        self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))