yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
screenshot_assertion.h File Reference
#include <chrono>
#include <cstdint>
#include <functional>
#include <string>
#include <vector>
#include "absl/status/status.h"
#include "absl/status/statusor.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  yaze::test::ScreenRegion
 Region of interest for screenshot comparison. More...
 
struct  yaze::test::ComparisonResult
 Result of a screenshot comparison. More...
 
struct  yaze::test::ComparisonConfig
 Configuration for screenshot comparison. More...
 
struct  yaze::test::Screenshot
 Screenshot data container. More...
 
class  yaze::test::ScreenshotAssertion
 Utilities for screenshot-based testing assertions. More...
 

Namespaces

namespace  yaze
 
namespace  yaze::test
 

Macros

#define YAZE_ASSERT_SCREENSHOT_MATCHES(assertion, reference_path)
 Assert screenshot matches reference (for use in tests).
 
#define YAZE_ASSERT_SCREENSHOT_CHANGED(assertion, baseline_name)
 Assert screenshot has changed from baseline.
 
#define YAZE_ASSERT_SCREENSHOT_UNCHANGED(assertion, baseline_name)
 Assert screenshot has NOT changed from baseline.
 

Macro Definition Documentation

◆ YAZE_ASSERT_SCREENSHOT_MATCHES

#define YAZE_ASSERT_SCREENSHOT_MATCHES ( assertion,
reference_path )
Value:
do { \
auto result = (assertion).AssertMatchesReference(reference_path); \
ASSERT_TRUE(result.ok()) << result.status().message(); \
EXPECT_TRUE(result->passed) \
<< "Screenshot mismatch: " << result->difference_percentage \
<< "% different, expected <" << (1.0f - (assertion).GetConfig().tolerance) * 100 \
<< "%\nDiff image: " << result->diff_image_path; \
} while (0)

Assert screenshot matches reference (for use in tests).

Usage:

YAZE_ASSERT_SCREENSHOT_MATCHES(assertion, "expected.png");
#define YAZE_ASSERT_SCREENSHOT_MATCHES(assertion, reference_path)
Assert screenshot matches reference (for use in tests).

Definition at line 302 of file screenshot_assertion.h.

◆ YAZE_ASSERT_SCREENSHOT_CHANGED

#define YAZE_ASSERT_SCREENSHOT_CHANGED ( assertion,
baseline_name )
Value:
do { \
auto result = (assertion).AssertChanged(baseline_name); \
ASSERT_TRUE(result.ok()) << result.status().message(); \
EXPECT_TRUE(result->passed) \
<< "Expected screenshot to change but similarity was " \
<< result->similarity * 100 << "%"; \
} while (0)

Assert screenshot has changed from baseline.

Definition at line 315 of file screenshot_assertion.h.

◆ YAZE_ASSERT_SCREENSHOT_UNCHANGED

#define YAZE_ASSERT_SCREENSHOT_UNCHANGED ( assertion,
baseline_name )
Value:
do { \
auto result = (assertion).AssertUnchanged(baseline_name); \
ASSERT_TRUE(result.ok()) << result.status().message(); \
EXPECT_TRUE(result->passed) \
<< "Expected screenshot unchanged but " \
<< result->difference_percentage << "% different\n" \
<< "Diff image: " << result->diff_image_path; \
} while (0)

Assert screenshot has NOT changed from baseline.

Definition at line 327 of file screenshot_assertion.h.