20#include "gmock/gmock.h"
21#include "gtest/gtest.h"
28using ::testing::IsNull;
29using ::testing::NotNull;
30using ::testing::Return;
32static constexpr char kChannelName[] =
"flutter/mousecursor";
36 "createCustomCursor/windows";
39 "deleteCustomCursor/windows";
41void 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);
73 engine_ = builder.Build();
77 windows_proc_table_ = std::make_shared<MockWindowsProcTable>();
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();
89 engine_->CreateView(std::move(
window),
94 std::unique_ptr<FlutterWindowsEngine> engine_;
95 std::unique_ptr<FlutterWindowsView> view_;
97 std::shared_ptr<MockWindowsProcTable> windows_proc_table_;
105 TestBinaryMessenger messenger;
108 EXPECT_CALL(*proc_table(), LoadCursor(IsNull(), IDC_HAND)).Times(1);
109 EXPECT_CALL(*proc_table(), SetCursor).Times(1);
111 bool success =
false;
115 EXPECT_EQ(result,
nullptr);
126 EXPECT_TRUE(success);
132 TestBinaryMessenger messenger;
136 std::vector<uint8_t>
buffer(4 * 4 * 4, 0);
138 bool success =
false;
142 EXPECT_EQ(std::get<std::string>(*result),
"hello");
157 EXPECT_TRUE(success);
163 TestBinaryMessenger messenger;
167 std::vector<uint8_t>
buffer(4 * 4 * 4, 0);
169 bool success =
false;
174 EXPECT_EQ(result,
nullptr);
178 EXPECT_CALL(*proc_table(), LoadCursor).Times(0);
179 EXPECT_CALL(*proc_table(), SetCursor(NotNull())).Times(1);
190 &create_result_handler);
196 &set_result_handler);
198 EXPECT_TRUE(success);
204 TestBinaryMessenger messenger;
210 [&
error](
const std::string& error_code,
const std::string& error_message,
215 "The custom cursor identified by the argument key cannot be found");
219 EXPECT_CALL(*proc_table(), LoadCursor).Times(0);
220 EXPECT_CALL(*proc_table(), SetCursor).Times(0);
234 TestBinaryMessenger messenger;
238 std::vector<uint8_t>
buffer(4 * 4 * 4, 0);
240 bool success =
false;
245 EXPECT_EQ(result,
nullptr);
258 &create_result_handler);
264 &delete_result_handler);
266 EXPECT_TRUE(success);
272 TestBinaryMessenger messenger;
275 bool success =
false;
279 EXPECT_EQ(result,
nullptr);
289 EXPECT_TRUE(success);
static NSString *const kActivateSystemCursorMethod
std::unique_ptr< std::vector< uint8_t > > EncodeMethodCall(const MethodCall< T > &method_call) const
static const StandardMethodCodec & GetInstance(const StandardCodecSerializer *serializer=nullptr)
FlutterWindowsEngine * engine()
FlutterWindowsView * view()
MockWindowsProcTable * proc_table()
CursorHandlerTest()=default
virtual ~CursorHandlerTest()=default
MockWindowBindingHandler * window()
Mock for the |Window| base class.
Mock for the |WindowsProcTable| base class.
WindowsTestContext & GetContext()
static constexpr char kDeleteCustomCursorMethod[]
static constexpr char kCreateCustomCursorMethod[]
static constexpr char kSetCustomCursorMethod[]
const uint8_t uint32_t uint32_t GError ** error
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
TEST_F(DisplayListTest, Defaults)
std::map< EncodableValue, EncodableValue > EncodableMap
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer