@@ -0,0 +1,69 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2014 Canonical
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.
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.
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/>.
24+from gi.repository import Notify
25+from testtools.matchers import Equals
27+from unity8.shell import (
32+from unity8.process_helpers import unlock_unity
34+class ScreenShotTestCase(tests.UnityTestCase):
36+ AP_SCREENSHOT_DIR = '/home/phablet/Pictures/Screenshots'
37+ SCREENSHOT_DELAY_SECS = 2
40+ super(ScreenShotTestCase, self).setUp()
41+ unity_proxy = self.launch_unity()
42+ unlock_unity(unity_proxy)
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)
49+ a=self.main_window.select_single("Notification", objectName="notification1")
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))
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)
64+ time.sleep(self.SCREENSHOT_DELAY_SECS)
66+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 0)
67+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_VOLUMEDOWN, 0)