Fix flaky/wrong test harnesses; fix IndVortex off-by-one abort

- palette_window/palette_icons tests: newer ImageMagick prints
  1526 (0.0138727) for compare -metric AE, so the integer -gt test
  failed on a passing diff; strip to the bare count. Palette window
  suite now 16/16.
- code_window test: View -> Code View reopen used F10 menu navigation
  (does not fire under bare Xvfb here) and fallback clicks at (130,12)
  that hit Debug, not View (View spans x 80-128); click the measured
  positions instead (108,12 then 162,37). Suite now ALL PASS.
- chart_pro render test: the resize-allocation check raced the Xvfb
  configure event (same binary passed 1/3 runs); wait boundedly for
  the allocation to shrink instead of a single pump().
- IndVortex: off-by-one in ind_vortex() aborted the layout on place
  (series[k-1] with k=0 when i=period-1); guard is now i < period.
  Pre-existing in the CWidgets source, fixed here in lightgui only.
  Placement test now 547/547 place, 547/547 draw, 0 failures.
Regenerated screenshots + palette_layout_results.csv from the passing
runs.
This commit is contained in:
cnmcdee committed 2026-11-29 04:50:01 +00:00
1 parent 6e9e7b5fe3
commit a80fedb026
12 files changed
+23 -12

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 206 KiB

After

Width:  |  Height:  |  Size: 228 KiB

