Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
flutter_windows_engine_builder.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "flutter/shell/platform/windows/testing/flutter_windows_engine_builder.h"
6
7#include "flutter/fml/macros.h"
8#include "flutter/shell/platform/windows/windows_proc_table.h"
9
10namespace flutter {
11namespace testing {
12
14 public:
16 const FlutterProjectBundle& project,
19 std::shared_ptr<WindowsProcTable> windows_proc_table = nullptr)
21 get_key_state_(std::move(get_key_state)),
22 map_vk_to_scan_(std::move(map_vk_to_scan)) {}
23
24 protected:
25 std::unique_ptr<KeyboardHandlerBase> CreateKeyboardKeyHandler(
29 if (get_key_state_) {
30 get_key_state = get_key_state_;
31 }
32
33 if (map_vk_to_scan_) {
34 map_vk_to_scan = map_vk_to_scan_;
35 }
36
38 messenger, get_key_state, map_vk_to_scan);
39 }
40
41 private:
44
46};
47
49 WindowsTestContext& context)
50 : context_(context) {
51 properties_.assets_path = context.GetAssetsPath().c_str();
52 properties_.icu_data_path = context.GetIcuDataPath().c_str();
53 properties_.aot_library_path = context.GetAotLibraryPath().c_str();
54}
55
57
59 dart_entrypoint_ = std::move(entrypoint);
60 properties_.dart_entrypoint = dart_entrypoint_.c_str();
61}
62
64 dart_entrypoint_arguments_.emplace_back(std::move(arg));
65}
66
68 std::vector<std::string> switches) {
69 switches_ = std::move(switches);
70}
71
75 get_key_state_ = std::move(get_key_state);
76 map_vk_to_scan_ = std::move(map_vk_to_scan);
77}
78
80 std::shared_ptr<WindowsProcTable> windows_proc_table) {
81 windows_proc_table_ = std::move(windows_proc_table);
82}
83
84std::unique_ptr<FlutterWindowsEngine> FlutterWindowsEngineBuilder::Build() {
85 std::vector<const char*> dart_args;
86 dart_args.reserve(dart_entrypoint_arguments_.size());
87
88 for (const auto& arg : dart_entrypoint_arguments_) {
89 dart_args.push_back(arg.c_str());
90 }
91
92 if (!dart_args.empty()) {
93 properties_.dart_entrypoint_argv = dart_args.data();
94 properties_.dart_entrypoint_argc = dart_args.size();
95 } else {
96 properties_.dart_entrypoint_argv = nullptr;
97 properties_.dart_entrypoint_argc = 0;
98 }
99
100 FlutterProjectBundle project(properties_);
101 project.SetSwitches(switches_);
102
103 return std::make_unique<TestFlutterWindowsEngine>(
104 project, get_key_state_, map_vk_to_scan_, std::move(windows_proc_table_));
105}
106
107} // namespace testing
108} // namespace flutter
void SetSwitches(const std::vector< std::string > &switches)
FlutterDesktopMessengerRef messenger()
std::shared_ptr< WindowsProcTable > windows_proc_table()
virtual std::unique_ptr< KeyboardHandlerBase > CreateKeyboardKeyHandler(BinaryMessenger *messenger, KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state, KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan)
std::function< SHORT(UINT, bool)> MapVirtualKeyToScanCode
void SetCreateKeyboardHandlerCallbacks(KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state, KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan)
void SetSwitches(std::vector< std::string > switches)
void SetWindowsProcTable(std::shared_ptr< WindowsProcTable > windows_proc_table)
std::unique_ptr< KeyboardHandlerBase > CreateKeyboardKeyHandler(BinaryMessenger *messenger, KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state, KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan)
TestFlutterWindowsEngine(const FlutterProjectBundle &project, KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state, KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan, std::shared_ptr< WindowsProcTable > windows_proc_table=nullptr)
const std::wstring & GetIcuDataPath() const
const std::wstring & GetAssetsPath() const
const std::wstring & GetAotLibraryPath() const
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
Definition ref_ptr.h:256