~timo-jyrinki/address-book-app/rebuild_against_qt521

« back to all changes in this revision

Viewing changes to tests/autopilot/address_book_app/emulators/toolbar.py

  • Committer: CI bot
  • Author(s): Jean-Baptiste Lallement
  • Date: 2014-02-27 02:29:20 UTC
  • mfrom: (134.2.4 abook.tc_delete)
  • Revision ID: ps-jenkins@lists.canonical.com-20140227022920-7bbjk3i13ymdlw67
tests/autopilot: Added 'delete contact' test case with pick mode enabled 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
 
 
3
""" Toolbar emulator for Addressbook App tests """
 
4
 
 
5
# Copyright 2013 Canonical
 
6
#
 
7
# This program is free software: you can redistribute it and/or modify it
 
8
# under the terms of the GNU General Public License version 3, as published
 
9
# by the Free Software Foundation.
 
10
from autopilot.introspection.dbus import StateNotFoundError
 
11
import logging
 
12
from ubuntuuitoolkit import emulators as toolkit_emulators
 
13
 
 
14
logger = logging.getLogger(__name__)
 
15
 
 
16
 
 
17
class Toolbar(toolkit_emulators.Toolbar):
 
18
    """An emulator class that makes it easy to interact with the tool bar"""
 
19
    def __init__(self, *args):
 
20
        super(Toolbar, self).__init__(*args)
 
21
 
 
22
    def click_action_item_by_text(self, text):
 
23
        """Click an action item in the tool labelled 'text'
 
24
 
 
25
        :param text: label of the ActionItem
 
26
        """
 
27
        try:
 
28
            action_item = self.select_single('ActionItem', text=text)
 
29
            self.pointing_device.click_object(action_item)
 
30
        except StateNotFoundError:
 
31
            logger.error(
 
32
                'ActionItem with text "{0}" not found.'.format(text)
 
33
            )
 
34
            raise
 
35
 
 
36
    def click_select(self):
 
37
        """Press 'Select' button on the toolbar"""
 
38
        self.click_action_item_by_text("Select")