Skip to content

Commit 7eb8754

Browse files
authored
EmbedderTest: templatise GetEmbedderContext (flutter#56709)
In many embedder tests, we want to get at the appropriate backend-specific `EmbedderTestContext` subclass (`EmbedderTestContextGL`, etc.) in order to make backend-specific setup calls such as `SetGLFBOCallback()` or others. Formerly, this required casting the returned `EmbedderTestContext&` to the appropriate subclass in each test. This templatises the `GetEmbedderContext()` method to return the appropriate backend-specific subclass directly. Issue: flutter#158998 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent 13450c2 commit 7eb8754

10 files changed

Lines changed: 266 additions & 252 deletions

shell/platform/embedder/tests/embedder_a11y_unittests.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ constexpr static char kTooltip[] = "tooltip";
3333

3434
TEST_F(EmbedderTest, CannotProvideMultipleSemanticsCallbacks) {
3535
{
36-
EmbedderConfigBuilder builder(
37-
GetEmbedderContext(EmbedderTestContextType::kSoftwareContext));
36+
auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
37+
EmbedderConfigBuilder builder(context);
3838
builder.SetSurface(SkISize::Make(1, 1));
3939
builder.GetProjectArgs().update_semantics_callback =
4040
[](const FlutterSemanticsUpdate* update, void* user_data) {};
@@ -46,8 +46,8 @@ TEST_F(EmbedderTest, CannotProvideMultipleSemanticsCallbacks) {
4646
}
4747

4848
{
49-
EmbedderConfigBuilder builder(
50-
GetEmbedderContext(EmbedderTestContextType::kSoftwareContext));
49+
auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
50+
EmbedderConfigBuilder builder(context);
5151
builder.SetSurface(SkISize::Make(1, 1));
5252
builder.GetProjectArgs().update_semantics_callback2 =
5353
[](const FlutterSemanticsUpdate2* update, void* user_data) {};
@@ -61,8 +61,8 @@ TEST_F(EmbedderTest, CannotProvideMultipleSemanticsCallbacks) {
6161
}
6262

6363
{
64-
EmbedderConfigBuilder builder(
65-
GetEmbedderContext(EmbedderTestContextType::kSoftwareContext));
64+
auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
65+
EmbedderConfigBuilder builder(context);
6666
builder.SetSurface(SkISize::Make(1, 1));
6767
builder.GetProjectArgs().update_semantics_callback =
6868
[](const FlutterSemanticsUpdate* update, void* user_data) {};
@@ -76,8 +76,8 @@ TEST_F(EmbedderTest, CannotProvideMultipleSemanticsCallbacks) {
7676
}
7777

7878
{
79-
EmbedderConfigBuilder builder(
80-
GetEmbedderContext(EmbedderTestContextType::kSoftwareContext));
79+
auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
80+
EmbedderConfigBuilder builder(context);
8181
builder.SetSurface(SkISize::Make(1, 1));
8282
builder.GetProjectArgs().update_semantics_callback2 =
8383
[](const FlutterSemanticsUpdate2* update, void* user_data) {};
@@ -98,7 +98,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingV3Callbacks) {
9898
GTEST_SKIP() << "This test crashes on Fuchsia. https://fxbug.dev/87493 ";
9999
#else
100100

101-
auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
101+
auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
102102

103103
fml::AutoResetWaitableEvent signal_native_latch;
104104

@@ -277,7 +277,7 @@ TEST_F(EmbedderA11yTest, A11yStringAttributes) {
277277
GTEST_SKIP() << "This test crashes on Fuchsia. https://fxbug.dev/87493 ";
278278
#else
279279

280-
auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
280+
auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
281281

282282
fml::AutoResetWaitableEvent signal_native_latch;
283283

@@ -397,7 +397,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingV2Callbacks) {
397397
GTEST_SKIP() << "This test crashes on Fuchsia. https://fxbug.dev/87493 ";
398398
#else
399399

400-
auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
400+
auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
401401

402402
fml::AutoResetWaitableEvent signal_native_latch;
403403

@@ -570,7 +570,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingV2Callbacks) {
570570
}
571571

572572
TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingV1Callbacks) {
573-
auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
573+
auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
574574

575575
fml::AutoResetWaitableEvent signal_native_latch;
576576

0 commit comments

Comments
 (0)