[Win32] Use mock macro for UpdateSemanticsEnabled (flutter/engine#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: https://github.com/flutter/flutter/issues/77838
This commit is contained in:
Chris Bracken
2021-11-29 10:39:54 -08:00
committed by GitHub
parent a151e55d29
commit 5b6219cb49

View File

@@ -35,7 +35,6 @@ struct TestResponseHandle {
};
static bool test_response = false;
static bool semantics_enabled = false;
constexpr uint64_t kKeyEventFromChannel = 0x11;
constexpr uint64_t kKeyEventFromEmbedder = 0x22;
@@ -130,11 +129,15 @@ TEST(FlutterWindowsViewTest, RestartClearsKeyboardState) {
TEST(FlutterWindowsViewTest, EnableSemantics) {
std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
EngineModifier modifier(engine.get());
modifier.embedder_api().UpdateSemanticsEnabled =
[](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
bool semantics_enabled = false;
modifier.embedder_api().UpdateSemanticsEnabled = MOCK_ENGINE_PROC(
UpdateSemanticsEnabled,
[&semantics_enabled](FLUTTER_API_SYMBOL(FlutterEngine) engine,
bool enabled) {
semantics_enabled = enabled;
return kSuccess;
};
});
auto window_binding_handler =
std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();