Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
try this for testing.
  • Loading branch information
jonahwilliams committed Jul 11, 2023
commit a08c2221bf6eba63ef3c6c11a4002ae3f44dc066
7 changes: 6 additions & 1 deletion shell/platform/windows/flutter_windows_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,12 @@ bool FlutterWindowsEngine::Run(std::string_view entrypoint) {
FlutterRendererConfig renderer_config;

if (enable_impeller_) {
// Impeller does not support a Software backend. Avoid failling back and
if (!surface_manager_) {
FML_LOG(ERROR) << "Could not create surface manager. Impeller backend "
"does not support software rendering.";
return false;
}
// Impeller does not support a Software backend. Avoid falling back and
// confusing the engine on which renderer is selected.
renderer_config = GetOpenGLRendererConfig();
} else {
Expand Down
35 changes: 35 additions & 0 deletions shell/platform/windows/flutter_windows_engine_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,41 @@ TEST_F(FlutterWindowsEngineTest, RunWithoutANGLEUsesSoftware) {
modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; };
}

TEST_F(FlutterWindowsEngineTest, RunWithoutANGLEOnImpellerFailsToStart) {
FlutterWindowsEngineBuilder builder{GetContext()};
builder.SetSwitches({"--enable-impeller"});
std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
EngineModifier modifier(engine.get());

modifier.embedder_api().NotifyDisplayUpdate =
MOCK_ENGINE_PROC(NotifyDisplayUpdate,
([engine_instance = engine.get()](
FLUTTER_API_SYMBOL(FlutterEngine) raw_engine,
const FlutterEngineDisplaysUpdateType update_type,
const FlutterEngineDisplay* embedder_displays,
size_t display_count) { return kSuccess; }));

// Accessibility updates must do nothing when the embedder engine is mocked
modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
UpdateAccessibilityFeatures,
[](FLUTTER_API_SYMBOL(FlutterEngine) engine,
FlutterAccessibilityFeature flags) { return kSuccess; });

// Stub out UpdateLocales and SendPlatformMessage as we don't have a fully
// initialized engine instance.
modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
UpdateLocales, ([](auto engine, const FlutterLocale** locales,
size_t locales_count) { return kSuccess; }));
modifier.embedder_api().SendPlatformMessage =
MOCK_ENGINE_PROC(SendPlatformMessage,
([](auto engine, auto message) { return kSuccess; }));

// Set the AngleSurfaceManager to nullptr to test software fallback path.
modifier.SetSurfaceManager(nullptr);

EXPECT_FALSE(engine->Run());
}

TEST_F(FlutterWindowsEngineTest, SendPlatformMessageWithoutResponse) {
FlutterWindowsEngineBuilder builder{GetContext()};
std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ void FlutterWindowsEngineBuilder::AddDartEntrypointArgument(std::string arg) {
dart_entrypoint_arguments_.emplace_back(std::move(arg));
}

void FlutterWindowsEngineBuilder::SetSwitches(std::vector<std::string> switches) {
switches_ = std::move(switches);
}

void FlutterWindowsEngineBuilder::SetCreateKeyboardHandlerCallbacks(
KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state,
KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan) {
Expand All @@ -86,6 +90,7 @@ std::unique_ptr<FlutterWindowsEngine> FlutterWindowsEngineBuilder::Build() {
}

FlutterProjectBundle project(properties_);
project.SetSwitches(switches_);

return std::make_unique<TestFlutterWindowsEngine>(project, get_key_state_,
map_vk_to_scan_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ class FlutterWindowsEngineBuilder {
KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state,
KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan);

void SetSwitches(std::vector<std::string> switches);

std::unique_ptr<FlutterWindowsEngine> Build();

private:
WindowsTestContext& context_;
FlutterDesktopEngineProperties properties_ = {};
std::string dart_entrypoint_;
std::vector<std::string> dart_entrypoint_arguments_;
std::vector<std::string> switches_;
KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state_;
KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan_;

Expand Down