Remove some unused test code

This commit is contained in:
James Babcock committed 2026-09-30 13:37:28 -07:00
1 parent f7fa4addc0
commit 81b7f3df64
7 files changed
-120

No files matched your search

-6
View File
@@ -3,12 +3,6 @@ import { registerShareIntentHandler } from './native/share-intents'
import { installNativeUserAgent } from './util/http'
import { registerPhoneRotation } from './native/phone-rotation'
import { runKotlinBridgeSmokeTest } from './native/kotlin-bridge'
declare const __DEV__: boolean;
if (__DEV__) runKotlinBridgeSmokeTest()
installNativeUserAgent()
registerShareIntentHandler()
registerPhoneRotation()
-4
View File
@@ -1,9 +1,5 @@
import { Application, Frame } from '@nativescript/core'
import { runKotlinBridgeSmokeTest } from './native/kotlin-bridge'
declare const FaceclawConfigPort: any
declare const __DEV__: boolean;
if (__DEV__) runKotlinBridgeSmokeTest()
// Apply transferred preferences before settings getters or app workers load.
FaceclawConfigPort.processPendingRequest()
-38
View File
@@ -1,38 +0,0 @@
import { isAndroid } from "@nativescript/core";
import { createKotlinBridge } from "./kotlin-platform";
/** Exercise the real native metadata and both directions of return values. */
export function runKotlinBridgeSmokeTest(): void {
try {
const bridge = createKotlinBridge();
const platform = bridge.platform();
const thread = bridge.threadName();
const callerOnMain = bridge.isMainThread();
const greeting = bridge.greet("Faceclaw");
const message = "Faceclaw \u2194 Kotlin \ud83d\udc53";
let callbackCount = 0;
let callbackMessage = "";
let callbackOnMain = false;
// Validate after returning; never throw from a native callback.
const reply = bridge.roundTrip(message, (value: string): string => {
callbackCount++;
callbackMessage = value;
callbackOnMain = bridge.isMainThread();
return `TypeScript received: ${value}`;
});
if (greeting !== "Hello, Faceclaw, from Kotlin"
|| platform !== (isAndroid ? "Android" : "iOS")
|| !thread || !callerOnMain || !callbackOnMain
|| callbackCount !== 1
|| callbackMessage !== `Kotlin received: ${message}`
|| reply !== `Kotlin received callback: TypeScript received: Kotlin received: ${message}`) {
throw new Error(`Unexpected Kotlin bridge result: ${JSON.stringify({
platform, thread, callerOnMain, callbackOnMain, greeting, callbackCount, callbackMessage, reply,
})}`);
}
console.log("FACECLAW_KOTLIN_BRIDGE_PASS " + JSON.stringify({ platform, thread, reply }));
} catch (error) {
// Diagnostics must not prevent the rest of the app from launching.
console.error(`FACECLAW_KOTLIN_BRIDGE_FAIL ${error}`);
}
}
-2
View File
@@ -1,4 +1,3 @@
import { runKotlinProtocolSmokeTest } from './kotlin-protocol-smoke';
import type { KotlinBridge } from './kotlin-platform';
// Handwritten declarations for the small native surface, checked against the
@@ -20,7 +19,6 @@ declare namespace com.faceclaw.shared {
}
export function createKotlinBridge(): KotlinBridge {
runKotlinProtocolSmokeTest();
const bridge = new com.faceclaw.shared.KotlinBridge();
return {
platform: () => bridge.platform(),
-2
View File
@@ -1,4 +1,3 @@
import { runKotlinProtocolSmokeTest } from './kotlin-protocol-smoke.ios';
import type { KotlinBridge } from './kotlin-platform';
// Handwritten declarations matching FaceclawKit's Objective-C header.
@@ -27,7 +26,6 @@ class KotlinCallback extends NSObject implements FaceclawKitKotlinBridgeListener
}
export function createKotlinBridge(): KotlinBridge {
runKotlinProtocolSmokeTest();
const bridge = FaceclawKitKotlinBridge.alloc().init();
return {
platform: () => bridge.platform(),
-46
View File
@@ -1,46 +0,0 @@
import { GrayImage } from "../graphics/image"
import { encodeShellScene } from "../graphics/shell-scene"
import { decodeImageBytes } from './image-bytes.ios'
import * as protocol from '../g2/ble-protocol.ios'
import { SurfaceCompositor } from '../graphics/surface-compositor.ios'
import { lvglMetrics } from './lvgl-font.ios'
/** Development-only checks of real NativeScript selectors and bulk data crossings. */
export function runKotlinProtocolSmokeTest(): void {
const hex = (data: Uint8Array) => Array.from(data, byte => byte.toString(16).padStart(2, '0')).join('')
const assert = (condition: boolean, what: string) => { if (!condition) throw new Error(`Kotlin protocol bridge: ${what}`) }
const auth = protocol.authentication(101)
assert(hex(auth) === '080410651a0408011004', 'authentication')
assert(protocol.crc16(new Uint8Array([1, 2, 3])) === 0xadad, 'CRC')
const receiver = new protocol.MessageReceiver()
const frame = protocol.frameMessage(auth, 128, 0, 64)[0]
const received = receiver.receive('test', frame)
assert(received.length === 1 && received[0].magic === 101 && hex(received[0].payload) === hex(auth), 'reassembly')
const payload = protocol.bytes(13, protocol.bytes(3, protocol.concat(protocol.integer(1, 12), protocol.integer(2, 2))))
const event = protocol.decodeGlassesInput({ sid: 224, flag: 1, payload, command: 0, magic: 0 })
assert(event?.kind === 'display-wake' && event.eventSource === 2, 'event')
const c = new SurfaceCompositor(3, 2)
c.configureSurface('test', { x: 0, y: 0, width: 3, height: 2, zOrder: 0, transparency: 'opaque' })
c.submitSurfaceFrame('test', new Uint8Array([0, 16, 255, 32, 48, 64]), { x: 0, y: 0, width: 3, height: 2 })
assert(hex(c.composite()) === '0010ff203040', 'composition')
assert(hex(protocol.packGray4(c.composite(), 3, 2)) === '01f02340', 'packing')
c.setShellScene(new Uint8Array([1,0,1,0,0,0,0,0,1,0,1,0,128,0,0,0,0,0,255]))
assert(hex(c.composite()) === 'f00070101020', 'shell scene bridge and 4bpp composition')
c.setScreenBlanked(true); assert(c.composite().every(p => p === 0), 'blanking')
const selectedSurface = new GrayImage(8, 4, 1)
selectedSurface.drawMenuSelection(new GrayImage(4, 2, 255), 1, 1, 16, 48, 0, 2)
const selectedPreview = new SurfaceCompositor(8, 4)
selectedPreview.setShellScene(encodeShellScene([{ image: selectedSurface, x: 0, y: 0, shellKey: 100 }]))
const selectedPixels = selectedPreview.composite()
assert(selectedPixels[10] === 240 && selectedPixels[9] === 0, 'menu selection depth and bridge')
assert(lvglMetrics('/nonexistent/faceclaw-font').length === 0, 'font bridge')
const compass = protocol.decodeCompassInput({ sid: 8, flag: 1, command: 15, magic: 0,
payload: new Uint8Array([8, 15, 16, 0, 82, 3, 8, 231, 2, 162, 6, 12, 67, 77, 1, 3, 2, 3, 140, 0, 152, 186, 220, 254]) })
if (compass?.headingDegrees !== 359 || compass.diagnostics?.sampleTimeMs !== 0xfedcba98)
throw new Error('Kotlin compass notification mismatch')
const png = NSData.alloc().initWithBase64EncodedStringOptions('iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAEklEQVR4nGP4z8DAAMIM/4EAAB/uBfsL2WiLAAAAAElFTkSuQmCC', 0 as NSDataBase64DecodingOptions)
const decoded = decodeImageBytes(interop.bufferFromData(png), 2, 2)
assert(!!decoded && Array.from(decoded.pixels).join(',') === '54,182,18,255', 'native map image orientation and grayscale')
assert(decodeImageBytes(new ArrayBuffer(0), 2, 2) === null, 'invalid map image')
console.log('FACECLAW_KOTLIN_PROTOCOL_PASS iOS')
}
-22
View File
@@ -1,22 +0,0 @@
import { copyToJavaByteBuffer } from './java-direct-buffer'
declare const com: any
/** Development-only checks of NativeScript metadata and bulk ByteBuffer crossings. */
export function runKotlinProtocolSmokeTest(): void {
const native = com.faceclaw.app
const hex = (data: any) => Array.from({ length: data.length }, (_, i) => (data[i] & 255).toString(16).padStart(2, '0')).join('')
const assert = (condition: boolean, what: string) => { if (!condition) throw new Error(`Kotlin protocol bridge: ${what}`) }
const auth = native.BleProtocol.buildAuthenticationRequest(101)
assert(hex(auth) === '080410651a0408011004', 'authentication')
const compositor = new native.SurfaceCompositor()
compositor.configureScreen(3, 2)
compositor.configureSurface('test', 0, 0, 3, 2, 0, 0)
const pixels = copyToJavaByteBuffer(new Uint8Array([0, 16, 255, 32, 48, 64]))
compositor.submitSurface('test', new native.AndroidByteReader(pixels), 0, 0, 3, 2, '1')
assert(hex(compositor.composite().gray) === '0010ff203040', 'composition/ByteBuffer')
assert(hex(native.BmpUtil.pack4bppFromGray8(compositor.composite().gray, 3, 2)) === '01f02340', 'packing')
const id = native.ImageAtlas.ensure('kotlin-smoke', 3, 2, new native.AndroidByteReader(pixels))
assert(id > 0 && native.ImageAtlas.get(id).width === 3, 'image atlas/reused buffer')
console.log('FACECLAW_KOTLIN_PROTOCOL_PASS Android')
}