summaryrefslogtreecommitdiff
path: root/spike/settings/source/DebugSelfTest.mc
blob: ef501489ebec7fc6dd1b6fb700b9fba9c3f76470 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Author:  cirakg & claude ai
// Summary: Debug-only self-test: fills one field and runs the settings-change path once, so the simulator shows real output.
//
// The simulator has no phone, so this stands in for one save from Garmin
// Connect: if Text 1 is empty it receives a fake 100-character test string,
// then the normal onSettingsChanged path runs (analysis plus write-back).
// It prints a "SPIKE ready" line that build-spike.sh waits for. Release
// builds compile the empty (:release) version, so the beta you upload never
// changes your settings by itself.

import Toybox.Application.Properties;
import Toybox.Lang;
import Toybox.System;

module DebugSelfTest {

    // Fake 100-character test string in the same format as the phone tests.
    (:debug)
    const SAMPLE = "N=100|abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrP0050stuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghEND";

    (:debug)
    function run(app as SpikeApp) as Void {
        var current = Properties.getValue("text1");
        if (current == null || (current instanceof String && current.length() == 0)) {
            Properties.setValue("text1", SAMPLE);
            app.onSettingsChanged();
        }
        System.println("SPIKE ready total_chars=" + app.report.totalChars + " changes=" + app.report.changeCount
            + " status='" + Properties.getValue("statusField") + "'");
    }

    (:release)
    function run(app as SpikeApp) as Void {
    }
}