~bfiller/gallery-app/remove-texture

« back to all changes in this revision

Viewing changes to tests/autopilot/goodhope/tests/__init__.py

mergeĀ autopilotĀ tests.

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
# Copyright 2012 Canonical
 
3
#
 
4
# This program is free software: you can redistribute it and/or modify it
 
5
# under the terms of the GNU General Public License version 3, as published
 
6
# by the Free Software Foundation.
 
7
 
 
8
"""goodhope autopilot tests."""
 
9
 
 
10
from os import remove
 
11
import os.path
 
12
 
 
13
from autopilot.introspection.qt import QtIntrospectionTestMixin
 
14
from autopilot.testcase import AutopilotTestCase
 
15
 
 
16
from goodhope.emulators.main_window import MainWindow
 
17
from goodhope.emulators.photo_viewer import PhotoViewer
 
18
from goodhope.emulators.album_editor import AlbumEditor
 
19
 
 
20
 
 
21
class GoodhopeTestCase(AutopilotTestCase, QtIntrospectionTestMixin):
 
22
 
 
23
    """A common test case class that provides several useful methods for goodhope tests."""
 
24
 
 
25
    def setUp(self):
 
26
        super(GoodhopeTestCase, self).setUp()
 
27
        os.system("cp goodhope/data/sample.jpg ~/Pictures/")
 
28
 
 
29
        sample_location = os.path.expanduser("~/Pictures/sample.jpg")
 
30
 
 
31
        self.assertTrue(os.path.exists(sample_location))
 
32
        self.addCleanup(os.remove, sample_location)
 
33
 
 
34
        # Lets assume we are installed system wide if this file is somewhere in /usr
 
35
        if os.path.realpath(__file__).startswith("/usr/"):
 
36
            self.launch_test_installed()
 
37
        else:
 
38
            self.launch_test_local()
 
39
 
 
40
    def launch_test_local(self):
 
41
        self.app = self.launch_test_application(
 
42
            "../../gallery"
 
43
            )
 
44
 
 
45
    def launch_test_installed(self):
 
46
        self.app = self.launch_test_application(
 
47
           "gallery",
 
48
           )
 
49
 
 
50
    @property
 
51
    def main_window(self):
 
52
        return MainWindow(self.app)
 
53
 
 
54
    @property
 
55
    def photo_viewer(self):
 
56
        return PhotoViewer(self.app)
 
57
 
 
58
    @property
 
59
    def album_editor(self):
 
60
        return AlbumEditor(self.app)
 
61