1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
# Copyright 2013 Canonical
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.
8
from __future__ import absolute_import
10
from testtools.matchers import Equals, NotEquals
11
from autopilot.matchers import Eventually
13
from libautopilot_qt.tests import AutopilotQtTestCase
16
class TestQueries(AutopilotQtTestCase):
19
super(TestQueries, self).setUp()
20
self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
23
super(TestQueries, self).tearDown()
25
def test_find_select_single(self):
26
root_item = self.main_window.get_root_item()
27
self.assertThat(root_item, NotEquals(None))
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))
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))
38
class TestProperties(AutopilotQtTestCase):
41
super(TestProperties, self).setUp()
42
self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
45
super(TestProperties, self).tearDown()
47
def test_basic_properties(self):
48
test_item = self.main_window.get_test_item()
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))
56
rectangle = self.main_window.get_test_rectangle()
57
self.assertThat(rectangle.color, Equals([0, 0, 255, 255]))
59
def test_mouse_interaction(self):
60
rectangle = self.main_window.get_test_rectangle()
61
self.assertThat(rectangle.color, Equals([0, 0, 255, 255]))
63
mousearea = self.main_window.get_test_mousearea()
64
self.pointing_device.move_to_object(mousearea)
65
self.pointing_device.click()
67
self.assertThat(rectangle.color, Eventually(Equals([255, 0, 0, 255])))
70
class TestAppNameQtDefault(AutopilotQtTestCase):
73
super(TestAppNameQtDefault, self).setUp("--appname", "untitled1")
75
def test_connection(self):
76
self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
79
class TestAppNameTech(AutopilotQtTestCase):
82
super(TestAppNameTech, self).setUp("--appname", "qt-test-app")
84
def test_connection(self):
85
self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
88
class TestAppNameUserfriendly(AutopilotQtTestCase):
91
super(TestAppNameUserfriendly, self).setUp("--appname", "Qt Test App")
93
def test_connection(self):
94
self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
97
class TestAppNameFqdn(AutopilotQtTestCase):
100
super(TestAppNameFqdn, self).setUp("--appname", "com.ubuntu.qttestapp")
102
def test_connection(self):
103
self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))