forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Windows] Add engine builder to simplify tests (flutter#38546)
* [Windows] Add engine builder to simplify tests * Format
- Loading branch information
1 parent
a63bd85
commit e012dc8
Showing
7 changed files
with
151 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
shell/platform/windows/testing/flutter_windows_engine_builder.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "flutter/shell/platform/windows/testing/flutter_windows_engine_builder.h" | ||
|
||
namespace flutter { | ||
namespace testing { | ||
|
||
FlutterWindowsEngineBuilder::FlutterWindowsEngineBuilder( | ||
WindowsTestContext& context) | ||
: context_(context) { | ||
properties_.assets_path = context.GetAssetsPath().c_str(); | ||
properties_.icu_data_path = context.GetIcuDataPath().c_str(); | ||
properties_.aot_library_path = context.GetAotLibraryPath().c_str(); | ||
} | ||
|
||
FlutterWindowsEngineBuilder::~FlutterWindowsEngineBuilder() = default; | ||
|
||
void FlutterWindowsEngineBuilder::SetDartEntrypoint(std::string entrypoint) { | ||
dart_entrypoint_ = std::move(entrypoint); | ||
properties_.dart_entrypoint = dart_entrypoint_.c_str(); | ||
} | ||
|
||
void FlutterWindowsEngineBuilder::AddDartEntrypointArgument(std::string arg) { | ||
dart_entrypoint_arguments_.emplace_back(std::move(arg)); | ||
} | ||
|
||
std::unique_ptr<FlutterWindowsEngine> FlutterWindowsEngineBuilder::Build() { | ||
std::vector<const char*> dart_args; | ||
dart_args.reserve(dart_entrypoint_arguments_.size()); | ||
|
||
for (const auto& arg : dart_entrypoint_arguments_) { | ||
dart_args.push_back(arg.c_str()); | ||
} | ||
|
||
if (!dart_args.empty()) { | ||
properties_.dart_entrypoint_argv = dart_args.data(); | ||
properties_.dart_entrypoint_argc = dart_args.size(); | ||
} else { | ||
properties_.dart_entrypoint_argv = nullptr; | ||
properties_.dart_entrypoint_argc = 0; | ||
} | ||
|
||
FlutterProjectBundle project(properties_); | ||
|
||
return std::make_unique<FlutterWindowsEngine>(project); | ||
} | ||
|
||
} // namespace testing | ||
} // namespace flutter |
43 changes: 43 additions & 0 deletions
43
shell/platform/windows/testing/flutter_windows_engine_builder.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_FLUTTER_WINDOWS_ENGINE_BUILDER_H_ | ||
#define FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_FLUTTER_WINDOWS_ENGINE_BUILDER_H_ | ||
|
||
#include <memory> | ||
|
||
#include "flutter/shell/platform/windows/flutter_windows_engine.h" | ||
#include "flutter/shell/platform/windows/public/flutter_windows.h" | ||
#include "flutter/shell/platform/windows/testing/windows_test_context.h" | ||
|
||
namespace flutter { | ||
namespace testing { | ||
|
||
class FlutterWindowsEngineBuilder { | ||
public: | ||
explicit FlutterWindowsEngineBuilder(WindowsTestContext& context); | ||
~FlutterWindowsEngineBuilder(); | ||
|
||
void SetDartEntrypoint(std::string entrypoint); | ||
|
||
void AddDartEntrypointArgument(std::string arg); | ||
|
||
std::unique_ptr<FlutterWindowsEngine> Build(); | ||
|
||
// Prevent copying. | ||
FlutterWindowsEngineBuilder(FlutterWindowsEngineBuilder const&) = delete; | ||
FlutterWindowsEngineBuilder& operator=(FlutterWindowsEngineBuilder const&) = | ||
delete; | ||
|
||
private: | ||
WindowsTestContext& context_; | ||
FlutterDesktopEngineProperties properties_ = {}; | ||
std::string dart_entrypoint_; | ||
std::vector<std::string> dart_entrypoint_arguments_; | ||
}; | ||
|
||
} // namespace testing | ||
} // namespace flutter | ||
|
||
#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_FLUTTER_WINDOWS_ENGINE_BUILDER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.