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
@@ -53,7 +53,7 @@ test('controller skips unset preferences, deduplicates changes and forces reconn
|
||||
const method = controller.members.find(node => node.name?.getText(file) === 'pushHeadUpPreferences').getText(file);
|
||||
let prefs = { enabled: -1, angle: -1 };
|
||||
const { Harness } = evaluate(`export class Harness { ${method} }`, {
|
||||
global: { isAndroid: true }, getHeadUpPreferences: () => prefs,
|
||||
global: { isAndroid: true }, glassesTypeSetting: { get: () => 'g2' }, getHeadUpPreferences: () => prefs,
|
||||
});
|
||||
const h = new Harness(), calls = [];
|
||||
h.communicator = { configureHeadUpWake: async (...args) => calls.push(args) };
|
||||
@@ -74,3 +74,87 @@ test('controller skips unset preferences, deduplicates changes and forces reconn
|
||||
const connect = controller.members.find(node => node.name?.getText(file) === 'connect').getText(file);
|
||||
assert.match(connect, /pushHeadUpPreferences\(true\)/);
|
||||
});
|
||||
|
||||
function settingsMenuHarness(isIOS, model) {
|
||||
const file = ts.createSourceFile('settings-menus.ts', source('app/ui/dashboard/settings-menus.ts'), ts.ScriptTarget.Latest, true);
|
||||
const actual = new Set(['settingsSections', 'ringConnectionMenuItem', 'notificationFilterMenuItem']);
|
||||
const globals = { global: { isIOS }, NOTIFICATIONS_SETTINGS_SECTION: 'Notifications' };
|
||||
// Isolate the real menu construction from unrelated rendering/native dependencies.
|
||||
for (const node of file.statements) {
|
||||
if (ts.isImportDeclaration(node)) {
|
||||
for (const binding of node.importClause?.namedBindings?.elements ?? []) {
|
||||
const name = binding.name.text;
|
||||
globals[name] = Object.assign(() => ({}), { label: name, get: () => '' });
|
||||
}
|
||||
} else if (ts.isFunctionDeclaration(node) && !actual.has(node.name.text)) {
|
||||
globals[node.name.text] = () => ({});
|
||||
}
|
||||
}
|
||||
const row = setting => ({ label: setting.label });
|
||||
Object.assign(globals, {
|
||||
enumSettingMenuItem: row, toggleSettingMenuItem: row, textSettingMenuItem: row,
|
||||
glassesTypeSetting: { get: () => model },
|
||||
customizationRows: () => () => [], whisperServerMenuItems: () => [],
|
||||
submenuItem: (label, onSelect, options) => ({ label, onSelect, ...options }),
|
||||
});
|
||||
const code = file.statements.filter(node => ts.isFunctionDeclaration(node) && actual.has(node.name.text))
|
||||
.map(node => `export ${node.getText(file)}`).join('\n');
|
||||
return evaluate(code, globals);
|
||||
}
|
||||
|
||||
test('head-up controls are offered only for Android G2 model selection', () => {
|
||||
for (const isIOS of [false, true]) {
|
||||
for (const model of ['g2', 'g1', 'rayneo-io']) {
|
||||
const display = settingsMenuHarness(isIOS, model).settingsSections().find(section => section.label === 'Display');
|
||||
for (const label of ['headUpWakeSetting', 'headUpAngleSetting']) {
|
||||
assert.equal(display.items.some(item => item.label === label), !isIOS && model === 'g2', `${isIOS ? 'iOS' : 'Android'} ${model} ${label}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('notification filter description matches glasses-wide filtering while keeping phone notifications', () => {
|
||||
const item = settingsMenuHarness(false, 'g2').notificationFilterMenuItem();
|
||||
assert.equal(item.description, 'Disabled apps are hidden from glasses popups, the notification list, and the tray. Their notifications remain on your phone.');
|
||||
});
|
||||
|
||||
test('Developer ring connection stays model-aware on iOS and Android', () => {
|
||||
for (const isIOS of [false, true]) {
|
||||
for (const model of ['g2', 'g1', 'rayneo-io']) {
|
||||
const section = settingsMenuHarness(isIOS, model).settingsSections().find(section => section.label === 'Developer');
|
||||
const ring = section.items.find(item => item.label === 'ringConnectionModeSetting');
|
||||
assert.equal(typeof ring.disabled, 'function', 'use the model-aware ring helper');
|
||||
assert.equal(ring.disabled(), model !== 'g2', `${isIOS ? 'iOS' : 'Android'} ${model}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function controllerForModel(getModel, isAndroid, preferences) {
|
||||
const file = ts.createSourceFile('controller.ts', source('app/g2/dashboard-controller.ts'), ts.ScriptTarget.Latest, true);
|
||||
const controller = file.statements.find(node => ts.isClassDeclaration(node) && node.name.text === 'DashboardController');
|
||||
const method = controller.members.find(node => node.name?.getText(file) === 'pushHeadUpPreferences').getText(file);
|
||||
const { Harness } = evaluate(`export class Harness { ${method} }`, {
|
||||
global: { isAndroid }, glassesTypeSetting: { get: getModel }, getHeadUpPreferences: () => preferences,
|
||||
});
|
||||
return new Harness();
|
||||
}
|
||||
|
||||
test('controller sends stored head-up choices only to Android G2, including forced reconnects', () => {
|
||||
for (const isAndroid of [true, false]) {
|
||||
let model = 'g1';
|
||||
const preferences = { enabled: 1, angle: 35 };
|
||||
const h = controllerForModel(() => model, isAndroid, preferences);
|
||||
const calls = [];
|
||||
h.communicator = { configureHeadUpWake: async (...args) => calls.push(args) };
|
||||
for (model of ['g1', 'rayneo-io']) {
|
||||
h.pushHeadUpPreferences();
|
||||
h.pushHeadUpPreferences(true);
|
||||
assert.equal(calls.length, 0, `${isAndroid ? 'Android' : 'iOS'} ${model}`);
|
||||
assert.equal(h.lastPushedHeadUp, undefined, 'skipped models must not consume dedup state');
|
||||
}
|
||||
model = 'g2';
|
||||
h.pushHeadUpPreferences();
|
||||
assert.deepEqual(calls, isAndroid ? [[1, 35]] : []);
|
||||
assert.deepEqual(preferences, { enabled: 1, angle: 35 }, 'model changes preserve stored choices');
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user