Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/platform-apple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
"types": "./src/physical-device-facade.ts",
"default": "./src/physical-device-facade.ts"
},
"./plist": {
"types": "./src/plist-facade.ts",
"default": "./src/plist-facade.ts"
},
"./snapshot-source": {
"types": "./src/snapshot-source-facade.ts",
"default": "./src/snapshot-source-facade.ts"
Expand Down Expand Up @@ -93,7 +97,6 @@
}
},
"devDependencies": {
"@agent-device/test-kit": "workspace:*",
"plist": "5.0.0"
"@agent-device/test-kit": "workspace:*"
}
}
Binary file not shown.
79 changes: 79 additions & 0 deletions packages/platform-apple/src/core/__tests__/fixtures/info-xml.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>24G90</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>Example &amp; App</string>
<key>CFBundleExecutable</key>
<string>ExampleApp</string>
<key>CFBundleIdentifier</key>
<string>com.example.app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>ExampleApp</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.2</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>com.example.app.expo</string>
<key>CFBundleURLSchemes</key>
<array>
<string>exp+example</string>
<string>example</string>
</array>
</dict>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb1234567890</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>142</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tel</string>
<string>mailto</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
<string>15.1</string>
<key>NSCameraUsageDescription</key>
<string>Example uses the camera to scan barcodes.</string>
<key>NSMicrophoneUsageDescription</key>
<string/>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIDesignRequiresCompatibility</key>
<false/>
<key>UILaunchStoryboardName</key>
<string>BootScreen</string>
<key>UIPrerenderedIcon</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
</array>
</dict>
</plist>
Binary file not shown.
22 changes: 22 additions & 0 deletions packages/platform-apple/src/core/__tests__/fixtures/ints-xml.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Neg</key>
<integer>-12</integer>
<key>Neg32</key>
<integer>-2147483648</integer>
<key>SafeMax</key>
<integer>9007199254740991</integer>
<key>U16Max</key>
<integer>65535</integer>
<key>U32Max</key>
<integer>4294967295</integer>
<key>U8High</key>
<integer>128</integer>
<key>U8Max</key>
<integer>255</integer>
<key>Zero</key>
<integer>0</integer>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>String</key>
<string>plain</string>
<key>EmptyString</key>
<string></string>
<key>UnicodeString</key>
<string>Zürich — 東京</string>
<key>Integer</key>
<integer>-12</integer>
<key>BigInteger</key>
<integer>9007199254740991</integer>
<key>Real</key>
<real>2.5</real>
<key>True</key>
<true/>
<key>False</key>
<false/>
<key>Null</key>
<null/>
<key>Date</key>
<date>2026-11-22T09:15:30Z</date>
<key>Data</key>
<data>
iVBORw0KGgo=
</data>
<key>Array</key>
<array>
<string>one</string>
<integer>2</integer>
</array>
<key>EmptyArray</key>
<array/>
<key>Nested</key>
<dict>
<key>Inner</key>
<dict>
<key>Flag</key>
<true/>
</dict>
<key>Number</key>
<integer>7</integer>
</dict>
<key>EmptyDict</key>
<dict/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key> PaddedKey </key>
<string> PaddedValue </string>
<key>Blank</key>
<string> </string>
<key>Tabbed</key>
<string> x </string>
<key>CdataSplit</key>
<string>foo<![CDATA[ bar ]]>baz</string>
<key>CdataSpaced</key>
<string>
<![CDATA[ spaced ]]>
</string>
<key>Entities</key>
<string> &amp; </string>
<key>Multiline</key>
<string>line1
line2</string>
<key>URL</key>
<string>https://example.com/a?b=1&amp;c=2</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { beforeEach, test, vi } from 'vitest';
import { build, type PlistValue } from 'plist';
import { mkdtempForTest } from '../../__tests__/tmp-dir.ts';
import type { DeviceInfo } from '@agent-device/kernel/device';
import { IOS_TEST_SIMULATOR } from './apple-core-stub-helpers.ts';
Expand All @@ -24,21 +23,33 @@ beforeEach(async () => {
vi.mocked(runXcrun).mockClear();
});

function writePreferences(contents: string | Record<string, PlistValue>): void {
/** Builds an XML preferences document from entries whose values are already plist XML. */
function plistEntries(entries: Record<string, string>): string {
const body = Object.entries(entries)
.map(([key, value]) => `<key>${key}</key>${value}`)
.join('');
return `<?xml version="1.0" encoding="UTF-8"?>\n<plist version="1.0"><dict>${body}</dict></plist>`;
}

/** Writes the simulator preferences file from entries whose values are already plist XML. */
function writePreferences(entries: Record<string, string>): void;
/** Writes the simulator preferences file verbatim: damaged bytes, or bytes copied from a fixture. */
function writePreferences(contents: string): void;
function writePreferences(contents: Record<string, string> | string): void {
const dir = path.join(setPath, device.id, 'data/Library/Preferences');
fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(
path.join(dir, 'com.apple.Accessibility.plist'),
typeof contents === 'string' ? contents : build(contents),
typeof contents === 'string' ? contents : plistEntries(contents),
);
}

const wrote = () => vi.mocked(runXcrun).mock.calls.some(([args]) => args.includes('defaults'));

for (const [label, preferences] of [
['the key is on', { ApplicationAccessibilityEnabled: true }],
['the key is 1', { ApplicationAccessibilityEnabled: 1 }],
['the key is absent', { ReduceMotionEnabled: false }],
['the key is on', { ApplicationAccessibilityEnabled: '<true/>' }],
['the key is 1', { ApplicationAccessibilityEnabled: '<integer>1</integer>' }],
['the key is absent', { ReduceMotionEnabled: '<false/>' }],
] as const) {
test(`skips the guest write when ${label} on this host`, async () => {
writePreferences(preferences);
Expand All @@ -48,8 +59,11 @@ for (const [label, preferences] of [
}

for (const [label, write] of [
['the key is off', () => writePreferences({ ApplicationAccessibilityEnabled: false })],
['the key is 0', () => writePreferences({ ApplicationAccessibilityEnabled: 0 })],
['the key is off', () => writePreferences({ ApplicationAccessibilityEnabled: '<false/>' })],
[
'the key is 0',
() => writePreferences({ ApplicationAccessibilityEnabled: '<integer>0</integer>' }),
],
['the file is malformed', () => writePreferences('bplist00 truncated')],
['the file is missing', () => {}],
] as const) {
Expand All @@ -61,9 +75,9 @@ for (const [label, write] of [
}

test('reads again on every launch, so a later teardown is seen', async () => {
writePreferences({ ApplicationAccessibilityEnabled: true });
writePreferences({ ApplicationAccessibilityEnabled: '<true/>' });
await prepareIosSimulatorAccessibility(device);
writePreferences({ ApplicationAccessibilityEnabled: false });
writePreferences({ ApplicationAccessibilityEnabled: '<false/>' });
await prepareIosSimulatorAccessibility(device);
assert.equal(
vi.mocked(runXcrun).mock.calls.filter(([args]) => args.includes('defaults')).length,
Expand All @@ -88,7 +102,7 @@ for (const [value, expectWrite] of [
}

test('a scoped (remote) tool provider writes even when this host has an on key', async () => {
writePreferences({ ApplicationAccessibilityEnabled: true });
writePreferences({ ApplicationAccessibilityEnabled: '<true/>' });
await withAppleToolProvider({} as Parameters<typeof withAppleToolProvider>[0], () =>
prepareIosSimulatorAccessibility(device),
);
Expand Down
Loading
Loading