Class FakeScriptContext
- All Implemented Interfaces:
ScriptContext
ScriptContext for offline author tests.
This fixture exists only for JVM test source. It neither connects to an emulator nor grants native action access.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for a deterministic fake context.static final recordOne script-scoped log line recorded by this fixture. -
Method Summary
Modifier and TypeMethodDescriptionstatic FakeScriptContext.Builderbuilder()Creates a fixture builder with a safe default script id.Returns the game-message lines currently retained by the client.Returns the stable package identifier frommanifest.json.getSetting(String name, String fallback) Returns a launch-time script setting supplied by the Command Center.voidGrants a manifest permission to this fixture.booleanhasPermission(String permission) Tests whether the installed package was granted a manifest permission.booleanReturns whether Command Center has requested the script's next safe scheduled-break boundary.voidPublishes a script-scoped log entry.logs()Returns immutable logs emitted by the script.voidpublishTelemetry(String json) Publishes a small JSON telemetry snapshot for the Command Center paint.voidRevokes a manifest permission from this fixture.voidsetBreakRequested(boolean requested) Sets the simulated scheduled-break request.voidsetSetting(String name, String value) Replaces one launch setting for the next callback.Returns immutable telemetry payloads emitted by the script.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.valhalla.sdk.ScriptContext
debug, error, getBooleanSetting, getDoubleSetting, getEnumSetting, getIntListSetting, getIntSetting, getIntSetting, getListSetting, getLongSetting, info, requirePermission, warn
-
Method Details
-
builder
Creates a fixture builder with a safe default script id. -
getScriptId
Description copied from interface:ScriptContextReturns the stable package identifier frommanifest.json.- Specified by:
getScriptIdin interfaceScriptContext- Returns:
- script identifier used to prefix logs and runtime state
-
log
Description copied from interface:ScriptContextPublishes a script-scoped log entry.- Specified by:
login interfaceScriptContext- Parameters:
level- severity label such asDEBUG,INFO, orERRORmessage- human-readable message; avoid credentials and other secrets
-
hasPermission
Description copied from interface:ScriptContextTests whether the installed package was granted a manifest permission.- Specified by:
hasPermissionin interfaceScriptContext- Parameters:
permission- permission string, preferably fromPermissions- Returns:
truewhen the package grants the permission
-
getSetting
Description copied from interface:ScriptContextReturns a launch-time script setting supplied by the Command Center.- Specified by:
getSettingin interfaceScriptContext- Parameters:
name- setting key declared in the package manifestfallback- value returned when the key is absent- Returns:
- configured string value, or
fallbackwhen absent
-
publishTelemetry
Description copied from interface:ScriptContextPublishes a small JSON telemetry snapshot for the Command Center paint.An older runtime that predates this additive API resolves this default body, which forwards the snapshot through
ScriptContext.log(java.lang.String, java.lang.String)using the runtime's long-established"Telemetry: "bridge. That bridge applies the same permission, size, and JSON checks as the override and never writes telemetry values to Android's shared log buffer, so a runtime that does not implement this method degrades to the bridge instead of discarding the snapshot.A runtime predating the bridge does not recognize the prefix and records the line as an ordinary script log entry instead, which is why this snapshot must hold no credentials or secrets - the same contract
ScriptContext.log(java.lang.String, java.lang.String)already states.- Specified by:
publishTelemetryin interfaceScriptContext- Parameters:
json- valid JSON object, containing no credentials or secrets
-
isBreakRequested
public boolean isBreakRequested()Description copied from interface:ScriptContextReturns whether Command Center has requested the script's next safe scheduled-break boundary.The request is advisory: scripts should finish indivisible work and publish their existing safe-boundary telemetry before yielding. Older runtimes return
falsethrough this additive default method.- Specified by:
isBreakRequestedin interfaceScriptContext- Returns:
truewhile a scheduled break is due and awaiting a safe boundary
-
getGameMessages
Description copied from interface:ScriptContextReturns the game-message lines currently retained by the client.This data stays inside the Android script runtime and is never forwarded to Command Center telemetry. Packages must request
Permissions.GAME_READ_MESSAGES; older runtimes return an empty list through this default implementation.- Specified by:
getGameMessagesin interfaceScriptContext- Returns:
- immutable snapshot of retained game messages
-
setSetting
Replaces one launch setting for the next callback. -
grant
Grants a manifest permission to this fixture. -
revoke
Revokes a manifest permission from this fixture. -
setBreakRequested
public void setBreakRequested(boolean requested) Sets the simulated scheduled-break request. -
logs
Returns immutable logs emitted by the script. -
telemetry
Returns immutable telemetry payloads emitted by the script.
-