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

« back to all changes in this revision

Viewing changes to tests/autopilot/address_book_app/tests/test_delete_contact.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
"""Tests for the Addressbook App"""
 
4
 
 
5
# Copyright 2014 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 __future__ import absolute_import
 
11
 
 
12
from testtools.matchers import Equals
 
13
 
 
14
from address_book_app.tests import AddressBookAppTestCase
 
15
from address_book_app.emulators.contact_list_page import ContactListPage
 
16
from address_book_app.emulators.toolbar import Toolbar
 
17
 
 
18
 
 
19
class TestDeleteSelectContact(AddressBookAppTestCase):
 
20
    """
 
21
    Delete a contact using pick mode and verify the behavior of Cancel and
 
22
    Delete actions
 
23
    """
 
24
    scenarios = [
 
25
        ("single_cancel", {
 
26
            "select": [1],
 
27
            "action": "cancel"}),
 
28
        ("multiple_cancel", {
 
29
            "select": [1, 2],
 
30
            "action": "cancel"}),
 
31
        ("none_delete", {
 
32
            "select": [],
 
33
            "action": "delete"}),
 
34
        ("single_delete", {
 
35
            "select": [1],
 
36
            "action": "delete"}),
 
37
        ("multiple_delete", {
 
38
            "select": [1, 2],
 
39
            "action": "delete"}),
 
40
    ]
 
41
 
 
42
    def setUp(self):
 
43
        AddressBookAppTestCase.PRELOAD_VCARD = True
 
44
        super(TestDeleteSelectContact, self).setUp()
 
45
 
 
46
    def test_select(self):
 
47
        """
 
48
        Delete a contact in pick mode
 
49
 
 
50
        This test switch the contact list view to pick mode and validate the
 
51
        behavior of Cancel and delete actions by comparing the numbers of
 
52
        contact in the list before and after the action.
 
53
        Note that it doesn't check which contact has been deleted.
 
54
        """
 
55
        self.main_window.open_toolbar().click_select()
 
56
        listpage = self.main_window.get_contact_list_page()
 
57
        contacts_before = listpage.get_contacts()
 
58
 
 
59
        listpage.select_contacts_by_index(self.select)
 
60
        deleted = []
 
61
        if self.action == "cancel":
 
62
            listpage.cancel()
 
63
        elif self.action == "delete":
 
64
            listpage.delete()
 
65
            deleted = self.select
 
66
 
 
67
        contacts_after = listpage.get_contacts()
 
68
        # TODO:
 
69
        #   - Verify which contact have been deleted
 
70
        self.assertThat(len(contacts_after), Equals(len(contacts_before) -
 
71
                                                    len(deleted)))