def test_launch_fake_application_from_url_dispatcher(self): if platform.model() == 'Desktop': self.skipTest('Not yet working on desktop') path = os.path.abspath(__file__) dir_path = os.path.dirname(path) qml_file_path = os.path.join( dir_path, 'test_fixture_setup.LaunchFakeApplicationTestCase.qml') with open(qml_file_path) as qml_file: qml_file_contents = qml_file.read() fake_application = fixture_setup.FakeApplication( qml_file_contents=qml_file_contents, url_dispatcher_protocols=['testprotocol']) self.useFixture(fake_application) self.useFixture(fixture_setup.InitctlEnvironmentVariable( QT_LOAD_TESTABILITY=1)) self.addCleanup( subprocess.check_output, ['ubuntu-app-stop', fake_application.application_name]) subprocess.check_output( ['url-dispatcher', 'testprotocol://test']) pid = int(subprocess.check_output( ['ubuntu-app-pid', fake_application.application_name]).strip()) application = introspection.get_proxy_object_for_existing_process( pid=pid) # We can select a component from the application. application.select_single('Label', objectName='testLabel')
def setUp(self): super().setUp() self.useFixture( fixtures.EnvironmentVariable('QTCONTACTS_MANAGER_OVERRIDE', newvalue='memory')) self.useFixture( fixture_setup.InitctlEnvironmentVariable( QTCONTACTS_MANAGER_OVERRIDE='memory'))
def use_local_modules(self, local_modules_path): env_vars = [ 'QML_IMPORT_PATH', 'QML2_IMPORT_PATH', 'UBUNTU_UI_TOOLKIT_THEMES_PATH' ] kwargs = {'global_': True} for env in env_vars: kwargs[env] = local_modules_path self.useFixture(fixture_setup.InitctlEnvironmentVariable(**kwargs))
def set_up_locale(self): # We set up the language to english to check the formatting of the # dialed number. self.useFixture( fixtures.EnvironmentVariable('LANGUAGE', newvalue='en') ) self.useFixture( fixture_setup.InitctlEnvironmentVariable(LANGUAGE='en') )
def setUp(self): super(UseEmptyConfiguration, self).setUp() self.user_home_dir = tempfile.mkdtemp(suffix='', prefix='messaging-app') self.user_config_dir = self.user_home_dir + '/.config' self.app_config_dir = (self.user_config_dir + '/com.ubuntu.messaging-app/') os.makedirs(self.app_config_dir) self.useFixture( fixtures.EnvironmentVariable('HOME', newvalue=self.user_home_dir)) self.useFixture( fixtures.EnvironmentVariable('XDG_CONFIG_HOME', newvalue=self.user_config_dir)) self.useFixture( fixture_setup.InitctlEnvironmentVariable(HOME=self.user_home_dir)) self.useFixture( fixture_setup.InitctlEnvironmentVariable( XDG_CONFIG_HOME=self.user_config_dir))
def _launch_unity_with_upstart(self, binary_path, args): logger.info("Starting unity") self.useFixture( toolkit_fixtures.InitctlEnvironmentVariable(global_=True, QT_LOAD_TESTABILITY=1)) variables = self._environment variables['ARGS'] = " ".join(args) launch_unity_fixture = fixture_setup.RestartUnityWithTestability( binary_path, variables) self.useFixture(launch_unity_fixture) return launch_unity_fixture.unity_proxy
def setUp(self): super().setUp() vcard_full_path = PreloadVcards.VCARD_PATH_BIN if os.path.isfile(PreloadVcards.VCARD_PATH_DEV): vcard_full_path = PreloadVcards.VCARD_PATH_DEV self.useFixture( fixtures.EnvironmentVariable('QTCONTACTS_PRELOAD_VCARD', newvalue=vcard_full_path)) self.useFixture( fixture_setup.InitctlEnvironmentVariable( QTCONTACTS_PRELOAD_VCARD=vcard_full_path))
def setUp(self): self.driver = None self.app_proxy = None super().setUp() if platform.model() == 'Desktop': self.patch_environment('UBUNTU_WEBVIEW_DEVTOOLS_HOST', DEFAULT_WEBVIEW_INSPECTOR_IP) self.patch_environment('UBUNTU_WEBVIEW_DEVTOOLS_PORT', str(DEFAULT_WEBVIEW_INSPECTOR_PORT)) else: self.useFixture( fixture_setup.InitctlEnvironmentVariable( global_=True, UBUNTU_WEBVIEW_DEVTOOLS_HOST=DEFAULT_WEBVIEW_INSPECTOR_IP, UBUNTU_WEBVIEW_DEVTOOLS_PORT=str( DEFAULT_WEBVIEW_INSPECTOR_PORT)))
def setUp(self): """Restart Unity8 with testability and create sensors.""" super().setUp() self.useFixture( fixture_setup.InitctlEnvironmentVariable( UBUNTU_PLATFORM_API_TEST_OVERRIDE='sensors')) self.addCleanup(process_helpers.stop_job, 'unity8') restart_thread = threading.Thread( target=self._restart_unity_with_testability) restart_thread.start() self._create_sensors() restart_thread.join() self.fake_sensors = sensors.FakePlatformSensors()
def setUp(self): super(MessagingTestEnvironment, self).setUp() self.useFixture(OfonoPhoneSIM()) if self.use_testdata_db: self.useFixture(FillCustomSmsHistory()) else: self.useFixture(UseEmptySmsHistory()) # check for the configuration file if self.use_temporary_user_conf and self.use_empty_config: self.useFixture(UseEmptyConfiguration()) elif self.use_temporary_user_conf: self.useFixture(UseDefaultConfiguration()) self.useFixture(RespawnService()) self.useFixture(MockNotificationSystem()) telephonyProtocolsDir = '/usr/share/telephony-service/protocols' self.useFixture( fixture_setup.InitctlEnvironmentVariable( TELEPHONY_SERVICE_PROTOCOLS_DIR=telephonyProtocolsDir)) self.useFixture( fixtures.EnvironmentVariable('TELEPHONY_SERVICE_PROTOCOLS_DIR', newvalue=telephonyProtocolsDir))
def create_config_file(self, firstLaunch=False): self.user_config_dir = tempfile.mkdtemp(suffix='', prefix='dialer-app') self.app_config_dir = (self.user_config_dir + '/com.ubuntu.dialer-app/') os.makedirs(self.app_config_dir) config_file_path = (self.app_config_dir + '/DialerApp.conf') if firstLaunch: first_launch_flag = 'true' else: first_launch_flag = 'false' with open(config_file_path, 'w') as config_file: config_file.write( '[General]\nhintNecessary=%s\n' % (first_launch_flag)) self.useFixture( fixtures.EnvironmentVariable('XDG_CONFIG_HOME', newvalue=self.user_config_dir) ) self.useFixture( fixture_setup.InitctlEnvironmentVariable( XDG_CONFIG_HOME=self.user_config_dir) )
def setUp(self): self.useFixture(fixtures.EnvironmentVariable( 'GRID_UNIT_PX', self.grid_unit_px)) self.useFixture(fixture_setup.InitctlEnvironmentVariable( global_=True, GRID_UNIT_PX=self.grid_unit_px)) super().setUp()
def create_fixture(self, value): self.initctl_env_var = fixture_setup.InitctlEnvironmentVariable( testenvvarforfixture=value, global_=self.global_)