on xenial help sign in
Update the url dispatcher test to use the fake app fixture from the toolkit.
commit37259c5db28c04b3f2074b4c38d4bbead0d2fbde authorLeo Arias <leo.arias@canonical.com> dateFri 14 Mar 2014, 15:44 (13 years ago) parent7ee0a6dd6b3cbf
1 file changed+5−40
tests/autopilot/unity8/application_lifecycle/tests/test_url_dispatcher.py+5−40
tests/autopilot/unity8/application_lifecycle/tests/test_url_dispatcher.py+5−40
@@ -20,12 +20,11 @@
2020"""Test the integration with the URL dispatcher service."""
2121
2222import os
23−import tempfile
2423
2524from autopilot import platform
2625from autopilot.matchers import Eventually
2726from testtools.matchers import Equals
28−from ubuntuuitoolkit import base as toolkit_base
27+from ubuntuuitoolkit import fixture_setup
2928
3029from unity8 import process_helpers
3130from unity8.shell import tests
@@ -47,13 +46,6 @@ MainView {
4746 text: 'Test application.'
4847 }
4948}
50−""")
51−
52− desktop_file_contents = ("""[Desktop Entry]
53−Type=Application
54−Name=test
55−Exec={qmlscene} {qml_file_path}
56−Icon=Not important
5749""")
5850
5951 def setUp(self):
@@ -66,37 +58,10 @@ Icon=Not important
6658 process_helpers.unlock_unity(unity_proxy)
6759
6860 def create_test_application(self):
69− # FIXME most of this code is duplicated in the toolkit. We should
70− # create a fixture on the toolkit for other projects to use.
71− # http://pad.lv/1277334 --elopio - 2014-02-06
72− qml_file_path = self._write_test_qml_file()
73− self.addCleanup(os.remove, qml_file_path)
74− desktop_file_path = self._write_test_desktop_file(qml_file_path)
75− self.addCleanup(os.remove, desktop_file_path)
76− return qml_file_path, desktop_file_path
77−
78− def _write_test_qml_file(self):
79− qml_file = tempfile.NamedTemporaryFile(suffix='.qml', delete=False)
80− qml_file.write(self.test_qml.encode('utf-8'))
81− qml_file.close()
82− return qml_file.name
83−
84− def _write_test_desktop_file(self, qml_file_path):
85− desktop_file_dir = self._get_local_desktop_file_directory()
86− if not os.path.exists(desktop_file_dir):
87− os.makedirs(desktop_file_dir)
88− desktop_file = tempfile.NamedTemporaryFile(
89− suffix='.desktop', dir=desktop_file_dir, delete=False)
90− contents = self.desktop_file_contents.format(
91− qmlscene=toolkit_base.get_qmlscene_launch_command(),
92− qml_file_path=qml_file_path)
93− desktop_file.write(contents.encode('utf-8'))
94− desktop_file.close()
95− return desktop_file.name
96−
97− def _get_local_desktop_file_directory(self):
98− return os.path.join(
99− os.environ.get('HOME'), '.local', 'share', 'applications')
61+ fake_application = fixture_setup.FakeApplication(self.test_qml)
62+ self.useFixture(fake_application)
63+ return (
64+ fake_application.qml_file_path, fake_application.desktop_file_path)
10065
10166 def test_swipe_out_application_started_by_url_dispatcher(self):
10267 _, desktop_file_path = self.create_test_application()