~macslow/unity/backported-remote-add-to-5.0

« back to all changes in this revision

Viewing changes to tests/autopilot/autopilot/emulators/unity/launcher.py

Merging with upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
from autopilot.keybindings import KeybindingsHelper
15
15
from autopilot.emulators.unity import UnityIntrospectionObject
16
 
from autopilot.emulators.unity.icons import BamfLauncherIcon, SimpleLauncherIcon
 
16
from autopilot.emulators.unity.icons import BFBLauncherIcon, BamfLauncherIcon, SimpleLauncherIcon
17
17
from autopilot.emulators.X11 import Mouse, ScreenGeometry
18
18
from autopilot.emulators.dbus_handler import session_bus
19
19
 
213
213
        logger.debug("Clicking launcher icon %r on monitor %d with mouse button %d",
214
214
            icon, self.monitor, button)
215
215
        self.mouse_reveal_launcher()
216
 
        target_x = icon.x + self.x
217
 
        target_y = icon.y + (self.icon_size / 2)
 
216
        target_x = icon.center_x + self.x
 
217
        target_y = icon.center_y
218
218
        self._mouse.move(target_x, target_y )
219
219
        self._mouse.click(button)
220
220
        self.move_mouse_to_right_of_launcher()
271
271
class LauncherModel(UnityIntrospectionObject):
272
272
    """THe launcher model. Contains all launcher icons as children."""
273
273
 
 
274
    def get_bfb_icon(self):
 
275
        icons = BFBLauncherIcon.get_all_instances()
 
276
        assert(len(icons) == 1)
 
277
        return icons[0]
 
278
 
274
279
    def get_launcher_icons(self, visible_only=True):
275
280
        """Get a list of launcher icons in this launcher."""
276
281
        if visible_only:
277
 
            return self.get_children_by_type(SimpleLauncherIcon, quirk_visible=True)
 
282
            return self.get_children_by_type(SimpleLauncherIcon, visible=True)
278
283
        else:
279
284
            return self.get_children_by_type(SimpleLauncherIcon)
280
285
 
 
286
    def get_launcher_icons_for_monitor(self, monitor, visible_only=True):
 
287
        """Get a list of launcher icons for provided monitor."""
 
288
        icons = []
 
289
        for icon in self.get_launcher_icons(visible_only):
 
290
            if icon.is_on_monitor(monitor):
 
291
                icons.append(icon)
 
292
 
 
293
        return icons
 
294
 
281
295
    def get_icon_by_tooltip_text(self, tooltip_text):
282
296
        """Get a launcher icon given it's tooltip text.
283
297
 
294
308
        Returns None if there is no such launcher icon.
295
309
        """
296
310
        icons = self.get_children_by_type(SimpleLauncherIcon, desktop_file=desktop_file)
297
 
        return icons or None
 
311
        if len(icons):
 
312
            return icons[0]
 
313
 
 
314
        return None
 
315
 
 
316
    def get_icon_by_desktop_id(self, desktop_id):
 
317
        """Gets a launcher icon with the specified desktop id.
 
318
 
 
319
        Returns None if there is no such launcher icon.
 
320
        """
 
321
        icons = self.get_children_by_type(SimpleLauncherIcon, desktop_id=desktop_id)
 
322
        if len(icons):
 
323
            return icons[0]
 
324
 
 
325
        return None
298
326
 
299
327
    def num_launcher_icons(self):
300
328
        """Get the number of icons in the launcher model."""