22struct ViewAssertionAverageColor {
24 aui::float_within_0_1 mInaccuracy;
26 ViewAssertionAverageColor(
const AColor& color, aui::float_within_0_1 inaccuracy = 0.1f) : mColor(color), mInaccuracy(inaccuracy) {}
29 glm::vec3 average(ScreenshotAnalyzer::makeScreenshot().clip(v).averageColor());
30 auto d = glm::length2(average - glm::vec3(mColor)) / 3;
31 return d <= mInaccuracy;
43struct ViewAssertionPixelColorAt {
44 using RelativePosition = glm::vec<2, aui::float_within_0_1>;
45 RelativePosition mRelativePosition;
47 aui::float_within_0_1 mInaccuracy;
49 ViewAssertionPixelColorAt(RelativePosition relativePosition,
const AColor& color, aui::float_within_0_1 inaccuracy = 0.1f): mRelativePosition(relativePosition), mColor(color), mInaccuracy(inaccuracy) {}
52 auto screenshot = ScreenshotAnalyzer::makeScreenshot().clip(v);
53 auto mappedPos = glm::uvec2(glm::vec2(screenshot.image().size() - 1u) * glm::vec2(mRelativePosition));
54 auto target = glm::vec3(screenshot.image().get(glm::min(mappedPos, screenshot.image().size() - 1u)));
55 auto d = glm::length2(target - glm::vec3(mColor)) / 3;
56 return d <= mInaccuracy;