4#include "flutter/shell/platform/windows/cursor_handler.h"
9#include "flutter/fml/macros.h"
10#include "flutter/shell/platform/common/client_wrapper/include/flutter/method_result_functions.h"
11#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_message_codec.h"
12#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_method_codec.h"
13#include "flutter/shell/platform/windows/flutter_windows_view.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/test_binary_messenger.h"
18#include "flutter/shell/platform/windows/testing/windows_test.h"
19#include "gmock/gmock.h"
20#include "gtest/gtest.h"
27using ::testing::NotNull;
28using ::testing::Return;
30static constexpr char kChannelName[] =
"flutter/mousecursor";
34 "createCustomCursor/windows";
37 "deleteCustomCursor/windows";
39void SimulateCursorMessage(TestBinaryMessenger* messenger,
40 const std::string& method_name,
41 std::unique_ptr<EncodableValue> arguments,
42 MethodResult<EncodableValue>* result_handler) {
43 MethodCall<>
call(method_name, std::move(arguments));
49 [&result_handler](
const uint8_t* reply,
size_t reply_size) {
50 StandardMethodCodec::GetInstance().DecodeAndProcessResponseEnvelope(
51 reply, reply_size, result_handler);
76 auto window = std::make_unique<MockWindowBindingHandler>();
77 EXPECT_CALL(*
window.get(), SetView).Times(1);
78 EXPECT_CALL(*
window.get(), GetWindowHandle).WillRepeatedly(Return(
nullptr));
82 view_ = std::make_unique<FlutterWindowsView>(
kImplicitViewId, engine_.get(),
86 modifier.SetImplicitView(view_.get());
90 std::unique_ptr<FlutterWindowsEngine> engine_;
91 std::unique_ptr<FlutterWindowsView> view_;
100 TestBinaryMessenger messenger;
103 EXPECT_CALL(*
window(), UpdateFlutterCursor(
"click")).Times(1);
105 bool success =
false;
109 EXPECT_EQ(
result,
nullptr);
126 TestBinaryMessenger messenger;
132 [&
error](
const std::string& error_code,
const std::string& error_message,
135 EXPECT_EQ(error_message,
136 "Cursor is not available in Windows headless mode");
153 TestBinaryMessenger messenger;
157 std::vector<uint8_t>
buffer(4 * 4 * 4, 0);
159 bool success =
false;
163 EXPECT_EQ(std::get<std::string>(*
result),
"hello");
184 TestBinaryMessenger messenger;
188 std::vector<uint8_t>
buffer(4 * 4 * 4, 0);
190 bool success =
false;
195 EXPECT_EQ(
result,
nullptr);
199 EXPECT_CALL(*
window(), SetFlutterCursor(NotNull())).Times(1);
210 &create_result_handler);
216 &set_result_handler);
224 TestBinaryMessenger messenger;
228 std::vector<uint8_t>
buffer(4 * 4 * 4, 0);
234 [&
error](
const std::string& error_code,
const std::string& error_message,
237 EXPECT_EQ(error_message,
238 "Cursor is not available in Windows headless mode");
251 &create_result_handler);
257 &set_result_handler);
265 TestBinaryMessenger messenger;
271 [&
error](
const std::string& error_code,
const std::string& error_message,
276 "The custom cursor identified by the argument key cannot be found");
280 EXPECT_CALL(*
window(), SetFlutterCursor).Times(0);
294 TestBinaryMessenger messenger;
298 std::vector<uint8_t>
buffer(4 * 4 * 4, 0);
300 bool success =
false;
305 EXPECT_EQ(
result,
nullptr);
318 &create_result_handler);
324 &delete_result_handler);
332 TestBinaryMessenger messenger;
335 bool success =
false;
339 EXPECT_EQ(
result,
nullptr);
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()
CursorHandlerTest()=default
virtual ~CursorHandlerTest()=default
MockWindowBindingHandler * window()
Mock for the |Window| 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
TEST_F(DisplayListTest, Defaults)
constexpr int64_t kImplicitViewId
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 vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
#define EXPECT_TRUE(handle)