1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
# Copyright 2012 Canonical
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.
8
"""goodhope autopilot tests."""
13
from autopilot.introspection.qt import QtIntrospectionTestMixin
14
from autopilot.testcase import AutopilotTestCase
16
from goodhope.emulators.main_window import MainWindow
17
from goodhope.emulators.photo_viewer import PhotoViewer
18
from goodhope.emulators.album_editor import AlbumEditor
21
class GoodhopeTestCase(AutopilotTestCase, QtIntrospectionTestMixin):
23
"""A common test case class that provides several useful methods for goodhope tests."""
26
super(GoodhopeTestCase, self).setUp()
27
os.system("cp goodhope/data/sample.jpg ~/Pictures/")
29
sample_location = os.path.expanduser("~/Pictures/sample.jpg")
31
self.assertTrue(os.path.exists(sample_location))
32
self.addCleanup(os.remove, sample_location)
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()
38
self.launch_test_local()
40
def launch_test_local(self):
41
self.app = self.launch_test_application(
45
def launch_test_installed(self):
46
self.app = self.launch_test_application(
51
def main_window(self):
52
return MainWindow(self.app)
55
def photo_viewer(self):
56
return PhotoViewer(self.app)
59
def album_editor(self):
60
return AlbumEditor(self.app)