Compare commits

...

5 Commits

Author SHA1 Message Date
68d5ef98af Let sandbox run test drain its late chimes
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (flutter, flutter-analyze, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint,flutter-analyze) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / lock-popup-safety (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (0) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (1) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (2) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (3) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (4) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (5) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (6) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (7) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (8) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (9) (push) Waiting to run
Tests / flutter-coverage (push) Blocked by required conditions
Tests / web-coverage (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
run_screen_sandbox_test failed in flutter test: the kilometre chimes
play after the vibrator probe answers, so the last ones can start
audioplayers' frame callbacks after the final pump, and the framework
reports them as running after the tree was disposed. The test now
waits 300 ms and pumps twice before it ends. It failed the same way
on 74a39c3, so it was not caused by the material_ui move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
2026-11-16 09:16:03 +01:00
f26903f57a Zero gatelock's startup grace in tests
wait_for_turn sleeps its 1.5 s startup grace for real, so every test
that builds a locker paid it. The suite took ~135 s under the CPU
cap and the ci-pytest gate step could not finish inside the 60 s
action cap. With the grace zeroed in the hermetic gatelock fixture
all 2142 tests run in 13 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
2026-11-16 09:06:03 +01:00
9eac2ce3d6 Bump dependencies behind newest stable
The dependency-freshness gate failed the pre-push stamp on 17
findings: node 26.13.1, crdt-sync 0.11.1, freedays 0.4.3, sickdays
0.5.4 (the pylint hooks still pinned 0.3.0), coverage 7.17.3, pylint
4.1.4, ruff 0.17.5, flutter_local_notifications 23.0.2, and five
web packages with pnpm 12.21.0. Manifests, hook pins and lockfiles
move together.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
2026-11-16 08:57:17 +01:00
5f2925a550 Move workout_app to Flutter 3.50 material_ui
Flutter 3.50 deprecates package:flutter/material.dart, which made
flutter-analyze report 27 deprecated_member_use infos and blocked the
gate. workout_app now imports material_ui 1.11.0, with crdt_sync_dart
0.14.1 and sync_settings_ui 0.8.2 (both on material_ui).

material_ui's MaterialApp ships its own MaterialLocalizations, so a
package that still calls the framework showDialog threw a null check.
WorkoutApp now adds the framework delegate, and a widget test opens a
material_ui and a framework dialog through the real app root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
2026-11-16 08:54:33 +01:00
74a39c3054 Close the lock window when credit lands
On 2026-11-16 a manual workout was credited at 07:59 by
_session_stream, but the open lock window never rechecked log.json
(TRY AGAIN only asked StrongLifts/adb), so kuhy had to mark a sick
day. The window now polls log.json mtime every 3 s via Tk after and
stands down (decision workout_credited_elsewhere, no second credit),
and TRY AGAIN stands down when today is already logged.
_verify_phone_workout is deliberately unchanged (shared with
early-bird/status).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
2026-11-16 08:29:01 +01:00
122 changed files with 847 additions and 303 deletions

2
.fvmrc
View File

@ -1,3 +1,3 @@
{
"flutter": "3.47.9"
"flutter": "3.50.0"
}

View File

@ -60,7 +60,7 @@ jobs:
- uses: kuhyx/utils/flutter-setup@flutter-setup-v1
if: matrix.group == 'flutter'
with:
flutter-version: 3.47.9
flutter-version: 3.50.0
working-directory: stronglift_replacement/workout_app
# analyze needs resolved packages (.dart_tool); the hook runs analyze
# only, so fetch deps here first.
@ -83,7 +83,7 @@ jobs:
- uses: actions/setup-node@v4
if: matrix.group == 'rest'
with:
node-version: "26.13.0"
node-version: "26.13.1"
cache: pnpm
cache-dependency-path: web/pnpm-lock.yaml
- name: Install status-UI packages

View File

@ -99,7 +99,7 @@ jobs:
# cache cost ~38 s to restore even on a hit.
- uses: kuhyx/utils/flutter-setup@flutter-setup-v1
with:
flutter-version: 3.47.9
flutter-version: 3.50.0
working-directory: stronglift_replacement/workout_app
- name: flutter test --coverage, bucket ${{ matrix.shard }}
@ -136,7 +136,7 @@ jobs:
package_json_file: web/package.json
- uses: actions/setup-node@v4
with:
node-version: 26.13.0
node-version: 26.13.1
cache: pnpm
cache-dependency-path: web/pnpm-lock.yaml

View File

@ -60,7 +60,7 @@ jobs:
- uses: subosito/flutter-action@v2
with:
flutter-version: 3.47.9
flutter-version: 3.50.0
channel: stable
cache: true

View File

@ -114,7 +114,7 @@ repos:
# Same release as requirements.txt. No --jobs here: pyproject.toml holds
# it at 1, because parallel pylint pickles through dill, which crashes on
# Python 3.15 (see the comment on `jobs` there).
rev: v4.1.3
rev: v4.1.4
hooks:
# Two hooks, because the three checks below are not defects in a test
# suite -- they are how pytest and unit-testing private mixins work --
@ -142,10 +142,10 @@ repos:
# the manifest becomes an unresolvable hook environment rather
# than merely an old one.
- gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.12.0#subdirectory=gatelock
- crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.9.2#subdirectory=crdt-sync
- crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync
- earned-time @ git+https://github.com/kuhyx/utils@earned-time-v0.21.0#subdirectory=earned_time
- freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.0#subdirectory=freedays
- sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.3.0#subdirectory=sickdays
- freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays
- sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.4#subdirectory=sickdays
# Same pin as workout_app/tools/render_finish_chime.sh installs.
- music_theory @ git+https://github.com/kuhyx/utils@music-theory-v0.1.0#subdirectory=music_theory
- mcp>=2,<3
@ -165,10 +165,10 @@ repos:
# the manifest becomes an unresolvable hook environment rather
# than merely an old one.
- gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.12.0#subdirectory=gatelock
- crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.9.2#subdirectory=crdt-sync
- crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync
- earned-time @ git+https://github.com/kuhyx/utils@earned-time-v0.21.0#subdirectory=earned_time
- freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.0#subdirectory=freedays
- sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.3.0#subdirectory=sickdays
- freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays
- sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.4#subdirectory=sickdays
- mcp>=2,<3
- pydantic

View File

@ -75,7 +75,7 @@ ensure_runtime_deps() {
_pip_runtime_dep gatelock \
"gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.10.0#subdirectory=gatelock"
_pip_runtime_dep crdt_sync \
"crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.9.2#subdirectory=crdt-sync"
"crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync"
}
ensure_runtime_deps

View File

@ -8,11 +8,11 @@ requires-python = ">=3.14"
# diet_guard; here for phone-workout sync, Firebase RTDB only since 2026-10-09
dependencies = [
"gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.13.0#subdirectory=gatelock",
"crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.9.2#subdirectory=crdt-sync",
"freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.0#subdirectory=freedays",
"crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync",
"freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays",
"earned-time @ git+https://github.com/kuhyx/utils@earned-time-v0.21.0#subdirectory=earned_time",
"holds @ git+https://github.com/kuhyx/utils@holds-v0.1.0#subdirectory=holds",
"sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.0#subdirectory=sickdays",
"sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.4#subdirectory=sickdays",
]
[project.scripts]

View File

@ -2,16 +2,16 @@
# Runtime: tkinter/subprocess/socket/sqlite3 (stdlib) plus gatelock (below).
bandit==1.9.4
codespell==2.4.3
coverage==7.17.2
crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.9.2#subdirectory=crdt-sync
coverage==7.17.3
crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync
earned-time @ git+https://github.com/kuhyx/utils@earned-time-v0.21.0#subdirectory=earned_time
freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.0#subdirectory=freedays
freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays
gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.13.0#subdirectory=gatelock
holds @ git+https://github.com/kuhyx/utils@holds-v0.1.0#subdirectory=holds
mcp==2.3.0
mypy==2.4.1
pre-commit==4.7.0
pylint==4.1.3
pylint==4.1.4
pytest==9.2.0
pytest-cov==7.1.0
pytest-randomly==5.1.0
@ -21,8 +21,8 @@ pytest-xdist==3.8.0
# token over the REST endpoint; crdt-sync already pulls requests in, but this
# module imports it itself, so it is declared rather than assumed.
requests==2.34.2
ruff==0.17.4
sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.0#subdirectory=sickdays
ruff==0.17.5
sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.4#subdirectory=sickdays
types-requests==2.33.0.20261030
# Direct dependency since the Firebase session stream (_session_stream) catches
# urllib3's own errors on the long-lived SSE read; requests pulls it in, but

View File

@ -0,0 +1,117 @@
"""An open lock window closes itself the moment today's workout is credited.
2026-11-16: the window opened at 07:55:17. kuhy logged a manual workout on the
phone; at 07:59:04 the separate ``_session_stream`` daemon credited it (log row
written, shutdown moved). The open window never noticed: TRY AGAIN only asked
StrongLifts/ADB/HTTP, so it kept saying "stale" and kuhy marked a sick day to
get out. The startup ladder reads ``log.json`` once; this is the same verdict
(``has_logged_today``, HMAC-checked) re-asked whenever the file changes.
Event-driven on the Tk loop, no thread, no new dependency: each poll is one
``stat`` of the log; the file is parsed only when its (mtime, size, inode)
moved. The credit itself was already written by whoever logged it, so closing
here writes nothing and applies nothing -- it just takes the window down.
"""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
from screen_locker._decision_log import LockDecision, record_decision
if TYPE_CHECKING:
from collections.abc import Callable
from pathlib import Path
from tkinter import Misc
__all__ = ["POLL_MS", "CreditStandDownMixin", "watch_for_credit"]
_logger = logging.getLogger(__name__)
# Well inside the 10 s an open window may take to notice a credit.
POLL_MS = 3_000
_UNSEEN: tuple[int, ...] = (-1,)
_ABSENT: tuple[int, ...] = ()
def _signature(log_file: Path) -> tuple[int, ...] | None:
"""(mtime_ns, size, inode) of the log: ``()`` when absent, None on error."""
# exists() first: a log nobody has written yet is normal, not a fault, and
# a bare ``except FileNotFoundError`` would be a silent swallow.
if not log_file.exists():
return _ABSENT
try:
stat = log_file.stat()
except OSError as exc:
_logger.warning(
"Could not stat %s while the lock is up (%s) — keeping the lock "
"and trying again in %d s",
log_file,
exc,
POLL_MS // 1000,
)
return None
return (stat.st_mtime_ns, stat.st_size, stat.st_ino)
def watch_for_credit(
root: Misc,
log_file: Path,
has_logged: Callable[[], bool],
on_credit: Callable[[], None],
) -> None:
"""Hand a credit that landed while the window is up to ``on_credit``.
The first poll always checks (a row may land between startup and arming);
after that ``has_logged`` runs only when the log's signature changed. A
failed check is logged and the poll goes on: one bad read must not end the
only thing watching. Stops re-arming once it fires.
"""
seen = _UNSEEN
def _tick() -> None:
nonlocal seen
sig = _signature(log_file)
if sig is not None and sig != seen:
seen = sig
try:
if has_logged():
on_credit()
return
except (OSError, ValueError, TypeError, KeyError) as exc:
_logger.warning(
"Could not check %s for a credit while the lock is up "
"(%s) — keeping the lock and trying again in %d s",
log_file,
exc,
POLL_MS // 1000,
)
seen = _UNSEEN
root.after(POLL_MS, _tick)
root.after(POLL_MS, _tick)
class CreditStandDownMixin:
"""The locker's side: leave through the normal ``close`` once credited."""
def _stand_down_for_credit(self) -> None:
"""Take the window down because today's workout is already credited.
Same exit as a credited workout, a test hold or a late carrot: lock
window released, instance lock dropped, exit 0. No row, no credit, no
penalty -- the logger of the workout already did all of that.
"""
record_decision(
LockDecision(
locked=False,
reason="workout_credited_elsewhere",
detail="Today's workout was credited while the lock was up.",
)
)
_logger.warning(
"Today's workout was credited by another process while the lock "
"was up — taking the lock down without writing a second credit."
)
self.close()

View File

@ -14,6 +14,7 @@ from typing import TYPE_CHECKING
from screen_locker import _glyphs as g
from screen_locker import _manual_workout
from screen_locker._credit_watch import CreditStandDownMixin
from screen_locker._source_health import collect_source_findings, explain_findings
from screen_locker._ui_flows_lockout import LockoutFlowMixin
from screen_locker._ui_flows_sick import SickDayFlowMixin
@ -25,7 +26,9 @@ if TYPE_CHECKING:
_logger = logging.getLogger(__name__)
class UIFlowsMixin(SickDayFlowMixin, SickPanelFlowMixin, LockoutFlowMixin):
class UIFlowsMixin(
SickDayFlowMixin, SickPanelFlowMixin, LockoutFlowMixin, CreditStandDownMixin
):
"""Mixin providing UI flow logic for the screen locker.
The sick-day and lockout/penalty flows live in sibling modules and are
@ -50,7 +53,16 @@ class UIFlowsMixin(SickDayFlowMixin, SickPanelFlowMixin, LockoutFlowMixin):
self._text(g.WAIT, role="display", color=self._colors.palette.muted)
def _start_phone_check(self) -> None:
"""Check phone for today's workout immediately at startup."""
"""Check phone for today's workout immediately at startup.
Also the TRY AGAIN path. Another process (the stream daemon, a manual
log) may have credited today since the window opened; the log is
authoritative, so that closes the window instead of asking the phone
-- a StrongLifts "stale" verdict must never outrank a logged workout.
"""
if self.has_logged_today():
self._stand_down_for_credit()
return
self.paint_phone_check()
executor = ThreadPoolExecutor(max_workers=1)
self._phone_future = executor.submit(self._verify_phone_workout)

View File

@ -35,6 +35,7 @@ from screen_locker._constants import (
PHONE_PENALTY_DELAY_PRODUCTION,
SCHEDULED_SKIPS_FILE,
)
from screen_locker._credit_watch import watch_for_credit
from screen_locker._decision_log import record_run_aborted
from screen_locker._early_bird import EarlyBirdMixin
from screen_locker._heat_skip import HeatSkipMixin
@ -214,6 +215,9 @@ class ScreenLocker(
self._lock.grab_input()
watch_for_hold(self.root, self.close)
watch_for_carrot(self.root, self._stand_down_for_carrot)
watch_for_credit(
self.root, self.log_file, self.has_logged_today, self._stand_down_for_credit
)
def close(self) -> None:
"""Close the application and exit."""

View File

@ -54,8 +54,13 @@ def _hermetic_gatelock(
The runtime dir is redirected as well, so a test cannot reach the real
``$XDG_RUNTIME_DIR`` and stand a *production* locker down through the
arbiter.
The queue's startup grace is zeroed too: ``wait_for_turn`` sleeps it for
real before its first look, which put 1.5 s on every test that builds a
locker and the suite far past the 60 s action cap.
"""
monkeypatch.setenv("GATELOCK_RUNTIME_DIR", str(tmp_path / "gatelock-runtime"))
monkeypatch.setattr("gatelock._queue.STARTUP_GRACE_SECONDS", 0.0)
with (
patch("gatelock._surfaces.tk.Toplevel", side_effect=_make_toplevel),
patch("gatelock._outputs.RandrBackend.create", return_value=None),

View File

@ -0,0 +1,232 @@
"""An open lock window closes itself when another process credits today.
2026-11-16: the window opened 07:55:17; the `_session_stream` daemon credited a
manual workout at 07:59:04 and the open window never noticed -- TRY AGAIN only
asked StrongLifts/ADB/HTTP -- so kuhy had to mark a sick day to get out.
"""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
from unittest.mock import ANY, MagicMock, patch
import pytest
from screen_locker._credit_watch import POLL_MS, watch_for_credit
from screen_locker._day import today_str
from screen_locker._log_mixin import write_signed_entry
from screen_locker.tests.conftest import create_locker
if TYPE_CHECKING:
from collections.abc import Iterator
from pathlib import Path
@pytest.fixture(autouse=True)
def _signing_key(tmp_path: Path) -> Iterator[None]:
key = tmp_path / "hmac.key"
key.write_bytes(b"1" * 32)
with patch("gatelock.log_integrity.DEFAULT_HMAC_KEY_FILE", key):
yield
def _credit_today(log_file: Path) -> None:
"""What the stream daemon does: a signed row for today in the scratch log."""
write_signed_entry(
log_file,
today_str(),
{"type": "manual", "workout_id": "wk-1", "source": "phone"},
)
def _arm(
log_file: Path, *, logged: bool = False
) -> tuple[MagicMock, MagicMock, MagicMock]:
"""Arm the watch; return (root, on_credit, has_logged)."""
root, on_credit = MagicMock(), MagicMock()
has_logged = MagicMock(return_value=logged)
watch_for_credit(root, log_file, has_logged, on_credit)
return root, on_credit, has_logged
def _fire(root: MagicMock) -> None:
"""Run the poll the watch last scheduled."""
root.after.call_args.args[1]()
class TestWatchForCredit:
"""The poll on the Tk loop."""
def test_polls_well_inside_ten_seconds(self, tmp_path: Path) -> None:
"""First check is scheduled at most 5 s out: credit shows in <= 10 s."""
root, on_credit, _ = _arm(tmp_path / "log.json")
assert POLL_MS <= 5_000
assert root.after.call_args.args[0] == POLL_MS
on_credit.assert_not_called()
def test_nothing_logged_keeps_the_window_and_rearms(self, tmp_path: Path) -> None:
"""No file, no credit: the window stays and the next poll is armed."""
root, on_credit, _ = _arm(tmp_path / "log.json")
_fire(root)
on_credit.assert_not_called()
assert root.after.call_count == 2
def test_credit_landing_after_arming_fires_once_and_stops(
self, tmp_path: Path
) -> None:
"""A row written after arming is handed over; the poll is not re-armed."""
log_file = tmp_path / "log.json"
root = MagicMock()
on_credit = MagicMock()
watch_for_credit(root, log_file, log_file.exists, on_credit)
_fire(root)
on_credit.assert_not_called()
_credit_today(log_file)
_fire(root)
on_credit.assert_called_once_with()
assert root.after.call_count == 2
def test_unchanged_file_is_not_reread(self, tmp_path: Path) -> None:
"""Steady state is one stat per poll: the log is parsed only on change."""
log_file = tmp_path / "log.json"
log_file.write_text("{}")
root, _, has_logged = _arm(log_file)
_fire(root)
_fire(root)
_fire(root)
assert has_logged.call_count == 1
def test_rewritten_file_is_reread(self, tmp_path: Path) -> None:
"""A changed file is checked again even if the first check said no."""
log_file = tmp_path / "log.json"
log_file.write_text("{}")
root, _, has_logged = _arm(log_file)
_fire(root)
log_file.write_text('{"1999-01-01": []}')
_fire(root)
assert has_logged.call_count == 2
def test_credit_present_before_first_poll_is_caught(self, tmp_path: Path) -> None:
"""A row that landed between startup and arming is not missed."""
log_file = tmp_path / "log.json"
_credit_today(log_file)
root, on_credit, _ = _arm(log_file, logged=True)
_fire(root)
on_credit.assert_called_once_with()
def test_read_failure_is_logged_and_the_poll_survives(
self, tmp_path: Path, caplog: pytest.LogCaptureFixture
) -> None:
"""A failing check warns and re-arms; it must not end the only watcher."""
log_file = tmp_path / "log.json"
log_file.write_text("{}")
root, on_credit, has_logged = _arm(log_file)
has_logged.side_effect = OSError("disk gone")
with caplog.at_level(logging.WARNING, logger="screen_locker._credit_watch"):
_fire(root)
on_credit.assert_not_called()
assert root.after.call_count == 2
assert "disk gone" in caplog.text
def test_unreadable_stat_is_logged_not_swallowed(
self, tmp_path: Path, caplog: pytest.LogCaptureFixture
) -> None:
"""A log that exists but cannot be stat'ed is reported, not skipped."""
log_file = tmp_path / "log.json"
log_file.write_text("{}")
root, on_credit, _ = _arm(log_file)
with (
patch("pathlib.Path.stat", side_effect=PermissionError("no stat")),
caplog.at_level(logging.WARNING, logger="screen_locker._credit_watch"),
):
_fire(root)
on_credit.assert_not_called()
assert "no stat" in caplog.text
assert root.after.call_count == 2
class TestLockerClosesOnCredit:
"""The locker side: wiring, the retry path and the stand-down itself."""
def test_construction_arms_the_watch(
self, mock_tk: MagicMock, tmp_path: Path
) -> None:
"""A built locker watches its own log, with its own stand-down."""
with patch("screen_locker.screen_lock.watch_for_credit") as watch:
locker = create_locker(mock_tk, tmp_path)
watch.assert_called_once_with(
locker.root,
locker.log_file,
ANY, # create_locker patches has_logged_today during construction
locker._stand_down_for_credit,
)
def test_open_window_closes_when_another_process_credits(
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
) -> None:
"""Window open -> row appended to the scratch log -> next poll closes it."""
locker = create_locker(mock_tk, tmp_path)
root = MagicMock()
watch_for_credit(
root,
locker.log_file,
locker.has_logged_today,
locker._stand_down_for_credit,
)
_fire(root)
mock_sys_exit.assert_not_called()
_credit_today(locker.log_file)
with (
patch.object(locker, "_lock") as lock,
patch("screen_locker._credit_watch.record_decision") as record,
):
_fire(root)
lock.close.assert_called_once_with()
mock_sys_exit.assert_called_once_with(0)
decision = record.call_args.args[0]
assert decision.locked is False
assert decision.reason == "workout_credited_elsewhere"
def test_stand_down_writes_no_credit_of_its_own(
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
) -> None:
"""Closing must not double-credit: no new log row, no credit applied."""
locker = create_locker(mock_tk, tmp_path)
_credit_today(locker.log_file)
before = locker.log_file.read_bytes()
with (
patch.object(locker, "_lock"),
patch.object(locker, "_apply_workout_credit") as credit,
):
locker._stand_down_for_credit()
credit.assert_not_called()
assert locker.log_file.read_bytes() == before
mock_sys_exit.assert_called_once_with(0)
def test_try_again_with_todays_credit_closes_instead_of_asking_the_phone(
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
) -> None:
"""2026-11-16: TRY AGAIN said 'stale' though the log held today's row."""
locker = create_locker(mock_tk, tmp_path)
_credit_today(locker.log_file)
with (
patch.object(locker, "_lock"),
patch.object(locker, "_verify_phone_workout") as verify,
):
locker._start_phone_check()
verify.assert_not_called()
mock_sys_exit.assert_called_once_with(0)
def test_try_again_without_credit_still_asks_the_phone(
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
) -> None:
"""Not logged today: the retry runs the normal phone check."""
locker = create_locker(mock_tk, tmp_path)
with patch.object(
locker, "_verify_phone_workout", return_value=("stale", "old")
) as verify:
locker._start_phone_check()
locker._phone_future.result(timeout=5)
verify.assert_called_once_with()
mock_sys_exit.assert_not_called()

View File

@ -1,7 +1,14 @@
import 'dart:async';
import 'dart:io' show HttpOverrides, Platform;
import 'package:flutter/material.dart';
// Framework material, for its MaterialLocalizations delegate only: material_ui
// ships its own MaterialLocalizations type, so a package that still calls the
// framework `showDialog` (crdt_sync_flutter did) finds none and throws a null
// check.
// ignore: deprecated_member_use, the only source of the framework delegate.
import 'package:flutter/material.dart' as fw show DefaultMaterialLocalizations;
import 'package:flutter_foreground_task/flutter_foreground_task.dart';
import 'package:material_ui/material_ui.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/sandbox/sandbox.dart';
import 'package:workout_app/sandbox/sandbox_http.dart';
@ -196,6 +203,10 @@ class _WorkoutAppState extends State<WorkoutApp> with WidgetsBindingObserver {
// the launcher icon and the manifest label (android:label) already.
debugShowCheckedModeBanner: false,
theme: buildAppTheme(),
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
fw.DefaultMaterialLocalizations.delegate,
DefaultWidgetsLocalizations.delegate,
],
home: const HomeScreen(),
// The one thing that must never be mistaken for the daily build: a
// ribbon on every screen, in the error colour, on the sandbox only.

View File

@ -12,10 +12,11 @@
library;
import 'dart:async';
import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart' as http;
import 'package:material_ui/material_ui.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:workout_app/services/github_device_auth.dart';
import 'package:workout_app/services/sync_settings.dart';

View File

@ -8,9 +8,10 @@ import 'dart:async';
import 'dart:convert';
import 'dart:developer' as developer;
import 'dart:math';
import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/models/manual_workout.dart';
import 'package:workout_app/models/run_record.dart';
import 'package:workout_app/models/run_track.dart';

View File

@ -3,7 +3,7 @@ library;
import 'dart:async';
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/models/exercise.dart';
import 'package:workout_app/sandbox/sandbox_log.dart';
import 'package:workout_app/screens/history_screen.dart';

View File

@ -15,7 +15,7 @@ library;
import 'dart:async';
import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/models/manual_workout.dart';
import 'package:workout_app/sandbox/sandbox_log.dart';
import 'package:workout_app/services/done_today.dart';

View File

@ -4,7 +4,7 @@
/// value.
library;
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/models/run_track.dart';
import 'package:workout_app/services/map_tile_cache.dart';
import 'package:workout_app/services/run_format.dart';

View File

@ -10,8 +10,8 @@ import 'dart:async';
import 'package:audioplayers/audioplayers.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:latlong2/latlong.dart';
import 'package:material_ui/material_ui.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:workout_app/models/run_track.dart';
import 'package:workout_app/sandbox/sandbox_log.dart';

View File

@ -8,9 +8,10 @@ library;
import 'dart:async';
import 'dart:developer';
import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:material_ui/material_ui.dart';
import 'package:sync_settings_ui/sync_settings_ui.dart';
import 'package:workout_app/models/exercise.dart';
import 'package:workout_app/models/workout_plan.dart';

View File

@ -5,7 +5,7 @@ library;
import 'dart:async';
import 'dart:developer';
import 'package:audioplayers/audioplayers.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:vibration/vibration.dart';
import 'package:workout_app/models/break_intent.dart';
import 'package:workout_app/models/break_snapshot.dart';

View File

@ -146,20 +146,18 @@ extension _WorkoutScreenFinish on _WorkoutScreenState {
// PB (it rewards the recording, not the number), then the summary arrives
// on the dialog motion token instead of appearing. Both start together.
unawaited(_cues.workoutFinished());
unawaited(
showDialog<void>(
context: context,
barrierDismissible: false,
animationStyle: AnimationStyle(
duration: motionDuration(context, AppDuration.slow),
curve: AppCurve.decelerate,
reverseCurve: AppCurve.accelerate,
),
builder: (_) => WorkoutSummaryDialog(
session: session,
syncResult: syncResult,
pcPoke: pcPoke,
),
showDialog<void>(
context: context,
barrierDismissible: false,
animationStyle: AnimationStyle(
duration: motionDuration(context, AppDuration.slow),
curve: AppCurve.decelerate,
reverseCurve: AppCurve.accelerate,
),
builder: (_) => WorkoutSummaryDialog(
session: session,
syncResult: syncResult,
pcPoke: pcPoke,
),
);
}

View File

@ -6,7 +6,7 @@
/// hand-picked, not algorithmically derived from one seed color.
library;
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
/// Builds the app's single dark `ThemeData` from the shared token set.
ThemeData buildAppTheme() {

View File

@ -1,7 +1,7 @@
/// A whole number that counts to its true value instead of snapping to it.
library;
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/ui/theme.dart';
/// Rebuilds [builder] with a number that eases from 0 to [value] on arrival,

View File

@ -1,7 +1,7 @@
/// Countdown strip permanently reserved at the top of the workout screen.
library;
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/ui/theme.dart';
/// Fixed-height strip: the rest countdown, Skip, and the workout's Reset and

View File

@ -1,7 +1,7 @@
/// Monthly calendar showing which days had workouts.
library;
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/ui/theme.dart';
/// Monthly calendar widget that highlights days with completed workouts.

View File

@ -3,7 +3,7 @@ library;
import 'dart:developer' show log;
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/services/data_transfer.dart';
import 'package:workout_app/services/storage_service.dart';

View File

@ -5,7 +5,7 @@ library;
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/models/exercise.dart';
import 'package:workout_app/models/exercise_state.dart';
import 'package:workout_app/models/progression.dart';

View File

@ -2,7 +2,7 @@
/// one row of warmup + set circles, and the progress line.
library;
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/models/exercise.dart';
import 'package:workout_app/models/exercise_state.dart';
import 'package:workout_app/models/progression.dart';

View File

@ -1,7 +1,7 @@
/// The one-line PC status on the workout summary.
library;
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/services/pc_poke_result.dart';
import 'package:workout_app/ui/theme.dart';

View File

@ -12,7 +12,7 @@
/// long press → reset to neutral
library;
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/ui/theme.dart';
/// Visual state of a [RepCircle].

View File

@ -29,9 +29,9 @@ library;
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/models/run_track.dart';
import 'package:workout_app/services/map_tile_cache.dart';
import 'package:workout_app/ui/theme.dart';

View File

@ -1,9 +1,9 @@
/// The route, endpoint markers and attribution button drawn by `RunMap`.
library;
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/models/run_track.dart';
import 'package:workout_app/ui/theme.dart';

View File

@ -2,8 +2,8 @@
library;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:latlong2/latlong.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/models/run_track.dart';
import 'package:workout_app/services/map_tile_cache.dart';
import 'package:workout_app/ui/theme.dart';

View File

@ -8,7 +8,7 @@ library;
import 'dart:async';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/services/pace_band.dart';
import 'package:workout_app/services/run_format.dart';
import 'package:workout_app/ui/theme.dart';

View File

@ -3,7 +3,7 @@ library;
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/services/run_uploader.dart';
import 'package:workout_app/ui/theme.dart';

View File

@ -1,4 +1,4 @@
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/services/runnerup_importer.dart';
/// The RunnerUp history import's state as a glyph, never as words: a small

View File

@ -6,7 +6,7 @@
/// a workout gets logged into a void again.
library;
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/ui/theme.dart';
/// Tells the user this workout will not reach the PC until sync is set up.

View File

@ -6,7 +6,7 @@
/// all offer the fix rather than just reporting the problem.
library;
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/services/sync_status.dart';
import 'package:workout_app/ui/theme.dart';

View File

@ -1,7 +1,7 @@
/// Dialog shown after a workout is finished, summarising results.
library;
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:workout_app/models/workout_session.dart';
import 'package:workout_app/services/pc_poke_result.dart';
import 'package:workout_app/services/sync_service.dart';

View File

@ -125,10 +125,10 @@ packages:
dependency: transitive
description:
name: clock
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
sha256: e51d50bca3217c9a9fa2b41a30e4a38971133f5f9ec7a3d57bae095007f1d28e
url: "https://pub.dev"
source: hosted
version: "1.1.2"
version: "1.1.3"
code_assets:
dependency: transitive
description:
@ -149,11 +149,11 @@ packages:
dependency: "direct main"
description:
path: crdt_sync_dart
ref: "crdt_sync_dart-v0.12.1"
resolved-ref: "6641d85f0550ca60433fc8e0d13a3dafdbb664d6"
ref: "crdt_sync_dart-v0.14.1"
resolved-ref: edd0f7a7882cb1d3904932ba94faa282d08165df
url: "https://github.com/kuhyx/utils"
source: git
version: "0.12.1"
version: "0.14.1"
cross_file:
dependency: transitive
description:
@ -170,6 +170,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.8"
cryptography:
dependency: transitive
description:
name: cryptography
sha256: "3eda3029d34ec9095a27a198ac9785630fe525c0eb6a49f3d575272f8e792ef0"
url: "https://pub.dev"
source: hosted
version: "2.9.0"
cupertino_ui:
dependency: transitive
description:
name: cupertino_ui
sha256: "369e39a1c5c030a6212589c3da1809920b1c2cfade7b02aade7695bfa4b88c3a"
url: "https://pub.dev"
source: hosted
version: "1.1.6"
dart_earcut:
dependency: transitive
description:
@ -420,10 +436,10 @@ packages:
dependency: "direct main"
description:
name: flutter_local_notifications
sha256: "58f9ea245d7194363c05f7a012bbc73291736c2d8b5f555a8e0ea3f9121868b4"
sha256: fac349e7361f80591a0cedff03548f807282c9faee9fc6192763166e5f81def2
url: "https://pub.dev"
source: hosted
version: "23.0.1"
version: "23.0.2"
flutter_local_notifications_linux:
dependency: transitive
description:
@ -456,6 +472,11 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.1"
flutter_localizations:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
flutter_map:
dependency: "direct main"
description:
@ -747,6 +768,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.1.0"
listen:
dependency: transitive
description:
name: listen
sha256: "47501a08016a43fcad79252439d723f50f14f88fa7bfd8a177e0a417e5c9e1f2"
url: "https://pub.dev"
source: hosted
version: "1.0.1"
logging:
dependency: transitive
description:
@ -771,6 +800,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.13.0"
material_ui:
dependency: "direct main"
description:
name: material_ui
sha256: "474c135fd46b56ff1d35ca982155e8863d28fbc6464d1192acf4ee53a738680e"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
meta:
dependency: transitive
description:
@ -1148,10 +1185,10 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
sha256: "277654b3034d17ac6f9f1cb5595db011b1d5d41e8806866db28e0abaa101c490"
url: "https://pub.dev"
source: hosted
version: "1.12.1"
version: "1.12.2"
stream_channel:
dependency: transitive
description:
@ -1172,11 +1209,11 @@ packages:
dependency: "direct main"
description:
path: sync_settings_ui
ref: "sync_settings_ui-v0.7.0"
resolved-ref: "3084080d744c348a217727e26a6be838e7d5a4ff"
ref: "sync_settings_ui-v0.8.2"
resolved-ref: "3225af8365481677d61a8cabec0c0ad4d0407567"
url: "https://github.com/kuhyx/utils"
source: git
version: "0.7.0"
version: "0.8.2"
synchronized:
dependency: transitive
description:
@ -1197,10 +1234,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "2a122cbe059f8b610d3a5415f42e255b6c17b1f21eee1d960f31080237fb4f11"
sha256: "0a10344e901e5b2e63819567951cb6a06673ed6b84f40462188ff5a0c41f371f"
url: "https://pub.dev"
source: hosted
version: "0.7.12"
version: "0.7.14"
timezone:
dependency: transitive
description:
@ -1301,10 +1338,10 @@ packages:
dependency: transitive
description:
name: vector_math
sha256: "1d774bbdf6b72a0b12122fc1560c9c2d2a67db5a4a4cc2bd8a5c990ab20e3188"
sha256: fa49e1674cb84acb900141714e6c6e1f9ae099827c24d141430ff6819db4e1bc
url: "https://pub.dev"
source: hosted
version: "2.4.0"
version: "2.4.4"
very_good_analysis:
dependency: "direct dev"
description:

View File

@ -12,7 +12,7 @@ dependencies:
crdt_sync:
git:
url: https://github.com/kuhyx/utils
ref: crdt_sync_dart-v0.12.1
ref: crdt_sync_dart-v0.14.1
path: crdt_sync_dart
# HMAC-SHA256 for the signed phone->PC workout poke (pc_poke_wire.dart).
crypto: 3.0.8
@ -34,7 +34,7 @@ dependencies:
flutter_foreground_task: 11.0.3
# The break-end alert itself, on its own high-importance channel so the OS
# rings even if the Flutter isolate is busy.
flutter_local_notifications: 23.0.1
flutter_local_notifications: 23.0.2
# The run map and its tile disk cache.
flutter_map: 8.3.2
flutter_map_cache: 2.1.2
@ -52,6 +52,7 @@ dependencies:
http: 1.6.0
http_cache_file_store: 2.0.2
latlong2: 0.10.1
material_ui: 1.11.0
path: 1.9.1
path_provider: 2.1.6
permission_handler: 13.0.2
@ -63,7 +64,7 @@ dependencies:
sync_settings_ui:
git:
url: https://github.com/kuhyx/utils
ref: sync_settings_ui-v0.7.0
ref: sync_settings_ui-v0.8.2
path: sync_settings_ui
url_launcher: 6.3.3
uuid: 4.6.0

View File

@ -0,0 +1,66 @@
import 'dart:async' show unawaited;
// Framework material, for `showDialog` only: material_ui ships its own
// MaterialLocalizations type, so a package that still calls the framework
// `showDialog` (crdt_sync_flutter did) finds none under WorkoutApp and throws
// a null check. This opens one through the real app root.
// ignore: deprecated_member_use, the only source of the framework dialog.
import 'package:flutter/material.dart' as fw show showDialog;
import 'package:flutter_test/flutter_test.dart';
import 'package:material_ui/material_ui.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/main.dart';
import 'package:workout_app/screens/home_screen.dart';
import 'package:workout_app/services/storage_service.dart';
import 'fake_secure_storage.dart';
void main() {
setUpAll(() {
sqfliteFfiInit();
databaseFactory = databaseFactoryFfi;
});
setUp(() async {
installFakeSecureStorage();
StorageService.resetForTesting();
await StorageService.init();
});
Future<BuildContext> pumpApp(WidgetTester tester) async {
await tester.runAsync(() async {
await tester.pumpWidget(const WorkoutApp());
await Future<void>.delayed(const Duration(milliseconds: 300));
});
await tester.pump();
return tester.element(find.byType(HomeScreen));
}
testWidgets('a material_ui dialog opens through the app root', (
tester,
) async {
final context = await pumpApp(tester);
unawaited(
showDialog<void>(
context: context,
builder: (_) => const AlertDialog(key: Key('mui-dialog')),
),
);
await tester.pumpAndSettle();
expect(find.byKey(const Key('mui-dialog')), findsOneWidget);
expect(tester.takeException(), isNull);
});
testWidgets('a framework dialog opens through the app root', (tester) async {
final context = await pumpApp(tester);
unawaited(
fw.showDialog<void>(
context: context,
builder: (_) => const SizedBox(key: Key('fw-dialog')),
),
);
await tester.pumpAndSettle();
expect(find.byKey(const Key('fw-dialog')), findsOneWidget);
expect(tester.takeException(), isNull);
});
}

View File

@ -2,7 +2,7 @@
/// the icon's spoken `semanticLabel`).
library;
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
/// The [Icon] whose spoken label is exactly [label].

View File

@ -2,7 +2,7 @@
//
// Linux returns early because main() never starts the socket there, so a
// resume must not start one behind the lock screen's back.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/main.dart';

View File

@ -7,7 +7,7 @@
import 'dart:convert';
import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;
import 'package:http/testing.dart';

View File

@ -5,7 +5,7 @@
// statically and a fake could not intercept one.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:workout_app/screens/home_screen.dart';
import 'package:workout_app/services/workout_sync_service.dart';

View File

@ -3,7 +3,7 @@
// Hoisted to top level so the split test files import one definition (see
// _history_test_fixtures.dart for why local copies drift).
import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:workout_app/services/workout_sync_service.dart';

View File

@ -3,7 +3,7 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:latlong2/latlong.dart';
import 'package:workout_app/models/run_track.dart';

View File

@ -4,7 +4,7 @@
// the interaction in `runAsync`: the widget-test zone fakes async, so a
// sqflite-ffi write started from a plain pump hangs and takes the isolate
// down on shutdown.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:workout_app/models/exercise.dart';
import 'package:workout_app/screens/workout_screen.dart';

View File

@ -1,7 +1,7 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;

View File

@ -1,7 +1,7 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;

View File

@ -1,7 +1,7 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;

View File

@ -1,7 +1,7 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;

View File

@ -4,7 +4,7 @@
import 'dart:convert';
import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;
import 'package:http/testing.dart';

View File

@ -4,7 +4,7 @@
import 'dart:convert';
import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;
import 'package:http/testing.dart';

View File

@ -1,6 +1,6 @@
// Runs in the history: the overview strip, the one-entry-per-run merge with
// the PC's runnerup_verified rows, the calendar, and opening the detail.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/models/run_track.dart';

View File

@ -1,7 +1,7 @@
import 'dart:convert';
import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;
import 'package:http/testing.dart';

View File

@ -2,7 +2,7 @@
// The numbers themselves are untouched: only the road to them is animated.
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/models/workout_plan.dart';

View File

@ -2,7 +2,7 @@
// home screen and lands on the workout, the way todo lands on the editor.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/screens/home_screen.dart';

View File

@ -1,5 +1,5 @@
// The run icon on the home screen opens the run screen.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:geolocator/geolocator.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';

View File

@ -1,4 +1,4 @@
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/models/workout_plan.dart';

View File

@ -4,7 +4,7 @@
// workout-start paths.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/models/workout_plan.dart';

View File

@ -1,6 +1,6 @@
// The workout date on the manual form: today up to a week ahead, the budget
// read as of that date, and the refusals around it.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:workout_app/screens/manual_workout_screen.dart';
import 'package:workout_app/services/workout_sync_service.dart';

View File

@ -1,5 +1,5 @@
import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:workout_app/models/manual_workout.dart';
import 'package:workout_app/screens/manual_workout_screen.dart';

View File

@ -1,4 +1,4 @@
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:workout_app/models/run_track.dart';
import 'package:workout_app/screens/run_detail_screen.dart';

View File

@ -1,6 +1,6 @@
// Location refused: no map, no start, only the red icon; a grant later (the
// app coming back from settings) brings the screen back.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:workout_app/services/position_source.dart';
import 'package:workout_app/widgets/run_map.dart';

View File

@ -1,6 +1,6 @@
// Before a run the map shows and follows where the user is; those display-only
// fixes never reach the recorded track.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:workout_app/widgets/run_map.dart';

View File

@ -1,6 +1,6 @@
// R7: the run screen fits one Pixel 6a screen with no scrolling, clear of the
// status bar and the gesture bar, in every phase.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import '../fake_audio_platform.dart';

View File

@ -1,6 +1,6 @@
// One mode: every GPS activity is recorded with the running filter and written
// as a Running TCX. There is no run/walk switch left on the screen.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:workout_app/models/run_track.dart';
import 'package:workout_app/services/tcx_codec.dart';

View File

@ -1,6 +1,6 @@
// The optional pace target on the run screen: the picker before the start, the
// coloured current pace while recording, the cues, the notification.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:workout_app/services/pace_band.dart';
import 'package:workout_app/ui/theme.dart';

View File

@ -1,4 +1,4 @@
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:workout_app/models/run_track.dart';
import 'package:workout_app/services/position_source.dart';

View File

@ -1,6 +1,6 @@
// In the sandbox flavor the idle map sits on the replay's first fix: one dot
// at the loop's start, not the whole lap walked before the run.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';

View File

@ -2,7 +2,7 @@
// replayed GPS loop, the recorder, the database and the no-op uploader.
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
@ -94,5 +94,14 @@ void main() {
expect(run.track.distanceM, closeTo(4000, 20));
expect(run.uploadState, RunUploadState.pending);
expect(run.tcxFilename, endsWith('_Running.tcx'));
// The kilometre chimes play after the platform's vibrator probe answers, so
// the last ones can land after the final pump above. audioplayers starts a
// frame callback per play and cancels only the newest on completion; let
// them land and run, or the framework reports them as still running.
await tester.runAsync(
() => Future<void>.delayed(const Duration(milliseconds: 300)),
);
await tester.pump();
await tester.pump();
});
}

View File

@ -1,6 +1,6 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:workout_app/screens/run_screen.dart';
import 'package:workout_app/services/position_source.dart';

View File

@ -1,7 +1,7 @@
// Manual deload from the Settings screen's exercise sheet: the stored and
// shown weights move, a refusal is spoken, a pending stepper write cannot
// undo it, and the progression push fires when the sheet closes.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/screens/settings_screen.dart';

View File

@ -1,6 +1,6 @@
// The PER EXERCISE section: each row opens the workout tile's settings sheet,
// edits persist as they happen, and closing the sheet pushes to Firebase.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/screens/settings_screen.dart';

View File

@ -1,5 +1,5 @@
// The PC LINK section: shows the pairing, validates and persists the host.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/sandbox/sandbox_http.dart';

View File

@ -1,5 +1,5 @@
import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;
import 'package:sqflite_common_ffi/sqflite_ffi.dart';

View File

@ -1,6 +1,6 @@
// The SANDBOX section: present only in the sandbox flavor, and each of its
// three controls acts on the (sandbox's) database and reports back.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/sandbox/sandbox.dart';

View File

@ -1,5 +1,5 @@
// The Settings sound switch: one switch for every cue, remembered.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/screens/settings_screen.dart';

View File

@ -1,5 +1,5 @@
import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;
import 'package:sqflite_common_ffi/sqflite_ffi.dart';

View File

@ -1,5 +1,5 @@
import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;
import 'package:sqflite_common_ffi/sqflite_ffi.dart';

View File

@ -1,5 +1,5 @@
import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;
import 'package:sqflite_common_ffi/sqflite_ffi.dart';

View File

@ -1,5 +1,5 @@
// The export/import buttons in Settings reload the screen after an import.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/screens/settings_screen.dart';

View File

@ -2,7 +2,7 @@
// while the app was not.
//
// Split out of workout_breaks_test.dart to stay under the repo's 250-line cap.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/services/storage_service.dart';

View File

@ -2,7 +2,7 @@
//
// Split out of workout_screen_test.dart, which keeps the render and
// restore-on-construction tests.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/models/exercise.dart';

View File

@ -1,6 +1,6 @@
// The feedback cues: a haptic on recording a set, and a haptic, a chime and
// an arriving dialog on finishing. Reward the RECORDING, never the number.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';

View File

@ -1,6 +1,6 @@
// Finishing a workout whose break service will not stop: the summary still
// appears (the stop no longer gates it) and the failure is logged, not thrown.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';

View File

@ -7,7 +7,7 @@
import 'dart:io';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter/services.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';

View File

@ -1,7 +1,7 @@
// When the break service starts: on open for a restored session, on the
// first tap for a fresh one -- the launch opens the workout by itself, and
// just opening the app must not leave a notification behind.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';

View File

@ -1,6 +1,6 @@
// An exercise on an injury pause: no sets to tap, Finish does not wait for
// it, the notification skips it, and it is recorded as FAILED.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';

View File

@ -4,7 +4,7 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';

View File

@ -4,7 +4,7 @@
// Split out of workout_screen_intents_test.dart to stay under the repo's
// 250-line cap; the shared setup is duplicated rather than exported because
// each test file owns its own fakes.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';

View File

@ -4,7 +4,7 @@
// The real client reports isSupported == false off Android, so these inject a
// fake one -- otherwise the whole notification path is dead code on the test
// host and none of these rules would ever be exercised.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';

View File

@ -1,4 +1,4 @@
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/models/exercise.dart';

View File

@ -1,6 +1,6 @@
// The sound switch reaches every sound: the break-end cue on screen, and the
// foreground service that rings it when the screen is off.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';

View File

@ -5,7 +5,7 @@
// besides exercise names and unit symbols after numbers.
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/models/exercise.dart';

View File

@ -1,7 +1,7 @@
// textgate guard, widget states the screen-level guard does not reach:
// every sync-card state, every PC poke outcome, the settings sheet in each
// progression mode, and the GitHub mirror screen.
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/models/exercise_state.dart';

Some files were not shown because too many files have changed in this diff Show More