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',
31 'IOS_BUNDLE_ID':
'com.google.%s' % self.
app_name,
32 'IOS_MOUNT_POINT': self.
m.vars.workdir.join(
'mnt_iosdevice'),
38 def _run(self, title, *cmd, **kwargs):
41 'sleep before attempt %d' % attempt,
44 return self.
m.run.with_retry(self.
m.step, title, 3, cmd=list(cmd),
45 between_attempts_fn=sleep, **kwargs)
56 self.
m.
run(self.
m.step,
'check if device is paired',
57 cmd=[
'idevicepair',
'validate'],
58 infra_step=
True, abort_on_failure=
True,
59 fail_build_on_failure=
False)
60 except self.
m.step.StepFailure:
61 self.
_run_run(
'pair device',
'idevicepair',
'pair')
64 image_info = self.
_run_run(
'list mounted image',
65 'ideviceimagemounter',
'--list',
66 stdout=self.
m.raw_io.output())
68 image_info.stdout.decode(
'utf-8').strip()
if image_info.stdout
else '')
70 if 'ImageSignature' not in image_info_out:
71 image_pkgs = self.
m.file.glob_paths(
'locate ios-dev-image package',
72 self.
m.path.start_dir,
74 test_data=[
'ios-dev-image-13.2'])
75 if len(image_pkgs) != 1:
76 raise Exception(
'glob for ios-dev-image* returned %s'
79 image_pkg = image_pkgs[0]
80 contents = self.
m.file.listdir(
81 'locate image and signature', image_pkg,
82 test_data=[
'DeveloperDiskImage.dmg',
83 'DeveloperDiskImage.dmg.signature'])
87 if str(f).endswith(
'.dmg'):
89 if str(f).endswith(
'.dmg.signature'):
91 if not image
or not sig:
92 raise Exception(
'%s does not contain *.dmg and *.dmg.signature' %
95 self.
_run_run(
'mount developer image',
'ideviceimagemounter', image, sig)
101 def uninstall_app(attempt):
103 self.
m.
run(self.
m.step,
105 cmd=[
'ideviceinstaller',
'-U',
109 abort_on_failure=
False, fail_build_on_failure=
False)
112 self.
m.run.with_retry(self.
m.step,
'install %s' % self.
app_name,
114 cmd=[
'ideviceinstaller',
'-i', app_package],
115 between_attempts_fn=uninstall_app,
118 def step(self, name, cmd, **kwargs):
120 bundle_id =
'com.google.%s' % app_name
121 args = [bundle_id] + [str(ele)
for ele
in cmd[1:]]
125 self.
m.
run(self.
m.step, name, cmd=[
'idevicedebug',
'run'] + args)
130 self.
m.step,
'%s with full debug output' % name,
133 def _run_ios_script(self, script, first, *rest):
135 full = self.
m.path.start_dir.join(
136 'skia',
'platform_tools',
'ios',
'bin',
'ios_' + script)
137 self.
m.
run(self.
m.step,
138 name =
'%s %s' % (script, first),
139 cmd = [full, first] + list(rest),
160 full = self.
m.path.start_dir.join(
161 'skia',
'platform_tools',
'ios',
'bin',
'ios_cat_file')
162 rv = self.
m.
run(self.
m.step,
163 name =
'cat_file %s' % path,
165 stdout=self.
m.raw_io.output(),
168 return rv.stdout.decode(
'utf-8').rstrip()
if rv
and rv.stdout
else None
static SkString resource(SkPDFResourceType type, int index)
def _run(self, title, cmd, infra_step=False, **kwargs)
def copy_directory_contents_to_host(self, device, host)
def read_file_on_device(self, path, **kwargs)
def step(self, name, cmd, **kwargs)
def __init__(self, m, app_name)
def remove_file_on_device(self, path)
def create_clean_device_dir(self, path)
def copy_file_to_device(self, host, device)
def copy_directory_contents_to_device(self, host, device)
def _run(self, title, *cmd, **kwargs)
def _run_ios_script(self, script, first, *rest)