/usr/lib/python2.7/dist-packages/unity/tests/launcher/test_capture.py is in unity-autopilot 7.5.0+18.04.20180413-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2012 Canonical
# Authors: Thomi Richards,
# Marco Trevisan (TreviƱo)
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
from __future__ import absolute_import
from autopilot.matchers import Eventually
import logging
from testtools.matchers import Equals, LessThan, GreaterThan
from testtools import skip
from time import sleep
from unity.tests import UnityTestCase
logger = logging.getLogger(__name__)
class LauncherCaptureTests(UnityTestCase):
"""Test the launchers ability to capture/not capture the mouse."""
def setUp(self):
super(LauncherCaptureTests, self).setUp()
if self.display.get_num_screens() <= 1:
self.skipTest("This test requires two or more monitors.")
self.set_unity_option('launcher_capture_mouse', True)
self.set_unity_option('num_launchers', 0)
self.setHideMode(0)
def setHideMode(self, mode):
self.set_unity_option('launcher_hide_mode', mode)
launcher = self.unity.launcher.get_launcher_for_monitor(0)
self.assertThat(launcher.hidemode, Eventually(Equals(mode)))
def leftMostMonitor(self):
x1, y1, width, height = self.display.get_screen_geometry(0)
x2, y2, width, height = self.display.get_screen_geometry(1)
if x1 < x2:
return 0
return 1
def rightMostMonitor(self):
# TODO: This will break setups with 3 or more monitors.
return 1 - self.leftMostMonitor()
@skip("Test is no longer possible due to changes in AP mouse movement.")
def test_launcher_captures_while_sticky_and_revealed(self):
"""Tests that the launcher captures the mouse when moving between monitors
while revealed.
"""
x, y, width, height = self.display.get_screen_geometry(self.rightMostMonitor())
self.mouse.move(x + width / 2, y + height / 2, False)
self.mouse.move(x - width / 2, y + height / 2, True, 5, .002)
x_fin, y_fin = self.mouse.position()
# The launcher should have held the mouse a little bit
self.assertThat(x_fin, GreaterThan(x - width / 2))
def test_launcher_not_capture_while_not_sticky_and_revealed(self):
"""Tests that the launcher doesn't captures the mouse when moving between monitors
while revealed and stick is off.
"""
self.set_unity_option('launcher_capture_mouse', False)
x, y, width, height = self.display.get_screen_geometry(self.rightMostMonitor())
self.mouse.move(x + width / 2, y + height / 2, False)
self.mouse.move(x - width / 2, y + height / 2, True, 5, .002)
x_fin, y_fin = self.mouse.position()
# The launcher should have held the mouse a little bit
self.assertThat(x_fin, Equals(x - width / 2))
@skip("Test is no longer possible due to changes in AP mouse movement.")
def test_launcher_capture_while_not_sticky_and_hidden(self):
"""Tests that the launcher captures the mouse when moving between monitors
while hidden and sticky is off. (moving left)
"""
self.set_unity_option('launcher_capture_mouse', False)
self.setHideMode(1)
x, y, width, height = self.display.get_screen_geometry(self.rightMostMonitor())
self.mouse.move(x + width / 2, y + height / 2, False)
self.mouse.move(x - width / 2, y + height / 2, True, 5, .002)
x_fin, y_fin = self.mouse.position()
# The launcher should have held the mouse a little bit
self.assertThat(x_fin, GreaterThan(x - width / 2))
def test_launcher_not_capture_while_not_sticky_and_hidden_moving_right(self):
"""Tests that the launcher doesn't capture the mouse when moving between monitors
while hidden and sticky is off (moving right).
"""
self.set_unity_option('launcher_capture_mouse', False)
self.setHideMode(1)
x, y, width, height = self.display.get_screen_geometry(self.leftMostMonitor())
self.mouse.move(x + width / 2, y + height / 2, False)
sleep(1.5)
self.mouse.move(x + width * 1.5, y + height / 2, True, 5, .002)
x_fin, y_fin = self.mouse.position()
# The launcher should have held the mouse a little bit
self.assertThat(x_fin, Equals(x + width * 1.5))
@skip("Test is no longer possible due to changes in AP mouse movement.")
def test_launcher_capture_while_sticky_and_hidden_moving_right(self):
"""Tests that the launcher captures the mouse when moving between monitors
while hidden.
"""
self.setHideMode(1)
x, y, width, height = self.display.get_screen_geometry(self.leftMostMonitor())
self.mouse.move(x + width / 2, y + height / 2, False)
sleep(1.5)
self.mouse.move(x + width * 1.5, y + height / 2, True, 5, .002)
x_fin, y_fin = self.mouse.position()
# The launcher should have held the mouse a little bit
self.assertThat(x_fin, LessThan(x + width * 1.5))
|