Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit d0cf61d

Browse files
committed
made the fuzzy paramters specific to the whole runner, not the test suite
1 parent 3f3be86 commit d0cf61d

File tree

4 files changed

+23
-32
lines changed

4 files changed

+23
-32
lines changed

impeller/golden_tests/golden_digest.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
#include <fstream>
88

9+
static const double kMaxDiffPixelsPercent = 0.01;
10+
static const int32_t kMaxColorDelta = 8;
11+
912
namespace impeller {
1013
namespace testing {
1114

@@ -23,11 +26,9 @@ GoldenDigest::GoldenDigest() {}
2326
void GoldenDigest::AddImage(const std::string& test_name,
2427
const std::string& filename,
2528
int32_t width,
26-
int32_t height,
27-
double max_diff_pixels_percent,
28-
int32_t max_color_delta) {
29-
entries_.push_back({test_name, filename, width, height,
30-
max_diff_pixels_percent, max_color_delta});
29+
int32_t height) {
30+
entries_.push_back({test_name, filename, width, height, kMaxDiffPixelsPercent,
31+
kMaxColorDelta});
3132
}
3233

3334
bool GoldenDigest::Write(WorkingDirectory* working_directory) {

impeller/golden_tests/golden_digest.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ class GoldenDigest {
2121
void AddImage(const std::string& test_name,
2222
const std::string& filename,
2323
int32_t width,
24-
int32_t height,
25-
double max_diff_pixels_percent,
26-
int32_t max_color_delta);
24+
int32_t height);
2725

2826
/// Writes a "digest.json" file to `working_directory`.
2927
///

impeller/golden_tests/golden_playground_test_mac.cc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,14 @@ std::string GetGoldenFilename() {
2828
return GetTestName() + ".png";
2929
}
3030

31-
bool SaveScreenshot(std::unique_ptr<testing::MetalScreenshot> screenshot,
32-
double max_diff_pixels_percent,
33-
int32_t max_color_delta) {
31+
bool SaveScreenshot(std::unique_ptr<testing::MetalScreenshot> screenshot) {
3432
if (!screenshot || !screenshot->GetBytes()) {
3533
return false;
3634
}
3735
std::string test_name = GetTestName();
3836
std::string filename = GetGoldenFilename();
3937
testing::GoldenDigest::Instance()->AddImage(
40-
test_name, filename, screenshot->GetWidth(), screenshot->GetHeight(),
41-
max_diff_pixels_percent, max_color_delta);
38+
test_name, filename, screenshot->GetWidth(), screenshot->GetHeight());
4239
return screenshot->WriteToPNG(
4340
testing::WorkingDirectory::Instance()->GetFilenamePath(filename));
4441
}
@@ -48,8 +45,6 @@ struct GoldenPlaygroundTest::GoldenPlaygroundTestImpl {
4845
GoldenPlaygroundTestImpl() : screenshoter(new testing::MetalScreenshoter()) {}
4946
std::unique_ptr<testing::MetalScreenshoter> screenshoter;
5047
ISize window_size = ISize{1024, 768};
51-
const double max_diff_pixels_percent = 0.01;
52-
const int32_t max_color_delta = 8;
5348
};
5449

5550
GoldenPlaygroundTest::GoldenPlaygroundTest()
@@ -103,8 +98,7 @@ PlaygroundBackend GoldenPlaygroundTest::GetBackend() const {
10398
bool GoldenPlaygroundTest::OpenPlaygroundHere(const Picture& picture) {
10499
auto screenshot =
105100
pimpl_->screenshoter->MakeScreenshot(picture, pimpl_->window_size);
106-
return SaveScreenshot(std::move(screenshot), pimpl_->max_diff_pixels_percent,
107-
pimpl_->max_color_delta);
101+
return SaveScreenshot(std::move(screenshot));
108102
}
109103

110104
bool GoldenPlaygroundTest::OpenPlaygroundHere(

impeller/golden_tests/golden_tests.cc

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ std::string GetTestName() {
3131
std::string GetGoldenFilename() {
3232
return GetTestName() + ".png";
3333
}
34+
35+
bool SaveScreenshot(std::unique_ptr<MetalScreenshot> screenshot) {
36+
if (!screenshot || !screenshot->GetBytes()) {
37+
return false;
38+
}
39+
std::string test_name = GetTestName();
40+
std::string filename = GetGoldenFilename();
41+
GoldenDigest::Instance()->AddImage(
42+
test_name, filename, screenshot->GetWidth(), screenshot->GetHeight());
43+
return screenshot->WriteToPNG(
44+
WorkingDirectory::Instance()->GetFilenamePath(filename));
45+
}
46+
3447
} // namespace
3548

3649
class GoldenTests : public ::testing::Test {
@@ -39,23 +52,8 @@ class GoldenTests : public ::testing::Test {
3952

4053
MetalScreenshoter& Screenshoter() { return *screenshoter_; }
4154

42-
bool SaveScreenshot(std::unique_ptr<MetalScreenshot> screenshot) {
43-
if (!screenshot || !screenshot->GetBytes()) {
44-
return false;
45-
}
46-
std::string test_name = GetTestName();
47-
std::string filename = GetGoldenFilename();
48-
GoldenDigest::Instance()->AddImage(
49-
test_name, filename, screenshot->GetWidth(), screenshot->GetHeight(),
50-
max_diff_pixels_percent_, max_color_delta_);
51-
return screenshot->WriteToPNG(
52-
WorkingDirectory::Instance()->GetFilenamePath(filename));
53-
}
54-
5555
private:
5656
std::unique_ptr<MetalScreenshoter> screenshoter_;
57-
const double max_diff_pixels_percent_ = 0.01;
58-
const int32_t max_color_delta_ = 8;
5957
};
6058

6159
TEST_F(GoldenTests, ConicalGradient) {

0 commit comments

Comments
 (0)