on xenial help sign in
removed indicator_client autopilot.
commit180a1fe26007b030cd6df5b5bb9a00e9bd95909b authorNick Dedekind <nicholas.dedekind@gmail.com> dateThu 3 Oct 2013, 17:57 (13 years ago) parentabc9e69
8 files changed−287
CMakeLists.txt−1 debian/control−1 tests/autopilot/unity8/indicators_client/__init__.py−8 tests/autopilot/unity8/indicators_client/emulators/__init__.py−31 tests/autopilot/unity8/indicators_client/emulators/common.py−14 tests/autopilot/unity8/indicators_client/emulators/main_window.py−27 tests/autopilot/unity8/indicators_client/tests/__init__.py−91 tests/autopilot/unity8/indicators_client/tests/test_battery.py−114
CMakeLists.txt−1
@@ -96,7 +96,6 @@ enable_testing()
9696# Autopilot tests
9797include(autopilot)
9898declare_autopilot_test(shell unity8.shell ${CMAKE_SOURCE_DIR}/tests/autopilot/)
99−declare_autopilot_test(indicators_client unity8.indicators_client ${CMAKE_SOURCE_DIR}/tests/autopilot/)
10099
101100set(SHELL_APP unity8)
102101
debian/control−1
@@ -90,7 +90,6 @@ Description: Unity 8 shell
9090Package: unity8-autopilot
9191Architecture: all
9292Depends: gir1.2-glib-2.0,
93− indicators-client (>= ${source:Version}),
9493 libautopilot-qt,
9594 libqt5test5,
9695 libqt5widgets5,
tests/autopilot/unity8/indicators_client/__init__.pydeleted−8
@@ -1,8 +0,0 @@
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−"""unity indicators-client autopilot tests and emulators - sub level package."""
tests/autopilot/unity8/indicators_client/emulators/__init__.pydeleted−31
@@ -1,31 +0,0 @@
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 autopilot.introspection.dbus import DBusIntrospectionObject
9−from autopilot.input import Mouse, Touch, Pointer
10−from autopilot.platform import model
11−
12−from time import sleep
13−
14−from autopilot.introspection.dbus import IntrospectableObjectMetaclass
15−
16−class IndicatorsIntrospectionObject(DBusIntrospectionObject):
17−
18− """A common class that provides introspection and other helpers to indictors."""
19−
20− if model() == 'Desktop':
21− scenarios = [
22− ('with mouse', dict(input_device_class=Mouse)),
23− ]
24− else:
25− scenarios = [
26− ('with touch', dict(input_device_class=Touch)),
27− ]
28−
29− def setUp(self):
30− self.pointing_device = Pointer(self.input_device_class.create())
31− super(IndicatorsTestCase, self).setUp()
tests/autopilot/unity8/indicators_client/emulators/common.pydeleted−14
@@ -1,14 +0,0 @@
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 indicators_client.emulators import IndicatorsIntrospectionObject
9−
10−class SwitchMenu(IndicatorsIntrospectionObject):
11− """A switch menu control."""
12−
13−class Switch(IndicatorsIntrospectionObject):
14− """A switch control."""
tests/autopilot/unity8/indicators_client/emulators/main_window.pydeleted−27
@@ -1,27 +0,0 @@
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−class MainWindow(object):
9− """An emulator class that makes it easy to interact with the shell"""
10−
11− def __init__(self, app):
12− self.app = app
13−
14− def get_qml_view(self):
15− """Get the main QML view"""
16− return self.app.select_single("QQuickView")
17−
18− def get_indicators_client(self):
19− return self.app.select_single("IndicatorsClient")
20−
21− def get_page_stack(self):
22− """Get the page stack"""
23− return self.app.select_single("PageStack")
24−
25− def get_battery_menu(self):
26− """Get the battery menu from the list"""
27− return self.app.select_single("BaseMenuItem", objectName="indicator-battery");
tests/autopilot/unity8/indicators_client/tests/__init__.pydeleted−91
@@ -1,91 +0,0 @@
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−"""indicators-client autopilot tests."""
9−
10−import os.path
11−
12−from autopilot.input import Mouse, Touch, Pointer
13−from autopilot.testcase import AutopilotTestCase
14−from autopilot.matchers import Eventually
15−from autopilot.platform import model
16−from testtools.matchers import Equals
17−
18−from unity8 import get_binary_path
19−from unity8.indicators_client.emulators.main_window import MainWindow
20−from logging import getLogger
21−import sys
22−from time import sleep
23−
24−log = getLogger(__name__)
25−
26−class FormFactors(object):
27− Phone, Tablet, Desktop = range(3)
28−
29−class IndicatorsTestCase(AutopilotTestCase):
30−
31− """A common test case class that provides several useful methods for indicator tests."""
32−
33− geometry = None
34− grid_unit = None
35−
36− if model() == 'Desktop':
37− scenarios = [
38− ('with mouse', dict(input_device_class=Mouse, geometry="400x800", grid_unit="12")),
39− ]
40− else:
41− scenarios = [
42− ('with touch', dict(input_device_class=Touch)),
43− ]
44−
45− def setUp(self, geometry, grid_size):
46− self.pointing_device = Pointer(self.input_device_class.create())
47− super(IndicatorsTestCase, self).setUp()
48− if grid_size is not None:
49− self.patch_environment("GRID_UNIT_PX", str(grid_size))
50− self.grid_size = int(grid_size)
51− else:
52− self.grid_size = int(os.getenv('GRID_UNIT_PX'))
53−
54− if os.path.realpath(__file__).startswith("/usr/"):
55− self.launch_test_installed(geometry)
56− else:
57− self.launch_test_local(geometry)
58−
59− def launch_test_local(self, geometry):
60− if geometry is None:
61− self.app = self.launch_test_application(get_binary_path("indicators-client"),
62− "-geometry", geometry, app_type='qt')
63− else:
64− self.app = self.launch_test_application(get_binary_path("indicators-client"),
65− app_type='qt')
66−
67− def launch_test_installed(self, geometry):
68− if geometry is not None:
69− self.app = self.launch_test_application("indicators-client", "-geometry", geometry, app_type='qt')
70− else:
71− self.app = self.launch_test_application("indicators-client", app_type='qt')
72−
73− def skipWrapper(*args, **kwargs):
74− pass
75−
76− def form_factor(self):
77− return FormFactors.Desktop
78−
79− def __getattribute__(self, attr_name):
80− attr = object.__getattribute__(self, attr_name);
81− if attr_name.startswith("test_"):
82− try:
83− if self.form_factor() in attr.blacklist:
84− return self.skipWrapper
85− except:
86− pass
87− return attr
88−
89− @property
90− def main_window(self):
91− return MainWindow(self.app)
tests/autopilot/unity8/indicators_client/tests/test_battery.pydeleted−114
@@ -1,114 +0,0 @@
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−"""Add tests here if you want to ensure the behaviour of the power indicator menus are correct"""
9−
10−from testtools.matchers import Equals, NotEquals
11−from autopilot.input import Touch
12−from autopilot.matchers import Eventually
13−
14−from unity8.indicators_client.tests import IndicatorsTestCase
15−from time import sleep
16−import random
17−import math
18−import unittest
19−
20−class TestDisplayMenus(IndicatorsTestCase):
21− def setUp(self):
22− super(TestDisplayMenus, self).setUp(self.geometry, self.grid_unit)
23−
24− def tearDown(self):
25− # self.main_window.get_indicators_client().reset()
26− super(TestDisplayMenus, self).tearDown()
27−
28− # START SECTION
29− # We need to move these to emulators once autopilot supports emulators for
30− # applications started with AutopilotTestCase.launch_test_application
31−
32− def open_battery_menu(self):
33− # This opens the messaging menu so you don't have to do that in
34− # every test case
35− self.assertThat(lambda: self.main_window.get_battery_menu(), Eventually(NotEquals(None)));
36− self.pointing_device.move_to_object(self.main_window.get_battery_menu())
37− self.pointing_device.click()
38−
39− fn_loader = lambda: self.app.select_single("IndicatorsPage/QQuickLoader", objectName="pageLoader");
40− self.assertThat(fn_loader, Eventually(NotEquals(None)));
41− page_loader = fn_loader();
42− self.assertThat(page_loader.progress, Eventually(Equals(1.0)))
43−
44− def switch_auto_brightness(self, auto_brightness):
45− ab_switch = auto_brightness.select_single("CheckBox");
46− self.assertThat(ab_switch, NotEquals(None))
47−
48− self.pointing_device.move_to_object(ab_switch)
49− self.pointing_device.click()
50−
51− def set_brightness_to_value(self, brightness_menu, new_value):
52− brightness_slider = brightness_menu.select_single("Slider");
53− self.assertThat(brightness_slider, NotEquals(None))
54−
55− self.pointing_device.move_to_object(brightness_slider)
56−
57− old_ab_value = brightness_slider.value
58− pixel_ratio = brightness_slider.width / (brightness_slider.maximumValue - brightness_slider.minimumValue)
59−
60− while True:
61−
62− pixels_to_move = int(pixel_ratio * (new_value - old_ab_value) / 15)
63− if pixels_to_move == 0:
64− break;
65−
66− self.pointing_device.drag(self.pointing_device.x, self.pointing_device.y, self.pointing_device.x + pixels_to_move, self.pointing_device.y)
67−
68− old_ab_value = brightness_slider.value
69−
70− @unittest.skip("Battery indicator has been removed.")
71− def test_auto_bright_switch(self):
72− """Test the auto-bright switch"""
73− self.open_battery_menu()
74−
75− # wait for the switch menu item
76− fn_auto_brightness = lambda: self.app.select_single("SwitchMenuItem", objectName="auto-brightness");
77− # FIXME: this should go away when we switch to indicator-power
78− try:
79− self.assertThat(fn_auto_brightness, Eventually(NotEquals(None)));
80− except AssertionError:
81− self.skipTest("WARNING: test skipped due to missing indicator-battery")
82− auto_brightness = fn_auto_brightness();
83−
84− old_ab_value = auto_brightness.checked
85−
86− self.switch_auto_brightness(auto_brightness)
87−
88− # TODO - should check backend when it's introspectable.
89− self.assertThat(auto_brightness.checked, Eventually(NotEquals(old_ab_value)))
90−
91− @unittest.skip("Battery indicator has been removed.")
92− def test_brightness_slider(self):
93− """Test the auto-bright switch"""
94− self.open_battery_menu()
95−
96− fn_brightness_menu = lambda: self.app.select_single("SliderMenuItem", objectName="brightness");
97− # FIXME: this should go away when we switch to indicator-power
98− try:
99− self.assertThat(fn_brightness_menu, Eventually(NotEquals(None)));
100− except AssertionError:
101− self.skipTest("WARNING: test skipped due to missing indicator-battery")
102− brightness_menu = fn_brightness_menu();
103−
104− old_ab_value = brightness_menu.value
105− # find a new value to do to. At least 1/4 distance away from current value
106− while True:
107− desired_value = random.uniform(brightness_menu.minimumValue, brightness_menu.maximumValue)
108− if (abs(desired_value - old_ab_value) >= (brightness_menu.maximumValue - brightness_menu.minimumValue)/4):
109− break;
110−
111− self.set_brightness_to_value(brightness_menu, desired_value)
112−
113− # TODO - should check backend when it's introspectable.
114− self.assertThat(brightness_menu.value, Eventually(NotEquals(old_ab_value)))