Merge lp:~canonical-platform-qa/gallery-app/launch_app_fixture into lp:~canonical-platform-qa/gallery-app/clean_autopilot_setup

Proposed by Leo Arias
Status: Needs review
Proposed branch: lp:~canonical-platform-qa/gallery-app/launch_app_fixture
Merge into: lp:~canonical-platform-qa/gallery-app/clean_autopilot_setup
Prerequisite: lp:~canonical-platform-qa/gallery-app/fix1381207-do_not_touch_database
Diff against target: 143 lines (+62/-51)
1 file modified
tests/autopilot/gallery_app/tests/__init__.py (+62/-51)
To merge this branch: bzr merge lp:~canonical-platform-qa/gallery-app/launch_app_fixture
Reviewer Review Type Date Requested Status
Canonical Platform QA Team Pending
Review via email: mp+238388@code.launchpad.net

Commit message

Made an autopilot base test case for the tests that just need the app to be open.

To post a comment you must log in.

Unmerged revisions

1109. By Leo Arias

Made a base test case for the tests that just need the app to be open.

1108. By Leo Arias

Removed the database and thumbnail files.

1107. By Leo Arias

Link to the bug

1106. By Leo Arias

Modified the date of the first two pictures.

1105. By Leo Arias

Merged with prerequisite.

1104. By Leo Arias

Removed the database edits.

1103. By Leo Arias

Merged with prerequisite.

1102. By Leo Arias

Do not backup existing files during autopilot tests. We will assume a clean environment from now on.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/gallery_app/tests/__init__.py'
2--- tests/autopilot/gallery_app/tests/__init__.py 2014-10-15 05:23:12 +0000
3+++ tests/autopilot/gallery_app/tests/__init__.py 2014-10-15 05:23:12 +0000
4@@ -42,14 +42,19 @@
5
6 class GalleryTestCase(AutopilotTestCase):
7
8- """A common test case class that provides several useful methods for
9- gallery tests."""
10-
11- sample_file_source = "/sample01.jpg"
12- tap_press_time = 1
13+ """Base test case for gallery app tests.
14+
15+ It will open the gallery app with testability enabled.
16+
17+ """
18+
19 local_location = os.path.abspath('../../src/gallery-app')
20
21- ARGS = []
22+ def setUp(self):
23+ self.pointing_device = toolkit_emulators.get_pointing_device()
24+ super().setUp()
25+ env_type = self._get_environment_launch_type()
26+ self.launch_gallery_app(env_type)
27
28 @property
29 def gallery_utils(self):
30@@ -71,45 +76,11 @@
31 else:
32 return fixture_setup.Launcher.installed_click
33
34- def _get_sample_destination_dir(self):
35- return os.path.expanduser("~/Pictures")
36-
37- def configure_sample_files(self, env_type):
38- self.sample_dir = resource_filename('gallery_app', 'data')
39- self.sample_destination_dir = self._get_sample_destination_dir()
40- if (os.path.exists(self.sample_destination_dir)):
41- shutil.rmtree(self.sample_destination_dir)
42- self.assertFalse(os.path.exists(self.sample_destination_dir))
43-
44- self.sample_file = os.path.join(
45- self.sample_destination_dir,
46- "sample04.jpg"
47- )
48-
49- default_data_dir = os.path.join(self.sample_dir, 'default')
50- shutil.copytree(default_data_dir, self.sample_destination_dir)
51- self.assertTrue(os.path.isfile(self.sample_file))
52-
53- self.sample_file_source = default_data_dir + self.sample_file_source
54-
55- def do_reset_config(self):
56- config = os.path.expanduser(
57- os.path.join("~", ".config", "gallery-app.conf"))
58- if os.path.exists(config):
59- os.remove(config)
60-
61- def setUp(self):
62- self.pointing_device = toolkit_emulators.get_pointing_device()
63- super(GalleryTestCase, self).setUp()
64-
65- env_type = self._get_environment_launch_type()
66- self.configure_sample_files(env_type)
67-
68- self.launch_gallery_app(env_type)
69-
70- self.addCleanup(shutil.rmtree, self.sample_destination_dir)
71- self.addCleanup(logger.debug,
72- "Deleting %s" % self.sample_destination_dir)
73+ def launch_gallery_app(self, env_type):
74+ launch_fixture = fixture_setup.LaunchGalleryApp(
75+ env_type, self.local_location)
76+ self.useFixture(launch_fixture)
77+ self.app = launch_fixture.application_proxy
78
79 """ This is needed to wait for the application to start.
80 In the testfarm, the application may take some time to show up."""
81@@ -119,12 +90,6 @@
82 for switching to the albums view. Therefore this hack of sleeping"""
83 sleep(2)
84
85- def launch_gallery_app(self, env_type):
86- launch_fixture = fixture_setup.LaunchGalleryApp(
87- env_type, self.local_location)
88- self.useFixture(launch_fixture)
89- self.app = launch_fixture.application_proxy
90-
91 def ui_update(self):
92 """ Gives the program the time to update the UI"""
93 sleep(0.1)
94@@ -211,3 +176,49 @@
95 self.assertThat(delete_dialog.visible, Eventually(Equals(True)))
96 self.assertThat(delete_dialog.opacity, Eventually(Equals(1)))
97 return delete_dialog
98+
99+
100+class GalleryTestCaseWithSampleFiles(GalleryTestCase):
101+
102+ """A common test case class that provides several useful methods for
103+ gallery tests."""
104+
105+ sample_file_source = "/sample01.jpg"
106+ tap_press_time = 1
107+
108+ ARGS = []
109+
110+ def _get_sample_destination_dir(self):
111+ return os.path.expanduser("~/Pictures")
112+
113+ def configure_sample_files(self):
114+ self.sample_dir = resource_filename('gallery_app', 'data')
115+ self.sample_destination_dir = self._get_sample_destination_dir()
116+ if (os.path.exists(self.sample_destination_dir)):
117+ shutil.rmtree(self.sample_destination_dir)
118+ self.assertFalse(os.path.exists(self.sample_destination_dir))
119+
120+ self.sample_file = os.path.join(
121+ self.sample_destination_dir,
122+ "sample04.jpg"
123+ )
124+
125+ default_data_dir = os.path.join(self.sample_dir, 'default')
126+ shutil.copytree(default_data_dir, self.sample_destination_dir)
127+ self.assertTrue(os.path.isfile(self.sample_file))
128+
129+ self.sample_file_source = default_data_dir + self.sample_file_source
130+
131+ def do_reset_config(self):
132+ config = os.path.expanduser(
133+ os.path.join("~", ".config", "gallery-app.conf"))
134+ if os.path.exists(config):
135+ os.remove(config)
136+
137+ def setUp(self):
138+ self.configure_sample_files()
139+ self.addCleanup(shutil.rmtree, self.sample_destination_dir)
140+ self.addCleanup(logger.debug,
141+ "Deleting %s" % self.sample_destination_dir)
142+
143+ super(GalleryTestCase, self).setUp()

Subscribers

People subscribed via source and target branches

to all changes: