fix(plot): a degenerate range cannot strand a live axis, and the demo's follow check fails the run
This commit is contained in:
1 parent
77e861f79e
commit
7d2349555d
6 files changed
+146
-13
No files matched your search
+35
-4
@@ -20,7 +20,9 @@
|
||||
// (`XFollow::Live`), driving three wheel notches and a pan through the host's own
|
||||
// controller and printing, at each step, the range's width, its distance behind
|
||||
// the newest sample and the follow state -- the interaction spec §12 is about,
|
||||
// measured on a real stream rather than in a unit test.
|
||||
// measured on a real stream rather than in a unit test. It is a *check*, not a
|
||||
// readout: the run exits non-zero if a measured property fails to hold, or if the
|
||||
// sequence did not get far enough to measure all four.
|
||||
//
|
||||
// The producer is joined before the stream it writes into is destroyed, and
|
||||
// before the host closes the GL context (main's destruction order does that).
|
||||
@@ -183,10 +185,17 @@ struct Meter {
|
||||
/// Each measurement prints the range's width, how far its right edge sits behind the
|
||||
/// newest sample, and whether following is still armed. Only the zoom may change the
|
||||
/// width, only the pan may change the distance behind, and following must be armed
|
||||
/// throughout; the last line of the run says whether that held, so the run is a check
|
||||
/// rather than a printout to be read.
|
||||
/// throughout. The verdict is carried out of the run in `failed`, so `main()` exits
|
||||
/// non-zero on a failed check -- a check whose result only stdout knows is not a check
|
||||
/// -- and also when the sequence never completed, since a run that measured nothing
|
||||
/// has not passed.
|
||||
struct FollowScript {
|
||||
bool enabled = false;
|
||||
/// Set by report(); read by main(). False until the checks have all held.
|
||||
bool failed = false;
|
||||
/// Set by report(): the sequence reached a verdict at all. A run that ended before
|
||||
/// the fourth measurement has not passed, it just has not finished.
|
||||
bool completed = false;
|
||||
plot::u32 step = 0;
|
||||
plot::f64 width[4]{};
|
||||
plot::f64 behind[4]{};
|
||||
@@ -250,7 +259,8 @@ struct FollowScript {
|
||||
const plot::Rect axes = p.layout().axes;
|
||||
const f32 x = axes.x + 0.5f * axes.w;
|
||||
const f32 y = axes.y + 0.5f * axes.h;
|
||||
host.controller().on_pointer({x, y, 0.0f, 0.0f, plot::input::Button::Left, 0, true, true, false});
|
||||
host.controller().on_pointer(
|
||||
{x, y, 0.0f, 0.0f, plot::input::Button::Left, 0, true, true, false});
|
||||
host.controller().on_pointer(
|
||||
{x + 100.0f, y, 100.0f, 0.0f, plot::input::Button::Left, 0, true, false, false});
|
||||
host.controller().on_pointer(
|
||||
@@ -282,6 +292,8 @@ struct FollowScript {
|
||||
const bool pan_only_behind =
|
||||
at_edge(behind[0]) && at_edge(behind[1]) && behind[2] > 1e-6 && same(behind[2], behind[3]);
|
||||
const bool following = live[0] && live[1] && live[2] && live[3];
|
||||
failed = !(zoom_only_width && pan_only_behind && following);
|
||||
completed = true;
|
||||
std::printf(
|
||||
"[glfw_demo] follow checks: width changed only by the zoom: %s; distance behind only"
|
||||
" by the pan: %s; following armed throughout: %s\n",
|
||||
@@ -404,6 +416,25 @@ int main() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// The live-follow script's verdict, before the summary: a run that asked for the
|
||||
// verification and did not get a passing one fails, whether a check said NO or the
|
||||
// sequence never got far enough to say anything (a deadline too short to reach the
|
||||
// fourth measurement -- a run that measured nothing has not passed).
|
||||
if (script.enabled) {
|
||||
if (script.failed) {
|
||||
std::fprintf(stderr,
|
||||
"plot_glfw_demo: the live-follow checks failed (see the 'follow checks'"
|
||||
" line above)\n");
|
||||
return 1;
|
||||
}
|
||||
if (!script.completed) {
|
||||
std::fprintf(stderr,
|
||||
"plot_glfw_demo: the live-follow script did not complete (raise"
|
||||
" PLOT_DEMO_EXIT_AFTER_MS)\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
const plot::Renderer* r = host.renderer();
|
||||
const plot::FrameStats stats = r != nullptr ? r->stats() : plot::FrameStats{};
|
||||
const plot::Rect axes = std::as_const(p).layout().axes;
|
||||
|
||||
Reference in new issue
Block a user