44
# Source built locally paths
45
local_location = os.path.dirname(os.path.dirname(os.getcwd()))
46
local_build_location = os.path.join(local_location, 'builddir')
47
local_build_location_qml = os.path.join(
48
local_location, 'app/ubuntu-clock-app.qml')
49
#local_build_location_binary = os.path.join(local_build_location, 'app')
50
local_build_location_backend = os.path.join(local_build_location, 'backend')
53
# Source built with SDK paths
54
sdk_build_location = os.path.join(os.path.dirname(local_location),
55
os.path.basename(local_location)
57
sdk_build_location_qml = os.path.join(
58
local_location, 'app/ubuntu-clock-app.qml')
59
#sdk_build_location_binary = os.path.join(sdk_build_location, 'app/ubuntu-clock-app')
60
sdk_build_location_backend = os.path.join(sdk_build_location, 'backend')
62
# Installed binary paths
63
#installed_location_binary = '/usr/bin/ubuntu-clock-app'
64
installed_location_qml = '/usr/share/ubuntu-clock-app/ubuntu-clock-app.qml'
65
installed_location_backend = ""
66
if glob.glob('/usr/lib/*/qt5/qml/ClockApp'):
67
self.installed_location_backend = \
68
glob.glob('/usr/lib/*/qt5/qml/ClockApp')[0]
47
self.binary = 'ubuntu-clock-app'
48
self.source_dir = os.path.dirname(
49
os.path.dirname(os.path.abspath('.')))
50
self.build_dir = self._get_build_dir()
52
self.local_location = self.source_dir
53
self.local_location_qml = os.path.join(self.source_dir,
54
'app', self.binary + '.qml')
56
self.local_location_backend = os.path.join(self.build_dir, 'backend')
58
self.installed_location_backend = ""
59
if glob.glob('/usr/lib/*/qt5/qml/ClockApp'):
60
self.installed_location_backend = \
61
glob.glob('/usr/lib/*/qt5/qml/ClockApp')[0]
62
self.installed_location_qml = \
63
'/usr/share/ubuntu-clock-app/ubuntu-clock-app.qml'
65
71
self.sqlite_dir = os.path.expanduser(
66
72
"~/.local/share/com.ubuntu.clock")
67
73
self.backup_dir = self.sqlite_dir + ".backup"
70
76
self.temp_move_sqlite_db()
71
77
self.addCleanup(self.restore_sqlite_db)
73
# setup fixtures and launcher
74
self.useFixture(fixture_setup.LocationServiceTestEnvironment())
75
self.useFixture(fixtures.EnvironmentVariable('LC_ALL', newvalue='C'))
76
80
self.launcher, self.test_type = self.get_launcher_and_type()
78
82
# launch application under introspection
80
84
self.app = ubuntu_clock_app.ClockApp(self.launcher(), self.test_type)
82
86
def get_launcher_and_type(self):
83
if os.path.exists(self.local_location_backend):
87
if os.path.exists(self.local_build_location_backend):
84
88
launcher = self.launch_test_local
85
89
test_type = 'local'
90
elif os.path.exists(self.sdk_build_location_backend):
91
launcher = self.launch_test_sdk
86
93
elif os.path.exists(self.installed_location_backend):
87
94
launcher = self.launch_test_installed
95
102
def launch_test_local(self):
96
103
return self.launch_test_application(
97
104
base.get_qmlscene_launch_command(),
98
self.local_location_qml,
99
"-I", self.local_location_backend,
105
self.local_build_location_qml,
106
"-I", self.local_build_location_backend,
108
emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
110
@autopilot_logging.log_action(logger.info)
111
def launch_test_sdk(self):
112
return self.launch_test_application(
113
base.get_qmlscene_launch_command(),
114
self.sdk_build_location_qml,
115
"-I", self.sdk_build_location_backend,
101
117
emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
143
159
shutil.move(self.backup_dir, self.sqlite_dir)
145
161
logger.error("Failed to restore database")
147
def _get_build_dir(self):
149
Returns the build dir after having parsed the CMake config file
150
generated by Qt Creator. If it cannot find it or it cannot be parsed,
151
an in-tree build is assumed and thus returned.
154
cmake_config = CMakePluginParser.CMakePluginParser(os.path.join(
155
self.source_dir, 'CMakeLists.txt.user'))
156
build_dir = cmake_config.active_build_dir
158
logger.error("Error parsing CMakeLists.txt.user %s",
160
build_dir = os.path.join(self.source_dir, 'builddir')