9"""iOS flavor, used for running code on iOS."""
14 super(iOSFlavor, self).
__init__(m, app_name)
19 resource_dir=
'resources',
20 fonts_dir =
'NOT_SUPPORTED',
22 lotties_dir=
'lotties',
33 'IOS_MOUNT_POINT': self.
m.vars.workdir.join(
'mnt_iosdevice'),
39 def _run(self, title, *cmd, **kwargs):
42 'sleep before attempt %d' % attempt,
45 return self.
m.run.with_retry(self.
m.step, title, 3, cmd=list(cmd),
46 between_attempts_fn=sleep, **kwargs)
57 self.
m.
run(self.
m.step,
'check if device is paired',
58 cmd=[
'idevicepair',
'validate'],
59 infra_step=
True, abort_on_failure=
True,
60 fail_build_on_failure=
False)
61 except self.
m.step.StepFailure:
62 self.
_run_run(
'pair device',
'idevicepair',
'pair')
65 image_info = self.
_run_run(
'list mounted image',
66 'ideviceimagemounter',
'--list',
67 stdout=self.
m.raw_io.output())
69 image_info.stdout.decode(
'utf-8').strip()
if image_info.stdout
else '')
71 if 'ImageSignature' not in image_info_out:
72 image_pkgs = self.
m.file.glob_paths(
'locate ios-dev-image package',
73 self.
m.path[
'start_dir'],
75 test_data=[
'ios-dev-image-13.2'])
76 if len(image_pkgs) != 1:
77 raise Exception(
'glob for ios-dev-image* returned %s'
80 image_pkg = image_pkgs[0]
81 contents = self.
m.file.listdir(
82 'locate image and signature', image_pkg,
83 test_data=[
'DeveloperDiskImage.dmg',
84 'DeveloperDiskImage.dmg.signature'])
88 if str(f).endswith(
'.dmg'):
90 if str(f).endswith(
'.dmg.signature'):
92 if not image
or not sig:
93 raise Exception(
'%s does not contain *.dmg and *.dmg.signature' %
96 self.
_run_run(
'mount developer image',
'ideviceimagemounter', image, sig)
102 def uninstall_app(attempt):
104 self.
m.
run(self.
m.step,
106 cmd=[
'ideviceinstaller',
'-U',
110 abort_on_failure=
False, fail_build_on_failure=
False)
115 cmd=[
'ideviceinstaller',
'-i', app_package],
116 between_attempts_fn=uninstall_app,
119 def step(self, name, cmd, **kwargs):
121 bundle_id =
'com.google.%s' % app_name
122 args = [bundle_id] + [str(ele)
for ele
in cmd[1:]]
126 self.
m.
run(self.
m.step, name, cmd=[
'idevicedebug',
'run'] + args)
131 self.
m.step,
'%s with full debug output' % name,
132 cmd=[
'python3', self.
module.resource(
'ios_debug_cmd.py')] + args)
136 full = self.
m.path[
'start_dir'].join(
137 'skia',
'platform_tools',
'ios',
'bin',
'ios_' + script)
138 self.
m.
run(self.
m.step,
139 name =
'%s %s' % (script, first),
140 cmd = [full, first] + list(rest),
161 full = self.
m.path[
'start_dir'].join(
162 'skia',
'platform_tools',
'ios',
'bin',
'ios_cat_file')
163 rv = self.
m.
run(self.
m.step,
164 name =
'cat_file %s' % path,
166 stdout=self.
m.raw_io.output(),
169 return rv.stdout.decode(
'utf-8').rstrip()
if rv
and rv.stdout
else None
_run(self, title, cmd, infra_step=False, **kwargs)
create_clean_device_dir(self, path)
_run(self, title, *cmd, **kwargs)
_run_ios_script(self, script, first, *rest)
read_file_on_device(self, path, **kwargs)
copy_file_to_device(self, host, device)
copy_directory_contents_to_device(self, host, device)
step(self, name, cmd, **kwargs)
copy_directory_contents_to_host(self, device, host)
__init__(self, m, app_name)