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();
88 view_ = engine_->CreateView(std::move(
window));
92 std::unique_ptr<FlutterWindowsEngine> engine_;
93 std::unique_ptr<FlutterWindowsView> view_;
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);
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[]
G_BEGIN_DECLS GBytes * message
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