Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(test): the Android manifest oracle checks the number, and says when it did not run

yhhaef5bff47857
diff --git a/desktop/tests/android-aab.test.ts b/desktop/tests/android-aab.test.ts
index 02f34bfc0..d5cb35dd9 100644
--- a/desktop/tests/android-aab.test.ts
+++ b/desktop/tests/android-aab.test.ts
@@ -123,8 +123,8 @@ const attr = (element: Element, name: string): Attribute | undefined =>
element.attributes.find((a) => a.name === name);
describe('assembling an App Bundle', () => {
- it('lays the app out the way the format requires, and signs every entry', () => {
- if (!hasPython) return;
+ it('lays the app out the way the format requires, and signs every entry', (ctx) => {
+ if (!hasPython) ctx.skip();
const result = verify(build());
expect(result.hasDex).toBe(true);
@@ -143,8 +143,8 @@ describe('assembling an App Bundle', () => {
expect(result.signedEntries).toBe(result.entries - 3);
});
- it('describes the app in protobuf, typed the way the platform reads it', () => {
- if (!hasPython) return;
+ it('describes the app in protobuf, typed the way the platform reads it', (ctx) => {
+ if (!hasPython) ctx.skip();
const { manifest } = verify(build());
expect(attr(manifest, 'package')?.value).toBe('com.example.demo');
@@ -195,8 +195,8 @@ describe('assembling an App Bundle', () => {
expect(attr(find(manifest, 'activity')!, 'name')?.value).toBe(binary.activity);
});
- it('carries the icon and the resource table the reference resolves through', () => {
- if (!hasPython) return;
+ it('carries the icon and the resource table the reference resolves through', (ctx) => {
+ if (!hasPython) ctx.skip();
const entries = readZip(readFileSync(build())).map((e) => e.name);
expect(entries).toContain('base/res/mipmap-xxxhdpi/ic_launcher.png');
@@ -217,8 +217,8 @@ describe('assembling an App Bundle', () => {
expect(resFiles).toContain('res/mipmap-xxxhdpi/ic_launcher.png');
});
- it('fails verification once an entry changes under the signature', () => {
- if (!hasPython) return;
+ it('fails verification once an entry changes under the signature', (ctx) => {
+ if (!hasPython) ctx.skip();
// Repacked with one file swapped and the ORIGINAL signature kept — which is
// exactly what tampering with a signed bundle looks like.
const entries = readZip(readFileSync(build())).map((e) => (
diff --git a/desktop/tests/android-apk.test.ts b/desktop/tests/android-apk.test.ts
index 0716756d9..c2d6cb348 100644
--- a/desktop/tests/android-apk.test.ts
+++ b/desktop/tests/android-apk.test.ts
@@ -21,6 +21,7 @@ import { fileURLToPath } from 'node:url';
import { assembleApk, apkFileName } from '../../build-tools/utils/apk.js';
import { debugSigningKey } from '../../build-tools/utils/androidKeystore.js';
import { compileManifest, ANDROID_ATTR_IDS } from '../../build-tools/utils/androidBinaryXml.js';
+import { symbolicAttrValue } from '../../build-tools/utils/androidAttrValues.js';
import { appResources, ICON_RESOURCE_ID, ICON_PATH } from '../../build-tools/utils/androidResources.js';
import { zipLayout, readZip } from '../../build-tools/utils/zip.js';
@@ -196,8 +197,8 @@ describe('what the platform reads out of the compiled manifest', () => {
});
describe('the manifest is compiled, not shelled out to aapt2', () => {
- it('uses the resource ids AOSP publishes — the platform resolves attributes by id', () => {
- if (!hasAndroguard) return;
+ it('uses the resource ids AOSP publishes — the platform resolves attributes by id', (ctx) => {
+ if (!hasAndroguard) ctx.skip();
const dump = execFileSync('python3', ['-c',
'from androguard.core.resources.public import SYSTEM_RESOURCES;'
+ 'import json;print(json.dumps(SYSTEM_RESOURCES["attributes"]["forward"]))',
@@ -209,8 +210,8 @@ describe('the manifest is compiled, not shelled out to aapt2', () => {
}
});
- it('round-trips through an independent decoder with every value intact', () => {
- if (!hasAndroguard) return;
+ it('round-trips through an independent decoder with every value intact', (ctx) => {
+ if (!hasAndroguard) ctx.skip();
const file = path.join(scratch, 'AndroidManifest.xml');
writeFileSync(file, compileManifest(readFileSync(MANIFEST_TEMPLATE, 'utf8')
.replace(/@APP_ID@/g, 'com.example.demo').replace(/@APP_NAME@/g, 'My Game')
@@ -227,7 +228,19 @@ describe('the manifest is compiled, not shelled out to aapt2', () => {
expect(xml).toContain('package="com.example.demo"');
expect(xml).toContain('android:versionCode="7"');
expect(xml).toContain('android:label="My Game"');
- expect(xml).toContain('android:screenOrientation="sensorPortrait"');
+ // A symbolic attribute survives as its NUMBER, and that is the fix rather
+ // than a wart: shipped as the word it looks like, the platform runs
+ // Integer.parseInt over it and refuses the whole package. Derived from the
+ // table the encoder resolves through, so the two cannot drift — asserting a
+ // bare 7 here would only restate a literal.
+ expect(xml).toContain(
+ `android:screenOrientation="${symbolicAttrValue('screenOrientation', 'sensorPortrait')}"`,
+ );
+ expect(xml).toContain(
+ `android:configChanges="${symbolicAttrValue(
+ 'configChanges', 'orientation|keyboardHidden|screenSize|screenLayout|density',
+ )}"`,
+ );
// A framework style survives as a REFERENCE to the id, not as its text.
expect(xml).toContain('android:theme="@android:01030007"');
expect(xml).toContain('android:name="android.app.NativeActivity"');
@@ -287,8 +300,8 @@ describe('assembling an APK', () => {
expect(checked).toBe(3);
});
- it('carries a launcher icon the platform can resolve, through a table we wrote', () => {
- if (!hasAndroguard) return;
+ it('carries a launcher icon the platform can resolve, through a table we wrote', (ctx) => {
+ if (!hasAndroguard) ctx.skip();
const apk = build();
const resolved = JSON.parse(execFileSync('python3', ['-c',
@@ -329,8 +342,8 @@ describe('assembling an APK', () => {
});
describe('the v2 signature, checked by an independent implementation', () => {
- it('verifies: the digest covers the file and the certificate carries the signing key', () => {
- if (!hasPython) return;
+ it('verifies: the digest covers the file and the certificate carries the signing key', (ctx) => {
+ if (!hasPython) ctx.skip();
const result = verify(build());
expect(result.signedV2).toBe(true);
@@ -347,8 +360,8 @@ describe('the v2 signature, checked by an independent implementation', () => {
}
});
- it('fails once a single byte of the payload changes', () => {
- if (!hasPython) return;
+ it('fails once a single byte of the payload changes', (ctx) => {
+ if (!hasPython) ctx.skip();
const apk = readFileSync(build());
// Somewhere inside the first entry's data, well before the signing block.
const tampered = Buffer.from(apk);
diff --git a/desktop/tests/zip.test.ts b/desktop/tests/zip.test.ts
index b5b2d5087..950c2fc61 100644
--- a/desktop/tests/zip.test.ts
+++ b/desktop/tests/zip.test.ts
@@ -32,8 +32,8 @@ beforeAll(() => {
afterAll(() => rmSync(dir, { recursive: true, force: true }));
describe('makeZip', () => {
- it('writes an archive a real unzip accepts, with the content intact', () => {
- if (!hasUnzip) return;
+ it('writes an archive a real unzip accepts, with the content intact', (ctx) => {
+ if (!hasUnzip) ctx.skip();
// Repetitive enough that deflate must actually be exercised (a stored-only
// archive would pass a naive round-trip but not prove the deflate path).
const html = `<!doctype html><html><body>${'<span>playable</span>'.repeat(500)}</body></html>`;
@@ -57,8 +57,8 @@ describe('makeZip', () => {
expect(a.equals(b)).toBe(true);
});
- it('round-trips binary content and multiple entries', () => {
- if (!hasUnzip) return;
+ it('round-trips binary content and multiple entries', (ctx) => {
+ if (!hasUnzip) ctx.skip();
const bin = Buffer.from(Array.from({ length: 1024 }, (_, i) => i & 0xff));
const zip = makeZip([
{ name: 'index.html', data: Buffer.from('<html></html>', 'utf8') },
@@ -73,14 +73,14 @@ describe('makeZip', () => {
});
describe('readZip / extractZip', () => {
- it('reads an archive a real `zip` produced, deflated and stored alike', () => {
+ it('reads an archive a real `zip` produced, deflated and stored alike', (ctx) => {
let hasZip = true;
try {
execFileSync('zip', ['-v'], { stdio: 'ignore' });
} catch {
hasZip = false;
}
- if (!hasZip) return;
+ if (!hasZip) ctx.skip();
const src = path.join(dir, 'src');
mkdirSync(path.join(src, 'nested'), { recursive: true });