8#include "flutter/shell/platform/windows/client_wrapper/include/flutter/flutter_engine.h"
9#include "flutter/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.h"
10#include "gtest/gtest.h"
17class TestFlutterWindowsApi :
public testing::StubFlutterWindowsApi {
22 create_called_ =
true;
26 dart_entrypoint_arguments_.clear();
28 dart_entrypoint_arguments_.push_back(
35 bool EngineRun(
const char* entry_point)
override {
41 bool EngineDestroy()
override {
42 destroy_called_ =
true;
47 uint64_t EngineProcessMessages()
override {
return 99; }
57 void EngineReloadSystemFonts()
override { reload_fonts_called_ =
true; }
66 last_external_message_ =
message;
70 bool create_called() {
return create_called_; }
72 bool run_called() {
return run_called_; }
74 bool destroy_called() {
return destroy_called_; }
76 bool reload_fonts_called() {
return reload_fonts_called_; }
78 const std::vector<std::string>& dart_entrypoint_arguments() {
79 return dart_entrypoint_arguments_;
82 bool has_next_frame_callback() {
return next_frame_callback_ !=
nullptr; }
83 void run_next_frame_callback() {
84 next_frame_callback_(next_frame_user_data_);
85 next_frame_callback_ =
nullptr;
88 UINT last_external_message() {
return last_external_message_; }
91 bool create_called_ =
false;
92 bool run_called_ =
false;
93 bool destroy_called_ =
false;
94 bool reload_fonts_called_ =
false;
95 std::vector<std::string> dart_entrypoint_arguments_;
97 void* next_frame_user_data_ =
nullptr;
98 UINT last_external_message_ = 0;
104 testing::ScopedStubFlutterWindowsApi scoped_api_stub(
105 std::make_unique<TestFlutterWindowsApi>());
106 auto test_api =
static_cast<TestFlutterWindowsApi*
>(scoped_api_stub.stub());
110 EXPECT_EQ(test_api->create_called(),
true);
111 EXPECT_EQ(test_api->run_called(),
true);
112 EXPECT_EQ(test_api->destroy_called(),
false);
115 EXPECT_EQ(test_api->destroy_called(),
true);
120 std::make_unique<TestFlutterWindowsApi>());
121 auto test_api =
static_cast<TestFlutterWindowsApi*
>(scoped_api_stub.
stub());
127 EXPECT_EQ(test_api->create_called(),
true);
128 EXPECT_EQ(test_api->run_called(),
true);
129 EXPECT_EQ(test_api->destroy_called(),
false);
132 EXPECT_EQ(test_api->destroy_called(),
true);
136 testing::ScopedStubFlutterWindowsApi scoped_api_stub(
137 std::make_unique<TestFlutterWindowsApi>());
138 auto test_api =
static_cast<TestFlutterWindowsApi*
>(scoped_api_stub.stub());
142 EXPECT_EQ(test_api->create_called(),
true);
143 EXPECT_EQ(test_api->run_called(),
true);
144 EXPECT_EQ(test_api->destroy_called(),
false);
146 EXPECT_EQ(test_api->destroy_called(),
true);
151 std::make_unique<TestFlutterWindowsApi>());
152 auto test_api =
static_cast<TestFlutterWindowsApi*
>(scoped_api_stub.
stub());
158 EXPECT_EQ(next_event_time.count(), 99);
163 std::make_unique<TestFlutterWindowsApi>());
164 auto test_api =
static_cast<TestFlutterWindowsApi*
>(scoped_api_stub.
stub());
176 std::make_unique<TestFlutterWindowsApi>());
177 auto test_api =
static_cast<TestFlutterWindowsApi*
>(scoped_api_stub.
stub());
185 std::make_unique<TestFlutterWindowsApi>());
186 auto test_api =
static_cast<TestFlutterWindowsApi*
>(scoped_api_stub.
stub());
189 std::vector<std::string> arguments = {
"one",
"two"};
193 const std::vector<std::string>& arguments_ref =
194 test_api->dart_entrypoint_arguments();
195 ASSERT_EQ(2, arguments_ref.size());
203 std::make_unique<TestFlutterWindowsApi>());
204 auto test_api =
static_cast<TestFlutterWindowsApi*
>(scoped_api_stub.
stub());
208 bool success =
false;
213 test_api->run_next_frame_callback();
220 std::make_unique<TestFlutterWindowsApi>());
221 auto test_api =
static_cast<TestFlutterWindowsApi*
>(scoped_api_stub.
stub());
227 EXPECT_EQ(test_api->last_external_message(), 1234);
void set_dart_entrypoint(const std::string &entrypoint)
void set_dart_entrypoint_arguments(std::vector< std::string > arguments)
std::chrono::nanoseconds ProcessMessages()
BinaryMessenger * messenger()
std::optional< LRESULT > ProcessExternalWindowMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
void SetNextFrameCallback(std::function< void()> callback)
StubFlutterWindowsApi * stub()
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
TEST(FrameTimingsRecorderTest, RecordVsync)
const char ** dart_entrypoint_argv
#define EXPECT_TRUE(handle)