/usr/lib/python3/dist-packages/ubuntuuitoolkit/tests/gallery/__init__.py is in ubuntu-ui-toolkit-autopilot 0.1.46+14.04.20140408.1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
#
# Copyright (C) 2012, 2013 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Tests for the Ubuntu UI Toolkit Gallery"""
import os
import shutil
from ubuntuuitoolkit import tests
class GalleryTestCase(tests.QMLFileAppTestCase):
"""Base class for gallery test cases."""
local_desktop_file_path = None
def setUp(self):
if self._application_source_exists():
self.test_source_path = self._get_path_to_gallery_source()
else:
self.test_source_path = self._get_path_to_installed_gallery()
assert os.path.exists(self.test_source_path)
self.test_qml_file_path = self._get_test_qml_file_path()
self.desktop_file_path = self._get_desktop_file_path()
super(GalleryTestCase, self).setUp()
def _get_path_to_gallery_source(self):
return os.path.join(
tests.get_path_to_source_root(), 'examples',
'ubuntu-ui-toolkit-gallery')
def _application_source_exists(self):
return 'UBUNTU_UI_TOOLKIT_AUTOPILOT_FROM_SOURCE' in os.environ
def _get_test_qml_file_path(self):
return os.path.join(
self.test_source_path,
'ubuntu-ui-toolkit-gallery.qml')
def _get_path_to_installed_gallery(self):
return '/usr/lib/ubuntu-ui-toolkit/examples/ubuntu-ui-toolkit-gallery'
def _get_desktop_file_path(self):
desktop_file_path = os.path.join(
self.test_source_path,
'ubuntu-ui-toolkit-gallery.desktop')
if self._application_source_exists():
local_desktop_file_dir = tests.get_local_desktop_file_directory()
if not os.path.exists(local_desktop_file_dir):
os.makedirs(local_desktop_file_dir)
local_desktop_file_path = os.path.join(
local_desktop_file_dir, 'ubuntu-ui-toolkit-gallery.desktop')
shutil.copy(desktop_file_path, local_desktop_file_path)
# We can't delete the desktop file before we close the application,
# so we save it on an attribute to be deleted on tear down.
self.local_desktop_file_path = local_desktop_file_path
return local_desktop_file_path
else:
return desktop_file_path
def tearDown(self):
super(GalleryTestCase, self).tearDown()
# We can't delete the desktop file before we close the application,
# so we save it on an attribute to be deleted on tear down.
if self.local_desktop_file_path is not None:
os.remove(self.local_desktop_file_path)
|