chore: Fix app
This commit is contained in:
+43
-1
@@ -15,8 +15,10 @@ import {
|
||||
findMissingLauncherResources,
|
||||
findStockCapacitorResources,
|
||||
isBrandLauncherBackgroundColor,
|
||||
NOTIFICATION_STATUS_ICON_NAME,
|
||||
readAdaptiveIconBackgroundColor,
|
||||
REQUIRED_LAUNCHER_ICON_FILES,
|
||||
REQUIRED_NOTIFICATION_ICON_FILES,
|
||||
REQUIRED_SPLASH_FILES,
|
||||
resolveIconPixelSize,
|
||||
SPLASH_ICON_RATIO
|
||||
@@ -32,7 +34,11 @@ function sha256OfResource(resRelativePath: string): string {
|
||||
}
|
||||
|
||||
describe('mobile-android-launcher-icon.rules', () => {
|
||||
const allRequired = [...REQUIRED_LAUNCHER_ICON_FILES, ...REQUIRED_SPLASH_FILES];
|
||||
const allRequired = [
|
||||
...REQUIRED_LAUNCHER_ICON_FILES,
|
||||
...REQUIRED_SPLASH_FILES,
|
||||
...REQUIRED_NOTIFICATION_ICON_FILES
|
||||
];
|
||||
const presentFiles = allRequired.filter((file) => existsSync(resolve(RES_DIR, file)));
|
||||
|
||||
it('keeps the brand mark inside the adaptive-icon safe zone', () => {
|
||||
@@ -45,6 +51,42 @@ describe('mobile-android-launcher-icon.rules', () => {
|
||||
expect(findMissingLauncherResources(presentFiles)).toEqual([]);
|
||||
});
|
||||
|
||||
it('ships a notification status-bar icon for every density', () => {
|
||||
expect(findMissingLauncherResources(presentFiles, REQUIRED_NOTIFICATION_ICON_FILES)).toEqual([]);
|
||||
});
|
||||
|
||||
it('references the notification status icon from the Capacitor config', () => {
|
||||
const capacitorConfig = readFileSync(resolve(process.cwd(), 'capacitor.config.ts'), 'utf8');
|
||||
|
||||
expect(capacitorConfig).toContain(`smallIcon: '${NOTIFICATION_STATUS_ICON_NAME}'`);
|
||||
});
|
||||
|
||||
it('renders the notification status icon as an alpha-only white glyph', async () => {
|
||||
const iconPath = resolve(RES_DIR, 'drawable-xxxhdpi/ic_stat_metoyou.png');
|
||||
const { data, info } = await sharp(iconPath).ensureAlpha()
|
||||
.raw()
|
||||
.toBuffer({ resolveWithObject: true });
|
||||
|
||||
let opaquePixels = 0;
|
||||
let transparentPixels = 0;
|
||||
|
||||
for (let offset = 0; offset < data.length; offset += info.channels) {
|
||||
const alpha = data[offset + 3];
|
||||
|
||||
if (alpha > 224) {
|
||||
opaquePixels += 1;
|
||||
expect(data[offset]).toBeGreaterThan(224);
|
||||
expect(data[offset + 1]).toBeGreaterThan(224);
|
||||
expect(data[offset + 2]).toBeGreaterThan(224);
|
||||
} else if (alpha < 32) {
|
||||
transparentPixels += 1;
|
||||
}
|
||||
}
|
||||
|
||||
expect(opaquePixels).toBeGreaterThan(0);
|
||||
expect(transparentPixels).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('replaces every stock Capacitor placeholder with the brand asset', () => {
|
||||
const hashByFile = Object.fromEntries(presentFiles.map((file) => [file, sha256OfResource(file)]));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user