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

Commit 0e7213c

Browse files
authored
[Win32] Use mock macro for UpdateSemanticsEnabled (#29976)
Previously, we'd mocked out UpdateSemanticsEnabled using a simple lambda. Due to the embedder API's C ABI, we were unable to make use of lambda captures. This patch instead uses MOCK_ENGINE_PROC so we can make the test variable a local and rely on lambda capture. Issue: flutter/flutter#77838
1 parent 1244fde commit 0e7213c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

shell/platform/windows/flutter_windows_view_unittests.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ struct TestResponseHandle {
3535
};
3636

3737
static bool test_response = false;
38-
static bool semantics_enabled = false;
3938

4039
constexpr uint64_t kKeyEventFromChannel = 0x11;
4140
constexpr uint64_t kKeyEventFromEmbedder = 0x22;
@@ -130,11 +129,15 @@ TEST(FlutterWindowsViewTest, RestartClearsKeyboardState) {
130129
TEST(FlutterWindowsViewTest, EnableSemantics) {
131130
std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
132131
EngineModifier modifier(engine.get());
133-
modifier.embedder_api().UpdateSemanticsEnabled =
134-
[](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
132+
133+
bool semantics_enabled = false;
134+
modifier.embedder_api().UpdateSemanticsEnabled = MOCK_ENGINE_PROC(
135+
UpdateSemanticsEnabled,
136+
[&semantics_enabled](FLUTTER_API_SYMBOL(FlutterEngine) engine,
137+
bool enabled) {
135138
semantics_enabled = enabled;
136139
return kSuccess;
137-
};
140+
});
138141

139142
auto window_binding_handler =
140143
std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();

0 commit comments

Comments
 (0)