This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Adds impeller display list golden tests #52690
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8cdfe11
[Impeller] added display list golden test
gaaclarke a72ae78
refactored test
gaaclarke 3f83d0c
got goldens compiling
gaaclarke 29c5f67
removed include
gaaclarke 13077e4
format
gaaclarke b1ec721
license / tidy
gaaclarke 70586a5
moved the test to the flutter namespace
gaaclarke 83309ea
added test that draws image for goldens
gaaclarke c3fc360
added image to playground tests
gaaclarke 32b911c
updated golden golden
gaaclarke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "impeller/display_list/dl_golden_unittests.h" | ||
|
||
#include "flutter/display_list/dl_builder.h" | ||
#include "flutter/testing/testing.h" | ||
#include "gtest/gtest.h" | ||
|
||
namespace flutter { | ||
namespace testing { | ||
|
||
using impeller::PlaygroundBackend; | ||
using impeller::PlaygroundTest; | ||
|
||
INSTANTIATE_PLAYGROUND_SUITE(DlGoldenTest); | ||
|
||
TEST_P(DlGoldenTest, CanDrawPaint) { | ||
auto draw = [](DlCanvas* canvas, | ||
const std::vector<std::unique_ptr<DlImage>>& images) { | ||
canvas->Scale(0.2, 0.2); | ||
DlPaint paint; | ||
paint.setColor(DlColor::kCyan()); | ||
canvas->DrawPaint(paint); | ||
}; | ||
|
||
DisplayListBuilder builder; | ||
draw(&builder, /*images=*/{}); | ||
|
||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); | ||
} | ||
|
||
TEST_P(DlGoldenTest, CanRenderImage) { | ||
auto draw = [](DlCanvas* canvas, const std::vector<sk_sp<DlImage>>& images) { | ||
FML_CHECK(images.size() >= 1); | ||
DlPaint paint; | ||
paint.setColor(DlColor::kRed()); | ||
canvas->DrawImage(images[0], SkPoint::Make(100.0, 100.0), | ||
DlImageSampling::kLinear, &paint); | ||
}; | ||
|
||
DisplayListBuilder builder; | ||
std::vector<sk_sp<DlImage>> images; | ||
images.emplace_back(CreateDlImageForFixture("kalimba.jpg")); | ||
draw(&builder, images); | ||
|
||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); | ||
} | ||
|
||
} // namespace testing | ||
} // namespace flutter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef FLUTTER_IMPELLER_DISPLAY_LIST_DL_GOLDEN_UNITTESTS_H_ | ||
#define FLUTTER_IMPELLER_DISPLAY_LIST_DL_GOLDEN_UNITTESTS_H_ | ||
|
||
#include "impeller/display_list/dl_playground.h" | ||
#include "impeller/golden_tests/golden_playground_test.h" | ||
|
||
namespace flutter { | ||
namespace testing { | ||
|
||
#ifdef IMPELLER_GOLDEN_TESTS | ||
using DlGoldenTest = impeller::GoldenPlaygroundTest; | ||
#else | ||
using DlGoldenTest = impeller::DlPlayground; | ||
#endif | ||
|
||
} // namespace testing | ||
} // namespace flutter | ||
|
||
#endif // FLUTTER_IMPELLER_DISPLAY_LIST_DL_GOLDEN_UNITTESTS_H_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered making an
OpenPlaygroundHere
that takes in this lambda, but decided to stick with the existing API. The lambda API would remove boilerplate, but this makes the golden tests more accessible to old tests if we want.