Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf598224

Browse files
authored
[Impeller] Adds golden image tests. (#40366)
Added golden image tests to impeller
1 parent274196e commitf598224

27 files changed

+881
-7
lines changed

‎.ci.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,10 @@ targets:
380380
properties:
381381
release_build:"true"
382382
config_name:mac_host_engine
383+
dependencies:>-
384+
[
385+
{"dependency": "goldctl", "version": "git_revision:3a77d0b12c697a840ca0c7705208e8622dc94603"}
386+
]
383387
$flutter/osx_sdk :>-
384388
{ "sdk_version": "14a5294e" }
385389

‎BUILD.gn‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ group("unittests") {
181181
}
182182

183183
if (is_mac) {
184-
public_deps+=
185-
["//flutter/shell/platform/darwin:flutter_channels_unittests" ]
186184
public_deps+= [
185+
"//flutter/impeller/golden_tests:impeller_golden_tests",
186+
"//flutter/shell/platform/darwin:flutter_channels_unittests",
187187
"//flutter/third_party/spring_animation:spring_animation_unittests",
188188
]
189189
}

‎ci/builders/mac_host_engine.json‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@
110110
"os=Mac-12",
111111
"cpu=x86"
112112
],
113+
"dependencies": [
114+
{"dependency":"goldctl","version":"git_revision:3a77d0b12c697a840ca0c7705208e8622dc94603"}
115+
],
113116
"gclient_custom_vars": {
114117
"download_android_deps":false
115118
},
@@ -124,13 +127,27 @@
124127
"ninja": {
125128
"config":"host_release",
126129
"targets": [
127-
"flutter/shell/platform/darwin/macos:zip_macos_flutter_framework",
128130
"flutter/build/archives:archive_gen_snapshot",
129131
"flutter/build/archives:artifacts",
132+
"flutter/impeller/golden_tests:impeller_golden_tests",
133+
"flutter/shell/platform/darwin/macos:zip_macos_flutter_framework",
130134
"flutter/tools/font-subset"
131135
]
132136
},
133-
"tests": []
137+
"tests": [
138+
{
139+
"language":"python3",
140+
"name":"Impeller golden Tests for host_release",
141+
"parameters": [
142+
"--variant",
143+
"host_release",
144+
"--type",
145+
"impeller-golden"
146+
],
147+
"script":"flutter/testing/run_tests.py",
148+
"type":"local"
149+
}
150+
]
134151
},
135152
{
136153
"archives": [

‎ci/licenses_golden/excluded_files‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@
135135
../../../flutter/impeller/geometry/README.md
136136
../../../flutter/impeller/geometry/geometry_unittests.cc
137137
../../../flutter/impeller/geometry/geometry_unittests.h
138+
../../../flutter/impeller/golden_tests/README.md
139+
../../../flutter/impeller/golden_tests_harvester/.dart_tool
140+
../../../flutter/impeller/golden_tests_harvester/.gitignore
141+
../../../flutter/impeller/golden_tests_harvester/README.md
142+
../../../flutter/impeller/golden_tests_harvester/analysis_options.yaml
143+
../../../flutter/impeller/golden_tests_harvester/pubspec.lock
144+
../../../flutter/impeller/golden_tests_harvester/pubspec.yaml
145+
../../../flutter/impeller/golden_tests_harvester/test
138146
../../../flutter/impeller/image/README.md
139147
../../../flutter/impeller/playground
140148
../../../flutter/impeller/renderer/compute_subgroup_unittests.cc

‎ci/licenses_golden/licenses_flutter‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,19 @@ ORIGIN: ../../../flutter/impeller/geometry/type_traits.cc + ../../../flutter/LIC
13151315
ORIGIN: ../../../flutter/impeller/geometry/type_traits.h + ../../../flutter/LICENSE
13161316
ORIGIN: ../../../flutter/impeller/geometry/vector.cc + ../../../flutter/LICENSE
13171317
ORIGIN: ../../../flutter/impeller/geometry/vector.h + ../../../flutter/LICENSE
1318+
ORIGIN: ../../../flutter/impeller/golden_tests/golden_digest.cc + ../../../flutter/LICENSE
1319+
ORIGIN: ../../../flutter/impeller/golden_tests/golden_digest.h + ../../../flutter/LICENSE
1320+
ORIGIN: ../../../flutter/impeller/golden_tests/golden_tests.cc + ../../../flutter/LICENSE
1321+
ORIGIN: ../../../flutter/impeller/golden_tests/main.cc + ../../../flutter/LICENSE
1322+
ORIGIN: ../../../flutter/impeller/golden_tests/metal_screenshot.h + ../../../flutter/LICENSE
1323+
ORIGIN: ../../../flutter/impeller/golden_tests/metal_screenshot.mm + ../../../flutter/LICENSE
1324+
ORIGIN: ../../../flutter/impeller/golden_tests/metal_screenshoter.h + ../../../flutter/LICENSE
1325+
ORIGIN: ../../../flutter/impeller/golden_tests/metal_screenshoter.mm + ../../../flutter/LICENSE
1326+
ORIGIN: ../../../flutter/impeller/golden_tests/working_directory.cc + ../../../flutter/LICENSE
1327+
ORIGIN: ../../../flutter/impeller/golden_tests/working_directory.h + ../../../flutter/LICENSE
1328+
ORIGIN: ../../../flutter/impeller/golden_tests_harvester/bin/golden_tests_harvester.dart + ../../../flutter/LICENSE
1329+
ORIGIN: ../../../flutter/impeller/golden_tests_harvester/lib/golden_tests_harvester.dart + ../../../flutter/LICENSE
1330+
ORIGIN: ../../../flutter/impeller/golden_tests_harvester/lib/logger.dart + ../../../flutter/LICENSE
13181331
ORIGIN: ../../../flutter/impeller/image/backends/skia/compressed_image_skia.cc + ../../../flutter/LICENSE
13191332
ORIGIN: ../../../flutter/impeller/image/backends/skia/compressed_image_skia.h + ../../../flutter/LICENSE
13201333
ORIGIN: ../../../flutter/impeller/image/compressed_image.cc + ../../../flutter/LICENSE
@@ -3856,6 +3869,19 @@ FILE: ../../../flutter/impeller/geometry/type_traits.cc
38563869
FILE: ../../../flutter/impeller/geometry/type_traits.h
38573870
FILE: ../../../flutter/impeller/geometry/vector.cc
38583871
FILE: ../../../flutter/impeller/geometry/vector.h
3872+
FILE: ../../../flutter/impeller/golden_tests/golden_digest.cc
3873+
FILE: ../../../flutter/impeller/golden_tests/golden_digest.h
3874+
FILE: ../../../flutter/impeller/golden_tests/golden_tests.cc
3875+
FILE: ../../../flutter/impeller/golden_tests/main.cc
3876+
FILE: ../../../flutter/impeller/golden_tests/metal_screenshot.h
3877+
FILE: ../../../flutter/impeller/golden_tests/metal_screenshot.mm
3878+
FILE: ../../../flutter/impeller/golden_tests/metal_screenshoter.h
3879+
FILE: ../../../flutter/impeller/golden_tests/metal_screenshoter.mm
3880+
FILE: ../../../flutter/impeller/golden_tests/working_directory.cc
3881+
FILE: ../../../flutter/impeller/golden_tests/working_directory.h
3882+
FILE: ../../../flutter/impeller/golden_tests_harvester/bin/golden_tests_harvester.dart
3883+
FILE: ../../../flutter/impeller/golden_tests_harvester/lib/golden_tests_harvester.dart
3884+
FILE: ../../../flutter/impeller/golden_tests_harvester/lib/logger.dart
38593885
FILE: ../../../flutter/impeller/image/backends/skia/compressed_image_skia.cc
38603886
FILE: ../../../flutter/impeller/image/backends/skia/compressed_image_skia.h
38613887
FILE: ../../../flutter/impeller/image/compressed_image.cc

‎impeller/golden_tests/BUILD.gn‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
import("//flutter/common/config.gni")
6+
import("//flutter/impeller/tools/impeller.gni")
7+
8+
if (is_mac) {
9+
test_fixtures("impeller_golden_tests_fixtures") {
10+
fixtures= []
11+
}
12+
13+
impeller_component("impeller_golden_tests") {
14+
target_type="executable"
15+
16+
testonly=true
17+
18+
sources= [
19+
"golden_digest.cc",
20+
"golden_digest.h",
21+
"golden_tests.cc",
22+
"main.cc",
23+
"metal_screenshot.h",
24+
"metal_screenshot.mm",
25+
"metal_screenshoter.h",
26+
"metal_screenshoter.mm",
27+
"working_directory.cc",
28+
"working_directory.h",
29+
]
30+
31+
deps= [
32+
":impeller_golden_tests_fixtures",
33+
"//flutter/impeller/aiks",
34+
"//flutter/impeller/playground",
35+
"//flutter/impeller/renderer/backend/metal:metal",
36+
"//third_party/googletest:gtest",
37+
]
38+
}
39+
}

‎impeller/golden_tests/README.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#Impeller Golden Tests
2+
3+
This is the executable that will generate the golden image results that can then
4+
be sent to Skia Gold vial the
5+
[golden_tests_harvester]("../golden_tests_harvester").
6+
7+
Running these tests should happen from
8+
[//flutter/testing/run_tests.py](../../testing/run_tests.py). That will do all
9+
the steps to generate the golden images and transmit them to Skia Gold. If you
10+
run the tests locally it will not actually upload anything. That only happens if
11+
the script is executed from LUCI.
12+
13+
Example invocation:
14+
15+
```sh
16+
./run_tests.py --variant="host_debug_unopt_arm64" --type="impeller-golden"
17+
```
18+
19+
Currently these tests are only supported on macOS and only test the Metal
20+
backend to Impeller.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include"impeller/golden_tests/golden_digest.h"
6+
7+
#include<fstream>
8+
9+
namespaceimpeller {
10+
namespacetesting {
11+
12+
GoldenDigest* GoldenDigest::instance_ =nullptr;
13+
14+
GoldenDigest*GoldenDigest::Instance() {
15+
if (!instance_) {
16+
instance_ =newGoldenDigest();
17+
}
18+
return instance_;
19+
}
20+
21+
GoldenDigest::GoldenDigest() {}
22+
23+
voidGoldenDigest::AddImage(const std::string& test_name,
24+
const std::string& filename,
25+
int32_t width,
26+
int32_t height) {
27+
entries_.push_back({test_name, filename, width, height});
28+
}
29+
30+
boolGoldenDigest::Write(WorkingDirectory* working_directory) {
31+
std::ofstream fout;
32+
fout.open(working_directory->GetFilenamePath("digest.json"));
33+
if (!fout.good()) {
34+
returnfalse;
35+
}
36+
37+
fout <<"[" << std::endl;
38+
bool is_first =true;
39+
for (constauto& entry : entries_) {
40+
if (!is_first) {
41+
fout <<"," << std::endl;
42+
is_first =false;
43+
}
44+
fout <<" {"
45+
<<"\"testName\" :\"" << entry.test_name <<"\","
46+
<<"\"filename\" :\"" << entry.filename <<"\","
47+
<<"\"width\" :" << entry.width <<","
48+
<<"\"height\" :" << entry.height <<""
49+
<<"}";
50+
}
51+
fout << std::endl <<"]" << std::endl;
52+
53+
fout.close();
54+
returntrue;
55+
}
56+
57+
}// namespace testing
58+
}// namespace impeller
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#pragma once
6+
7+
#include<string>
8+
#include<vector>
9+
10+
#include"flutter/fml/macros.h"
11+
#include"flutter/impeller/golden_tests/working_directory.h"
12+
13+
namespaceimpeller {
14+
namespacetesting {
15+
16+
/// Manages a global variable for tracking instances of golden images.
17+
classGoldenDigest {
18+
public:
19+
static GoldenDigest*Instance();
20+
21+
voidAddImage(const std::string& test_name,
22+
const std::string& filename,
23+
int32_t width,
24+
int32_t height);
25+
26+
/// Writes a "digest.json" file to `working_directory`.
27+
///
28+
/// Returns `true` on success.
29+
boolWrite(WorkingDirectory* working_directory);
30+
31+
private:
32+
FML_DISALLOW_COPY_AND_ASSIGN(GoldenDigest);
33+
GoldenDigest();
34+
structEntry {
35+
std::string test_name;
36+
std::string filename;
37+
int32_t width;
38+
int32_t height;
39+
};
40+
41+
static GoldenDigest* instance_;
42+
std::vector<Entry> entries_;
43+
};
44+
}// namespace testing
45+
}// namespace impeller
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include"gtest/gtest.h"
6+
7+
#include<sstream>
8+
9+
#include"impeller/aiks/canvas.h"
10+
#include"impeller/entity/contents/conical_gradient_contents.h"
11+
#include"impeller/geometry/path_builder.h"
12+
#include"impeller/golden_tests/golden_digest.h"
13+
#include"impeller/golden_tests/metal_screenshot.h"
14+
#include"impeller/golden_tests/metal_screenshoter.h"
15+
#include"impeller/golden_tests/working_directory.h"
16+
17+
namespaceimpeller {
18+
namespacetesting {
19+
20+
namespace {
21+
std::stringGetTestName() {
22+
std::string suite_name =
23+
::testing::UnitTest::GetInstance()->current_test_suite()->name();
24+
std::string test_name =
25+
::testing::UnitTest::GetInstance()->current_test_info()->name();
26+
std::stringstream ss;
27+
ss <<"impeller_" << suite_name <<"_" << test_name;
28+
return ss.str();
29+
}
30+
31+
std::stringGetGoldenFilename() {
32+
returnGetTestName() +".png";
33+
}
34+
35+
boolSaveScreenshot(std::unique_ptr<MetalScreenshot> screenshot) {
36+
if (!screenshot || !screenshot->GetBytes()) {
37+
returnfalse;
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+
}// namespace
47+
48+
classGoldenTests : public ::testing::Test {
49+
public:
50+
GoldenTests() : screenshoter_(new MetalScreenshoter()) {}
51+
52+
MetalScreenshoter&Screenshoter() {return *screenshoter_; }
53+
54+
private:
55+
std::unique_ptr<MetalScreenshoter> screenshoter_;
56+
};
57+
58+
TEST_F(GoldenTests, ConicalGradient) {
59+
Canvas canvas;
60+
Paint paint;
61+
paint.color_source_type = Paint::ColorSourceType::kConicalGradient;
62+
paint.color_source = []() {
63+
auto result = std::make_shared<ConicalGradientContents>();
64+
result->SetCenterAndRadius(Point(125,125),125);
65+
result->SetColors({Color(1.0,0.0,0.0,1.0),Color(0.0,0.0,1.0,1.0)});
66+
result->SetStops({0,1});
67+
result->SetFocus(Point(180,180),0);
68+
result->SetTileMode(Entity::TileMode::kClamp);
69+
return result;
70+
};
71+
paint.stroke_width =0.0;
72+
paint.style = Paint::Style::kFill;
73+
canvas.DrawRect(Rect(10,10,250,250), paint);
74+
Picture picture = canvas.EndRecordingAsPicture();
75+
auto screenshot =Screenshoter().MakeScreenshot(std::move(picture));
76+
ASSERT_TRUE(SaveScreenshot(std::move(screenshot)));
77+
}
78+
}// namespace testing
79+
}// namespace impeller

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp