5#include "flutter/shell/platform/windows/window_proc_delegate_manager.h"
6#include "gtest/gtest.h"
14#define FLUTTER_NOINLINE __declspec(noinline)
16#define FLUTTER_NOINLINE __attribute__((noinline))
25bool TestWindowProcCallback(HWND hwnd,
31 TestWindowProcDelegate& delegate =
32 *
static_cast<TestWindowProcDelegate*
>(
user_data);
33 auto delegate_result = delegate(hwnd,
message, wparam, lparam);
34 if (delegate_result) {
35 *
result = *delegate_result;
37 return delegate_result.has_value();
42bool TestWindowProcCallback2(HWND hwnd,
54TEST(WindowProcDelegateManagerTest, CallsCorrectly) {
59 TestWindowProcDelegate delegate = [&called, &dummy_hwnd](
63 EXPECT_EQ(hwnd, dummy_hwnd);
67 return std::optional<LRESULT>();
69 manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback, &delegate);
70 auto result =
manager.OnTopLevelWindowProc(dummy_hwnd, 2, 3, 4);
76TEST(WindowProcDelegateManagerTest, ReplacementRegister) {
79 bool called_a =
false;
80 TestWindowProcDelegate delegate_a =
83 return std::optional<LRESULT>();
85 bool called_b =
false;
86 TestWindowProcDelegate delegate_b =
89 return std::optional<LRESULT>();
91 manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback,
94 manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback,
96 manager.OnTopLevelWindowProc(
nullptr, 0, 0, 0);
98 EXPECT_FALSE(called_a);
102TEST(WindowProcDelegateManagerTest, RegisterMultiple) {
105 bool called_a =
false;
106 TestWindowProcDelegate delegate_a =
109 return std::optional<LRESULT>();
111 bool called_b =
false;
112 TestWindowProcDelegate delegate_b =
115 return std::optional<LRESULT>();
117 manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback,
120 manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback2,
122 manager.OnTopLevelWindowProc(
nullptr, 0, 0, 0);
128TEST(WindowProcDelegateManagerTest, Ordered) {
130 LPARAM lparam) {
return 1; };
132 LPARAM lparam) {
return 2; };
137 manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback,
139 manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback2,
142 std::optional<LRESULT>
result =
143 manager.OnTopLevelWindowProc(
nullptr, 0, 0, 0);
151 manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback2,
153 manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback,
156 std::optional<LRESULT>
result =
157 manager.OnTopLevelWindowProc(
nullptr, 0, 0, 0);
163TEST(WindowProcDelegateManagerTest, ConflictingDelegates) {
166 bool called_a =
false;
167 TestWindowProcDelegate delegate_a =
170 return std::optional<LRESULT>(1);
172 bool called_b =
false;
173 TestWindowProcDelegate delegate_b =
176 return std::optional<LRESULT>(1);
178 manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback,
180 manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback2,
182 auto result =
manager.OnTopLevelWindowProc(
nullptr, 0, 0, 0);
189 EXPECT_NE(called_a, called_b);
192TEST(WindowProcDelegateManagerTest, Unregister) {
196 TestWindowProcDelegate delegate = [&called](HWND hwnd,
UINT message,
199 return std::optional<LRESULT>();
201 manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback, &delegate);
202 manager.UnregisterTopLevelWindowProcDelegate(TestWindowProcCallback);
203 auto result =
manager.OnTopLevelWindowProc(
nullptr, 0, 0, 0);
206 EXPECT_FALSE(called);
Dart_NativeFunction function
TEST(DisplayListComplexity, EmptyDisplayList)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font manager
#define EXPECT_TRUE(handle)