forked from Blendman974/faceclaw
Show G2 charging case on Settings tab and charging view rather than main activity
This commit is contained in:
1 parent
5e729d1236
commit
27756913d0
17 files changed
+277
-83
No files matched your search
@@ -1,13 +1,22 @@
|
||||
const test = require("node:test");
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const { chargingDisplayLabel, glassesDisplayAsleep, glassesDisplayLabel } = require("../.test-build/app/g2/glasses-display-state.js");
|
||||
const {
|
||||
chargingDisplayLabel,
|
||||
chargingPreviewMessage,
|
||||
formatBatteryLine,
|
||||
glassesDisplayAsleep,
|
||||
glassesDisplayDetail,
|
||||
glassesDisplayLabel,
|
||||
} = require("../.test-build/app/g2/glasses-display-state.js");
|
||||
|
||||
const connected = {
|
||||
phase: "connected",
|
||||
silentMode: false,
|
||||
screenOn: true,
|
||||
battery: 72,
|
||||
caseBattery: null,
|
||||
caseCharging: null,
|
||||
foregroundTitle: "Music",
|
||||
previewMode: false,
|
||||
};
|
||||
@@ -37,3 +46,33 @@ test("charging takes precedence and includes the last-known G2 battery", () => {
|
||||
assert.equal(chargingDisplayLabel(-1), "Charging");
|
||||
assert.equal(chargingDisplayLabel(101), "Charging");
|
||||
});
|
||||
|
||||
test("while charging, the case level is the watch face's second line and joins the mirror's message", () => {
|
||||
const charging = { ...connected, phase: "charging", caseBattery: 64, caseCharging: false };
|
||||
assert.equal(glassesDisplayLabel(charging), "Charging · G2 72%");
|
||||
assert.equal(glassesDisplayDetail(charging), "Case 64%");
|
||||
assert.equal(glassesDisplayDetail({ ...charging, caseCharging: true }), "Case 64% ⚡");
|
||||
assert.equal(chargingPreviewMessage(charging), "Charging · G2 72% · Case 64%");
|
||||
// No case level yet: the label alone.
|
||||
assert.equal(glassesDisplayDetail({ ...charging, caseBattery: null }), "");
|
||||
assert.equal(chargingPreviewMessage({ ...charging, caseBattery: null, battery: null }), "Charging");
|
||||
// Out of the case the level is stale, so it is not shown.
|
||||
assert.equal(glassesDisplayDetail({ ...connected, caseBattery: 64 }), "");
|
||||
});
|
||||
|
||||
const levels = {
|
||||
headset: 87, headsetCharging: true, case: 64, caseCharging: true, ring: 72, ringCharging: false,
|
||||
};
|
||||
|
||||
test("the Settings battery line lists each known level, with ⚡ only while the reading is live", () => {
|
||||
assert.equal(formatBatteryLine(levels, true), "G2 87% ⚡ · Case 64% ⚡ · R1 72%");
|
||||
// Without a link to the glasses their charging state and the case's are stale.
|
||||
assert.equal(formatBatteryLine({ ...levels, ringCharging: true }, false), "G2 87% · Case 64% · R1 72% ⚡");
|
||||
// caseCharging is null while the glasses are out of the case.
|
||||
assert.equal(formatBatteryLine({ ...levels, caseCharging: null }, true), "G2 87% ⚡ · Case 64% · R1 72%");
|
||||
assert.equal(formatBatteryLine({ ...levels, case: null, ring: null }, true), "G2 87% ⚡");
|
||||
assert.equal(
|
||||
formatBatteryLine({ headset: null, headsetCharging: null, case: null, caseCharging: null, ring: null, ringCharging: null }, true),
|
||||
"",
|
||||
);
|
||||
});
|
||||
@@ -218,6 +218,9 @@ test('iOS bandwidth footer toggles live, polls only in foreground and resets its
|
||||
'../g2/ios-peripheral-identity': { deviceAddressError: () => 'no test devices' },
|
||||
'./onboarding-state': { isPreviewOnlyMode: () => false },
|
||||
'../g2/reconnect-policy': { isAutoReconnectSuppressed: () => false },
|
||||
'../g2/glasses-display-state': require('../.test-build/app/g2/glasses-display-state.js'),
|
||||
'../ui/shell/shell': { shell: { onBatteryLevelsChanged: () => () => {}, getBatteryLevels: () => ({
|
||||
headset: null, headsetCharging: null, case: null, caseCharging: null, ring: null, ringCharging: null }) } },
|
||||
};
|
||||
modules['./keyboard-input-view-model'] = load('app/phone-ui/keyboard-input-view-model.ts', { require: id => modules[id] });
|
||||
modules['./remote-controls-view-model'] = load('app/phone-ui/remote-controls-view-model.ts', { require: id => modules[id] });
|
||||
|
||||
Reference in new issue
Block a user