This file is indexed.

/usr/lib/python2.7/dist-packages/unity/tests/launcher/test_tooltips.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
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2013 Canonical
# Authors: Jacob Edwards
#
# 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 autopilot.matchers import Eventually
from testtools.matchers import Equals, NotEquals
from time import sleep

from unity.tests.launcher import LauncherTestCase, _make_scenarios

class LauncherTooltipTests(LauncherTestCase):
    """Tests whether tooltips display only at appropriate times."""

    def setUp(self):
        super(LauncherTooltipTests, self).setUp()
        self.set_unity_option('launcher_hide_mode', 0)
        self.launcher_instance.move_mouse_beside_launcher()
        self.icons = self.unity.launcher.model.get_launcher_icons(visible_only=True)

    def test_launcher_tooltip_show(self):
        """Tests whether icon tooltips delay showing themselves and,
        once shown, whether subsequent icons show them instantly."""
        for i in self.icons:
            tooltip = i.get_tooltip()
            if not tooltip:
                continue
            self.assertThat(tooltip.active, Eventually(Equals(False)))

        # only reveal tooltips after short wait
        self.assertEqual(self.get_reveal_behavior(self.icons[0]), self.DELAYED)

        # must avoid the accordion effect, as the icons start to pass to quickly
        size = len(self.icons)
        if size > 5:
            size = 5

        # subsequent tooltips reveal instantly, but are destroyed on exit, meaning None
        a, b = 0, 1
        while b < size:
            self.mouse.move(self.icons[b].center.x, self.icons[b].center.y)
            self.assertThat(lambda: self.icons[b].get_tooltip(), Eventually(NotEquals(None)))
            self.assertThat(self.icons[b].get_tooltip().active, Eventually(Equals(True)))
            self.assertThat(self.icons[a].get_tooltip(), Equals(None))
            a, b = a + 1, b + 1
        b -= 1

        # leaving launcher clears tooltips, and instant reveal
        self.launcher_instance.move_mouse_beside_launcher()
        self.assertEqual(self.get_reveal_behavior(self.icons[b]), self.DELAYED)

    def test_launcher_tooltip_disabling(self):
        """Tests whether clicking on an icon hides its tooltip."""
        bfb, other = self.icons[0], self.icons[1]
        self.assertEqual(self.get_reveal_behavior(bfb), self.DELAYED)

        # clicking icon hides its launcher until further input
        self.mouse.click()
        self.assertEqual(self.get_reveal_behavior(bfb), self.NEVER)
        self.mouse.click()

        # normal behavior resumes on moving away from icon
        self.assertEqual(self.get_reveal_behavior(other), self.DELAYED)
        self.assertEqual(self.get_reveal_behavior(bfb), self.INSTANT)

    def test_launcher_bfb_tooltip_when_open(self):
        """Tests whether hovering over the active BFB starts a tooltip timer"""
        self.unity.dash.ensure_visible()
        self.addCleanup(self.unity.dash.ensure_hidden)
        bfb, other = self.icons[0], self.icons[1]

        # hovering an open dash's BFB does not show a tooltip ...
        self.assertEqual(self.get_reveal_behavior(bfb), self.NEVER)

        # ... nor did it timeout instant tooltips for other icons
        self.assertEqual(self.get_reveal_behavior(other), self.INSTANT)

    # Tooltip reveal types
    (INSTANT, DELAYED, NEVER) = range(3)

    def get_reveal_behavior(self, icon):
        self.mouse.move(icon.center.x, icon.center.y)
        tooltip = icon.get_tooltip()
        if tooltip and tooltip.active:
            return self.INSTANT
        sleep(1.2)
        tooltip = icon.get_tooltip()
        if tooltip and tooltip.active:
            return self.DELAYED
        return self.NEVER