forked from Blendman974/faceclaw
Merge upstream main preserving custom feature integrations
This commit is contained in:
commit
6150a1ac57
228 files changed
+16844
-1388
No files matched your search
@@ -23,6 +23,42 @@ function store(settings = new Map()) {
|
||||
}
|
||||
const mail = { packageName: 'com.mail', appName: 'Mail' };
|
||||
|
||||
/** dashboard-settings.ts over the same in-memory store, with `prefs` as its notification-sources. */
|
||||
function dashboardSettings(settings, prefs) {
|
||||
return evaluate(source('app/ui/dashboard-settings.ts'), (id) => {
|
||||
if (id.includes('settings-store')) return {
|
||||
onSettingsStoreChanged() {}, getStringSetting: (key, fallback) => settings.get(key) ?? fallback,
|
||||
setStringSetting: (key, value) => settings.set(key, value),
|
||||
getBooleanSetting: (key, fallback) => settings.get(key) ?? fallback, setBooleanSetting: (key, value) => settings.set(key, value),
|
||||
};
|
||||
if (id.includes('notification-sources')) return prefs;
|
||||
if (id.includes('brightness-curve')) return require('../.test-build/app/g2/brightness-curve.js');
|
||||
if (id.includes('animation-speed')) return require('../.test-build/app/ui/animation-speed.js');
|
||||
if (id.includes('transcription-language')) return load('app/native/transcription-language.ts');
|
||||
return { Layer: class {}, ASSISTANT_MODEL_CHOICES: [] };
|
||||
}, { global: { isIOS: false } });
|
||||
}
|
||||
|
||||
test('"Display new notifications" defaults to 15s; Off stops every popup, the filter still mutes single apps', () => {
|
||||
const settings = new Map();
|
||||
const prefs = store(settings);
|
||||
const api = dashboardSettings(settings, prefs);
|
||||
assert.equal(api.newNotificationDisplaySetting.get(), '15s');
|
||||
// Array.from: the module's arrays come from its own VM realm.
|
||||
const values = Array.from(api.newNotificationDisplaySetting.values);
|
||||
assert.deepEqual(values.map((value) => api.newNotificationDisplaySetting.displayValue(value)),
|
||||
['Off', 'Until dismissed', '5s', '15s', '1min']);
|
||||
assert.deepEqual(values.map(api.newNotificationDisplayTimeoutMs), [null, null, 5_000, 15_000, 60_000]);
|
||||
assert.equal(api.shouldPopUpNewNotification(mail.packageName), true);
|
||||
prefs.setNotificationSourceEnabled(mail, false);
|
||||
assert.equal(api.shouldPopUpNewNotification(mail.packageName), false);
|
||||
assert.equal(api.shouldPopUpNewNotification('com.other'), true);
|
||||
api.newNotificationDisplaySetting.set('off');
|
||||
assert.equal(api.shouldPopUpNewNotification('com.other'), false);
|
||||
api.newNotificationDisplaySetting.set('until-dismissed');
|
||||
assert.equal(api.shouldPopUpNewNotification('com.other'), true);
|
||||
});
|
||||
|
||||
test('sources default on and retain per-package choices and names across restart and rediscovery', () => {
|
||||
const settings = new Map();
|
||||
let prefs = store(settings);
|
||||
@@ -88,7 +124,7 @@ function ui(fontSize = 12) {
|
||||
'../util/render-freshness': { renderPassAllowsStaleData: () => false },
|
||||
'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
|
||||
'./metrics': load('app/ui/metrics.ts'),
|
||||
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), './animation-speed': require('../.test-build/app/ui/animation-speed.js'), '../native/settings-store': { getStringSetting: (_key, fallback) => fallback },
|
||||
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), './animation-speed': require('../.test-build/app/ui/animation-speed.js'), '../native/settings-store': { getStringSetting: (_key, fallback) => fallback }, '../graphics/screen-size': { screenWidth: () => 640, screenHeight: () => 480 },
|
||||
'./gestures': {},
|
||||
};
|
||||
const requireModule = (name) => {
|
||||
@@ -258,14 +294,16 @@ test('controller filters before waking or opening a popup, and still refreshes t
|
||||
const members = ['handleAndroidNotificationPosted', 'handleAndroidNotificationRemoved', 'popUpAndroidNotification']
|
||||
.map((name) => controller.members.find((node) => node.name?.getText(file) === name).getText(file));
|
||||
const { NotificationPopupDelay, notificationPopupDelayMs } = require('../.test-build/app/ui/shell/notification-popup-delay.js');
|
||||
const prefs = store();
|
||||
const settings = new Map();
|
||||
const prefs = store(settings);
|
||||
const { newNotificationDisplaySetting, shouldPopUpNewNotification } = dashboardSettings(settings, prefs);
|
||||
let active = [{ ...mail, key: 'key' }];
|
||||
let wakes = 0, popups = 0, renders = 0;
|
||||
const removed = [];
|
||||
const { Harness } = evaluate(`export class Harness { ${members.join('\n')} }`, null, {
|
||||
ALL_NOTIFICATIONS: 0x7fffffff,
|
||||
readActiveNotifications: () => active,
|
||||
shouldShowNotificationOnGlasses: prefs.shouldShowNotificationOnGlasses,
|
||||
shouldPopUpNewNotification,
|
||||
notificationPopupDelayMs,
|
||||
shell: {
|
||||
isScreenOn: () => false,
|
||||
@@ -317,6 +355,18 @@ test('controller filters before waking or opening a popup, and still refreshes t
|
||||
prefs.setNotificationSourceEnabled(mail, false);
|
||||
elapse();
|
||||
assert.equal(popups, 1);
|
||||
|
||||
// "Display new notifications: Off" holds back every app's popup, also once the delay is over.
|
||||
prefs.setNotificationSourceEnabled(mail, true);
|
||||
newNotificationDisplaySetting.set('off');
|
||||
instance.handleAndroidNotificationPosted('key');
|
||||
elapse();
|
||||
newNotificationDisplaySetting.set('15s');
|
||||
instance.handleAndroidNotificationPosted('key');
|
||||
newNotificationDisplaySetting.set('off');
|
||||
elapse();
|
||||
assert.equal(wakes, 1);
|
||||
assert.equal(popups, 1);
|
||||
});
|
||||
|
||||
test('Android display filters before limits and reapplies preferences to cached tray icons', () => {
|
||||
|
||||
Reference in new issue
Block a user