on xenial help sign in
Add AP test
eab826eJosh Arenson
tests/autopilot/unity8/shell/tests/test_screenshots.pynew file+69
@@ -0,0 +1,69 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2014 Canonical
5+#
6+# This program is free software: you can redistribute it and/or modify
7+# it under the terms of the GNU General Public License as published by
8+# the Free Software Foundation, either version 3 of the License, or
9+# (at your option) any later version.
10+#
11+# This program is distributed in the hope that it will be useful,
12+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+# GNU General Public License for more details.
15+#
16+# You should have received a copy of the GNU General Public License
17+# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+#
19+
20+import evdev
21+import os
22+import time
23+
24+from gi.repository import Notify
25+from testtools.matchers import Equals
26+
27+from unity8.shell import (
28+ fixture_setup,
29+ tests
30+)
31+
32+from unity8.process_helpers import unlock_unity
33+
34+class ScreenShotTestCase(tests.UnityTestCase):
35+
36+ AP_SCREENSHOT_DIR = '/home/phablet/Pictures/Screenshots'
37+ SCREENSHOT_DELAY_SECS = 2
38+
39+ def setUp(self):
40+ super(ScreenShotTestCase, self).setUp()
41+ unity_proxy = self.launch_unity()
42+ unlock_unity(unity_proxy)
43+
44+ def test_volume_is_hidden(self):
45+ uinput = evdev.UInput(name='apinput', devnode='/dev/autopilot-uinput')
46+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_VOLUMEDOWN, 1)
47+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_VOLUMEDOWN, 0)
48+ uinput.syn()
49+ a=self.main_window.select_single("Notification", objectName="notification1")
50+ print (a.icon)
51+
52+ def test_take_screenshot(self):
53+ num_screenshots_pre = len(os.listdir(self.AP_SCREENSHOT_DIR))
54+ self._take_screenshot()
55+ num_screenshots_post = len(os.listdir(self.AP_SCREENSHOT_DIR))
56+ self.assertThat(num_screenshots_pre + 1, Equals(num_screenshots_post))
57+
58+ def _take_screenshot(self):
59+ uinput = evdev.UInput(name='apinput', devnode='/dev/autopilot-uinput')
60+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 1)
61+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_VOLUMEDOWN, 1)
62+ uinput.syn()
63+
64+ time.sleep(self.SCREENSHOT_DELAY_SECS)
65+
66+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 0)
67+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_VOLUMEDOWN, 0)
68+ uinput.syn()
69+