Skip to content

Commit

Permalink
Fix test and change dummy view ID
Browse files Browse the repository at this point in the history
  • Loading branch information
dkwingsmt committed Oct 23, 2023
1 parent c79fe37 commit 4868038
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
8 changes: 6 additions & 2 deletions shell/common/shell_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ namespace flutter {
namespace testing {

constexpr int64_t kImplicitViewId = 0;
// Use a very large number that is not implicit view, so that if people
// accidentally used PumpOneFrame(shell) while rendering some content
// into the implicit view, their content wouldn't be skipped.
constexpr int64_t kDummyView = 0xdeadbeef;

FrameContent ViewContent::NoViews() {
return std::map<int64_t, ViewContent>();
}

FrameContent ViewContent::DummyView(double width, double height) {
FrameContent result;
result[kImplicitViewId] = ViewContent{
result[kDummyView] = ViewContent{
.viewport_metrics = {1.0, width, height, 22, 0},
.builder = {},
};
Expand All @@ -37,7 +41,7 @@ FrameContent ViewContent::DummyView(double width, double height) {

FrameContent ViewContent::DummyView(flutter::ViewportMetrics viewport_metrics) {
FrameContent result;
result[kImplicitViewId] = ViewContent{
result[kDummyView] = ViewContent{
.viewport_metrics = std::move(viewport_metrics),
.builder = {},
};
Expand Down
13 changes: 9 additions & 4 deletions shell/common/shell_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ struct ViewContent {
// to schedule the frame while the frame content is defined by other means.
static FrameContent NoViews();

// Build a frame with a single implicit view with the specific size and no
// content.
// Build a frame with a single view with the specific size and no content.
static FrameContent DummyView(double width = 1, double height = 1);

// Build a frame with a single implicit view with the specific viewport
// metrics and no content.
// Build a frame with a single view with the specific viewport metrics and no
// content.
static FrameContent DummyView(flutter::ViewportMetrics viewport_metrics);

// Build a frame with a single implicit view with the specific size and
Expand Down Expand Up @@ -108,6 +107,12 @@ class ShellTest : public FixtureTest {
static void SetViewportMetrics(Shell* shell, double width, double height);
static void NotifyIdle(Shell* shell, fml::TimeDelta deadline);

// By default PumpOneFrame renders dummy content into a dummy view that is
// not view ID. If the test case provide its own content, such as calling
// FlutterView.render in a Dart callback, you should probably pump a frame
// with no extra content using:
//
// PumpOneFrame(shell, FrameContent::NoViews())
static void PumpOneFrame(Shell* shell);
static void PumpOneFrame(Shell* shell, FrameContent frame_content);
static void DispatchFakePointerData(Shell* shell);
Expand Down
2 changes: 1 addition & 1 deletion shell/common/shell_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2750,7 +2750,7 @@ TEST_F(ShellTest, OnServiceProtocolRenderFrameWithRasterStatsDisableImpeller) {
configuration.SetEntrypoint("scene_with_red_box");

RunEngine(shell.get(), std::move(configuration));
PumpOneFrame(shell.get());
PumpOneFrame(shell.get(), ViewContent::NoViews());

ServiceProtocol::Handler::ServiceProtocolMap empty_params;
rapidjson::Document document;
Expand Down

0 comments on commit 4868038

Please sign in to comment.