+7 -1
View File
@@ -113,7 +113,13 @@ int main(int argc, char** argv) {
gtk_widget_set_size_request(gtk_widget_get_parent(chart.widget()),
620, 460);
gtk_window_resize(GTK_WINDOW(win), 660, 520);
pump();
// The configure event can arrive after one pump() drains the queue
// (flaky under Xvfb); wait for the allocation to shrink, bounded.
for (int i = 0; i < 40 &&
gtk_widget_get_allocated_width(chart.widget()) >= 700; ++i) {
g_usleep(50000);
pump();
}
check(gtk_widget_get_allocated_width(chart.widget()) < 700,
"chart widget actually resized");
Counts s = render(chart, 640, 480);
+9 -8
View File
@@ -281,17 +281,18 @@ else
fail "close-code-window-keeps-app-alive"
fi
[ -z "$(codewin_id)" ] && pass "code-window-actually-closed" || fail "code-window-actually-closed"
DISPLAY="$XDISP" xdotool windowfocus --sync "$MW" key F10 Right Right Down Return 2>/dev/null
# Reopen from View -> Code View by clicking: F10 menubar activation does
# not fire under bare Xvfb here, and the old fallback coordinates were
# wrong for this menubar (130,12 hits Debug, not View). Measured on this
# display: View spans x 80-128, its submenu opens at x 80, first item
# (Code View) centred near (162, 37) relative to the main window.
DISPLAY="$XDISP" xdotool windowraise "$MW" mousemove --window "$MW" 108 12 click 1 2>/dev/null
sleep 0.7
DISPLAY="$XDISP" xdotool mousemove --window "$MW" 162 37 click 1 2>/dev/null
if wait_win codewin 10; then
pass "view-menu-reopens-code-window"
else
# Fallback: click the View menu, then its first item.
GEOM=$(DISPLAY="$XDISP" xdotool getwindowgeometry --shell "$MW" 2>/dev/null)
WX=$(echo "$GEOM" | sed -n 's/^X=//p'); WY=$(echo "$GEOM" | sed -n 's/^Y=//p')
DISPLAY="$XDISP" xdotool windowraise "$MW" mousemove --window "$MW" 130 12 click 1 2>/dev/null
sleep 0.7
DISPLAY="$XDISP" xdotool mousemove --window "$MW" 140 55 click 1 2>/dev/null
if wait_win codewin 10; then pass "view-menu-reopens-code-window (click fallback)"; else fail "view-menu-reopens-code-window"; fi
fail "view-menu-reopens-code-window"
fi
kill_app
+2
View File
@@ -101,6 +101,8 @@ if [ -n "$PAL" ] && [ -n "$MAIN" ]; then
import -window root -crop 500x220+${CX}+${CY} /tmp/icons_after.png
DIFF=$(compare -metric AE -fuzz 5% /tmp/icons_before.png \
/tmp/icons_after.png /tmp/icons_diff.png 2>&1 || true)
# Newer ImageMagick prints "1526 (0.0138727)"; keep the bare count.
DIFF=${DIFF%% *}
echo "canvas pixel diff: $DIFF"
if [ "${DIFF:-0}" -gt 1000 ] 2>/dev/null; then ok palette-click-places;
else bad palette-click-places; fi
+2
View File
@@ -123,6 +123,8 @@ if [ -n "$PAL" ] && [ -n "$MAIN" ]; then
import -window root -crop 500x220+${CX}+${CY} /tmp/palette_after.png
DIFF=$(compare -metric AE -fuzz 5% /tmp/palette_before.png \
/tmp/palette_after.png /tmp/palette_diff.png 2>&1 || true)
# Newer ImageMagick prints "1526 (0.0138727)"; keep the bare count.
DIFF=${DIFF%% *}
echo "canvas pixel diff: $DIFF"
if [ "${DIFF:-0}" -gt 1000 ] 2>/dev/null; then ok palette-places-widgets;
else bad palette-places-widgets; fi
+1 -1
View File
@@ -207,7 +207,7 @@ inline std::vector<double> adx_v(const OHLCVSeries& s, int p) {
} // namespace detail_vortex
struct VortexResult { std::vector<double> plus; std::vector<double> minus; };
VortexResult ind_vortex(const OHLCVSeries& series, int period) { VortexResult r; r.plus.assign(series.size(), detail_vortex::nan_v()); r.minus.assign(series.size(), detail_vortex::nan_v()); if (period < 1) period = 1; std::vector<double> tr = detail_vortex::tr_v(series); for (size_t i = 0; i < series.size(); ++i) { if (i + 1 < (size_t)period || i == 0) continue; double vmp = 0.0, vmm = 0.0, trs = 0.0; for (int j = 0; j < period; ++j) { size_t k = i - (size_t)j; vmp += std::fabs(series[k].high - series[k - 1].low); vmm += std::fabs(series[k].low - series[k - 1].high); trs += tr[k]; } if (trs > 0.0) { r.plus[i] = vmp / trs; r.minus[i] = vmm / trs; } } return r; }
VortexResult ind_vortex(const OHLCVSeries& series, int period) { VortexResult r; r.plus.assign(series.size(), detail_vortex::nan_v()); r.minus.assign(series.size(), detail_vortex::nan_v()); if (period < 1) period = 1; std::vector<double> tr = detail_vortex::tr_v(series); for (size_t i = 0; i < series.size(); ++i) { if (i < (size_t)period) continue; /* need k>=1 so series[k-1] is valid */ double vmp = 0.0, vmm = 0.0, trs = 0.0; for (int j = 0; j < period; ++j) { size_t k = i - (size_t)j; vmp += std::fabs(series[k].high - series[k - 1].low); vmm += std::fabs(series[k].low - series[k - 1].high); trs += tr[k]; } if (trs > 0.0) { r.plus[i] = vmp / trs; r.minus[i] = vmm / trs; } } return r; }
class IndVortex {
private:
Display* display_; int screen_; Window window_; GC gc_;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

@@ -337,7 +337,7 @@ IndVolumePriceTrend,PASS,PASS,6662,
IndVolumeRateOfChange,PASS,PASS,13048,
IndVolumeWeightedMovingAverage,PASS,PASS,7975,
IndVolumeZoneOscillator,PASS,PASS,8774,
IndVortex,PASS,PASS,4300,
IndVortex,PASS,PASS,8632,
IndWMA,PASS,PASS,7958,
IndWaveTrend,PASS,PASS,4766,
IndWeightedClose,PASS,PASS,7627,
@@ -535,7 +535,7 @@ TStatusBar,PASS,PASS,46800,
TStringGrid,PASS,PASS,16557,
TTabControl,PASS,PASS,45098,
TTaskDialog,PASS,PASS,46582,
TTimeEdit,PASS,PASS,1050,
TTimeEdit,PASS,PASS,1059,
TTimer,PASS,PASS,1194,
TToggleBox,PASS,PASS,46783,
TToolBar,PASS,PASS,46800,
1 name place draw nonwhite note
337 IndVolumeRateOfChange PASS PASS 13048
338 IndVolumeWeightedMovingAverage PASS PASS 7975
339 IndVolumeZoneOscillator PASS PASS 8774
340 IndVortex PASS PASS 4300 8632
341 IndWMA PASS PASS 7958
342 IndWaveTrend PASS PASS 4766
343 IndWeightedClose PASS PASS 7627
535 TStringGrid PASS PASS 16557
536 TTabControl PASS PASS 45098
537 TTaskDialog PASS PASS 46582
538 TTimeEdit PASS PASS 1050 1059
539 TTimer PASS PASS 1194
540 TToggleBox PASS PASS 46783
541 TToolBar PASS PASS 46800