~deja-dup-hackers/deja-dup/34

« back to all changes in this revision

Viewing changes to deja-dup/tests/deja_dup_autopilot/tests/test_ccpanel.py

  • Committer: Michael Terry
  • Date: 2013-10-06 07:11:16 UTC
  • Revision ID: michael.terry@canonical.com-20131006071116-pz045n8znpxlajvj
Add first autopilot test

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 2; coding: utf-8 -*-
 
2
#
 
3
# This file is part of Déjà Dup.
 
4
# For copyright information, see AUTHORS.
 
5
#
 
6
# Déjà Dup is free software; you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation; either version 3 of the License, or
 
9
# (at your option) any later version.
 
10
#
 
11
# Déjà Dup is distributed in the hope that it will be useful, but
 
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
# General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with Déjà Dup.  If not, see <http://www.gnu.org/licenses/>.
 
18
 
 
19
import os
 
20
import subprocess
 
21
from autopilot.input import Pointer, Touch
 
22
from autopilot.matchers import Eventually
 
23
from autopilot.testcase import AutopilotTestCase
 
24
from deja_dup_autopilot import system_only
 
25
from testtools.matchers import Equals, NotEquals
 
26
 
 
27
 
 
28
class CCPanelTests(AutopilotTestCase):
 
29
 
 
30
  @system_only
 
31
  def setUp(self):
 
32
    super(CCPanelTests, self).setUp()
 
33
    self.pointer = Pointer(Touch.create())
 
34
 
 
35
    panel_dir = subprocess.check_output(["pkg-config",
 
36
                                         "--variable=extensiondir",
 
37
                                         "libgnome-control-center"]).strip()
 
38
    if not os.path.exists(os.path.join(panel_dir, "libdeja-dup.so")):
 
39
      self.skip("Skipping ccpanel test because the panel is not installed")
 
40
 
 
41
  def test_clean_exit(self):
 
42
    """Launch and close the panel a couple times.  If we don't properly clean
 
43
       up after ourselves when we are disposed, this may cause a crash."""
 
44
    app = self.launch_test_application('gnome-control-center', 'deja-dup')
 
45
    window = app.select_single("GtkApplicationWindow")
 
46
    self.assertThat(window.title, Eventually(Equals("Backup")))
 
47
    self.close_backup_panel(window)
 
48
    self.open_backup_panel(window)
 
49
    self.close_backup_panel(window)
 
50
 
 
51
  def open_backup_panel(self, window):
 
52
    # This is dumb, but GtkIconView doesn't seem to list its contents to
 
53
    # autopilot.  TODO: make this actually click on Backup icon in window
 
54
    os.system('gnome-control-center deja-dup')
 
55
    self.assertThat(window.title, Eventually(Equals("Backup")))
 
56
 
 
57
  def close_backup_panel(self, window):
 
58
    button = window.select_single("GtkButton", label="_All Settings")
 
59
    self.pointer.click_object(button)
 
60
    self.assertThat(window.title, Eventually(NotEquals("Backup")))