Run emulator in the beginning
This commit is contained in:
parent
0a605cf226
commit
7b7238f156
|
@ -68,7 +68,7 @@ Quick Start
|
||||||
|
|
||||||
- For different OS, localhost should work.
|
- For different OS, localhost should work.
|
||||||
|
|
||||||
4. Open ***http://docker-machine-ip-address:6080/vnc.html*** from web browser.
|
4. Open ***http://docker-machine-ip-address:6080*** from web browser.
|
||||||
|
|
||||||
![][noVNC]
|
![][noVNC]
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,7 @@ def prepare_avd(device: str, avd_name: str):
|
||||||
# Append command
|
# Append command
|
||||||
cmd += ' -d {device} -s {skin}'.format(device=device_name_bash, skin=skin_name)
|
cmd += ' -d {device} -s {skin}'.format(device=device_name_bash, skin=skin_name)
|
||||||
logger.info('AVD creation command: {cmd}'.format(cmd=cmd))
|
logger.info('AVD creation command: {cmd}'.format(cmd=cmd))
|
||||||
titel = 'AVD creation process'
|
subprocess.check_call(cmd, shell=True)
|
||||||
subprocess.check_call('xterm -T "{titel}" -n "{titel}" -e \"{cmd}\"'.format(titel=titel, cmd=cmd), shell=True)
|
|
||||||
|
|
||||||
|
|
||||||
def appium_run(avd_name: str):
|
def appium_run(avd_name: str):
|
||||||
|
@ -162,9 +161,15 @@ def run():
|
||||||
avd_name = '{device}_{version}'.format(device=device.replace(' ', '_').lower(), version=ANDROID_VERSION)
|
avd_name = '{device}_{version}'.format(device=device.replace(' ', '_').lower(), version=ANDROID_VERSION)
|
||||||
logger.info('AVD name: {avd}'.format(avd=avd_name))
|
logger.info('AVD name: {avd}'.format(avd=avd_name))
|
||||||
|
|
||||||
|
logger.info('Preparing emulator...')
|
||||||
prepare_avd(device, avd_name)
|
prepare_avd(device, avd_name)
|
||||||
|
logger.info('Run emulator...')
|
||||||
|
cmd = 'emulator -avd {name}'.format(name=avd_name)
|
||||||
|
subprocess.Popen(cmd.split())
|
||||||
|
|
||||||
appium = str_to_bool(str(os.getenv('APPIUM', True)))
|
appium = str_to_bool(str(os.getenv('APPIUM', True)))
|
||||||
if appium:
|
if appium:
|
||||||
|
logger.info('Run appium server...')
|
||||||
appium_run(avd_name)
|
appium_run(avd_name)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -34,16 +34,20 @@ class TestApp(TestCase):
|
||||||
self.assertEqual(app.str_to_bool(True), None)
|
self.assertEqual(app.str_to_bool(True), None)
|
||||||
|
|
||||||
@mock.patch('src.app.prepare_avd')
|
@mock.patch('src.app.prepare_avd')
|
||||||
def test_run_with_appium(self, mocked_avd):
|
@mock.patch('subprocess.Popen')
|
||||||
|
def test_run_with_appium(self, mocked_avd, mocked_subprocess):
|
||||||
with mock.patch('src.app.appium_run') as mocked_appium:
|
with mock.patch('src.app.appium_run') as mocked_appium:
|
||||||
app.run()
|
app.run()
|
||||||
self.assertTrue(mocked_avd.called)
|
self.assertTrue(mocked_avd.called)
|
||||||
|
self.assertTrue(mocked_subprocess.called)
|
||||||
self.assertTrue(mocked_appium.called)
|
self.assertTrue(mocked_appium.called)
|
||||||
|
|
||||||
@mock.patch('src.app.prepare_avd')
|
@mock.patch('src.app.prepare_avd')
|
||||||
def test_run_withhout_appium(self, mocked_avd):
|
@mock.patch('subprocess.Popen')
|
||||||
|
def test_run_withhout_appium(self, mocked_avd, mocked_subprocess):
|
||||||
with mock.patch('src.app.appium_run') as mocked_appium:
|
with mock.patch('src.app.appium_run') as mocked_appium:
|
||||||
os.environ['APPIUM'] = str(False)
|
os.environ['APPIUM'] = str(False)
|
||||||
app.run()
|
app.run()
|
||||||
self.assertTrue(mocked_avd.called)
|
self.assertTrue(mocked_avd.called)
|
||||||
|
self.assertTrue(mocked_subprocess.called)
|
||||||
self.assertFalse(mocked_appium.called)
|
self.assertFalse(mocked_appium.called)
|
||||||
|
|
Loading…
Reference in a new issue