53 lines
1.7 KiB
JavaScript
53 lines
1.7 KiB
JavaScript
import { readFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import Jimp from "jimp";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
const root = process.cwd();
|
|
|
|
async function expectOpaqueWhiteBackground(relativePath) {
|
|
const image = await Jimp.read(join(root, relativePath));
|
|
const { data, width, height } = image.bitmap;
|
|
|
|
for (let offset = 3; offset < data.length; offset += 4) {
|
|
if (data[offset] !== 255) {
|
|
throw new Error(`${relativePath} contains transparent pixels at byte offset ${offset}`);
|
|
}
|
|
}
|
|
|
|
for (const [x, y] of [
|
|
[0, 0],
|
|
[width - 1, 0],
|
|
[0, height - 1],
|
|
[width - 1, height - 1],
|
|
]) {
|
|
expect(Jimp.intToRGBA(image.getPixelColor(x, y))).toEqual({
|
|
r: 255,
|
|
g: 255,
|
|
b: 255,
|
|
a: 255,
|
|
});
|
|
}
|
|
}
|
|
|
|
describe("mobile app icon backgrounds", () => {
|
|
it("uses an opaque white background for the iOS marketing icon", async () => {
|
|
await expectOpaqueWhiteBackground("ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-1024.png");
|
|
});
|
|
|
|
it("uses an opaque white background for Android store and launcher icons", async () => {
|
|
await expectOpaqueWhiteBackground("store_icon.png");
|
|
|
|
for (const density of ["mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"]) {
|
|
await expectOpaqueWhiteBackground(`android/app/src/main/res/mipmap-${density}/ic_launcher.png`);
|
|
await expectOpaqueWhiteBackground(`android/app/src/main/res/mipmap-${density}/ic_launcher_round.png`);
|
|
}
|
|
|
|
const adaptiveBackground = await readFile(
|
|
join(root, "android/app/src/main/res/values/ic_launcher_background.xml"),
|
|
"utf8"
|
|
);
|
|
expect(adaptiveBackground).toContain("#FFFFFF");
|
|
});
|
|
});
|