9 #include "flutter/fml/macros.h"
14 #include "flutter/shell/platform/windows/testing/engine_modifier.h"
15 #include "flutter/shell/platform/windows/testing/flutter_windows_engine_builder.h"
16 #include "flutter/shell/platform/windows/testing/mock_window_binding_handler.h"
17 #include "flutter/shell/platform/windows/testing/mock_windows_proc_table.h"
18 #include "flutter/shell/platform/windows/testing/test_binary_messenger.h"
19 #include "flutter/shell/platform/windows/testing/windows_test.h"
20 #include "gmock/gmock.h"
21 #include "gtest/gtest.h"
28 using ::testing::IsNull;
29 using ::testing::NotNull;
30 using ::testing::Return;
32 static constexpr
char kChannelName[] =
"flutter/mousecursor";
36 "createCustomCursor/windows";
39 "deleteCustomCursor/windows";
41 void SimulateCursorMessage(TestBinaryMessenger* messenger,
42 const std::string& method_name,
43 std::unique_ptr<EncodableValue> arguments,
44 MethodResult<EncodableValue>* result_handler) {
45 MethodCall<> call(method_name, std::move(arguments));
49 EXPECT_TRUE(messenger->SimulateEngineMessage(
51 [&result_handler](
const uint8_t* reply,
size_t reply_size) {
52 StandardMethodCodec::GetInstance().DecodeAndProcessResponseEnvelope(
53 reply, reply_size, result_handler);
67 MockWindowBindingHandler*
window() {
return window_; }
68 MockWindowsProcTable*
proc_table() {
return windows_proc_table_.get(); }
71 FlutterWindowsEngineBuilder builder{GetContext()};
73 engine_ = builder.Build();
77 windows_proc_table_ = std::make_shared<MockWindowsProcTable>();
79 FlutterWindowsEngineBuilder builder{GetContext()};
80 builder.SetWindowsProcTable(windows_proc_table_);
82 auto window = std::make_unique<MockWindowBindingHandler>();
83 EXPECT_CALL(*
window.get(), SetView).Times(1);
84 EXPECT_CALL(*
window.get(), GetWindowHandle).WillRepeatedly(Return(
nullptr));
87 engine_ = builder.Build();
88 view_ = engine_->CreateView(std::move(
window));
92 std::unique_ptr<FlutterWindowsEngine> engine_;
93 std::unique_ptr<FlutterWindowsView> view_;
94 MockWindowBindingHandler* window_;
95 std::shared_ptr<MockWindowsProcTable> windows_proc_table_;
103 TestBinaryMessenger messenger;
106 EXPECT_CALL(*proc_table(), LoadCursor(IsNull(), IDC_HAND)).Times(1);
107 EXPECT_CALL(*proc_table(), SetCursor).Times(1);
109 bool success =
false;
113 EXPECT_EQ(result,
nullptr);
124 EXPECT_TRUE(success);
130 TestBinaryMessenger messenger;
134 std::vector<uint8_t> buffer(4 * 4 * 4, 0);
136 bool success =
false;
140 EXPECT_EQ(std::get<std::string>(*result),
"hello");
155 EXPECT_TRUE(success);
161 TestBinaryMessenger messenger;
165 std::vector<uint8_t> buffer(4 * 4 * 4, 0);
167 bool success =
false;
172 EXPECT_EQ(result,
nullptr);
176 EXPECT_CALL(*proc_table(), LoadCursor).Times(0);
177 EXPECT_CALL(*proc_table(), SetCursor(NotNull())).Times(1);
188 &create_result_handler);
194 &set_result_handler);
196 EXPECT_TRUE(success);
202 TestBinaryMessenger messenger;
208 [&error](
const std::string& error_code,
const std::string& error_message,
213 "The custom cursor identified by the argument key cannot be found");
217 EXPECT_CALL(*proc_table(), LoadCursor).Times(0);
218 EXPECT_CALL(*proc_table(), SetCursor).Times(0);
232 TestBinaryMessenger messenger;
236 std::vector<uint8_t> buffer(4 * 4 * 4, 0);
238 bool success =
false;
243 EXPECT_EQ(result,
nullptr);
256 &create_result_handler);
262 &delete_result_handler);
264 EXPECT_TRUE(success);
270 TestBinaryMessenger messenger;
273 bool success =
false;
277 EXPECT_EQ(result,
nullptr);
287 EXPECT_TRUE(success);
std::unique_ptr< std::vector< uint8_t > > EncodeMethodCall(const MethodCall< T > &method_call) const
static const StandardMethodCodec & GetInstance(const StandardCodecSerializer *serializer=nullptr)
CursorHandlerTest()=default
MockWindowBindingHandler * window()
FlutterWindowsView * view()
FlutterWindowsEngine * engine()
virtual ~CursorHandlerTest()=default
MockWindowsProcTable * proc_table()
static constexpr char kDeleteCustomCursorMethod[]
static constexpr char kActivateSystemCursorMethod[]
static constexpr char kChannelName[]
static constexpr char kCreateCustomCursorMethod[]
static constexpr char kSetCustomCursorMethod[]
TEST_F(CompositorOpenGLTest, CreateBackingStore)
std::map< EncodableValue, EncodableValue > EncodableMap