5#include "flutter/shell/platform/windows/direct_manipulation.h"
7#include "flutter/fml/macros.h"
8#include "flutter/shell/platform/windows/testing/mock_window_binding_handler_delegate.h"
9#include "gtest/gtest.h"
24 HRESULT(REFIID,
void**));
27 ActivateConfiguration,
28 HRESULT(DIRECTMANIPULATION_CONFIGURATION));
31 HRESULT(DIRECTMANIPULATION_CONFIGURATION));
34 HRESULT(IDirectManipulationContent*));
38 IDirectManipulationViewportEventHandler*,
44 HRESULT(REFIID,
void**));
47 HRESULT(DIRECTMANIPULATION_STATUS*));
50 HRESULT(REFIID,
void**, UINT32*));
60 HRESULT(DIRECTMANIPULATION_CONFIGURATION));
63 HRESULT(IDirectManipulationContent*));
69 HRESULT(DIRECTMANIPULATION_MOTION_TYPES));
73 HRESULT(DIRECTMANIPULATION_INPUT_MODE));
76 HRESULT(DIRECTMANIPULATION_GESTURE_CONFIGURATION));
79 HRESULT(IUnknown*, UINT32));
82 HRESULT(DIRECTMANIPULATION_INPUT_MODE));
85 HRESULT(DIRECTMANIPULATION_VIEWPORT_OPTIONS));
88 HRESULT(
const RECT*));
91 HRESULT(
const float*,
DWORD));
95 HRESULT(
const float*,
DWORD));
99 HRESULT(
const float,
const float,
const float,
const float,
BOOL));
113 HRESULT(REFIID,
void**));
117 HRESULT(
float*,
DWORD));
120 HRESULT(
float*,
DWORD));
123 HRESULT(REFIID,
void**, UINT32*));
126 HRESULT(REFIID,
void**));
129 HRESULT(
const RECT*));
132 HRESULT(IUnknown*, UINT32));
134 SyncContentTransform,
135 HRESULT(
const float*,
DWORD));
141TEST(DirectManipulationTest, TestGesture) {
145 const float scale = 1.5;
146 const float pan_x = 32.0;
147 const float pan_y = 16.0;
148 const int DISPLAY_WIDTH = 800;
149 const int DISPLAY_HEIGHT = 600;
150 auto owner = std::make_unique<DirectManipulationOwner>(
nullptr);
151 owner->SetBindingHandlerDelegate(&delegate);
153 fml::MakeRefCounted<DirectManipulationEventHandler>(owner.get());
154 int32_t device_id = (int32_t)
reinterpret_cast<int64_t
>(handler.get());
155 EXPECT_CALL(viewport, GetPrimaryContent(_, _))
160 .RetiresOnSaturation();
161 EXPECT_CALL(
content, GetContentTransform(_, 6))
168 .RetiresOnSaturation();
169 EXPECT_CALL(delegate, OnPointerPanZoomStart(device_id));
170 handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
171 DIRECTMANIPULATION_RUNNING,
172 DIRECTMANIPULATION_READY);
173 EXPECT_CALL(
content, GetContentTransform(_, 6))
181 EXPECT_CALL(delegate,
182 OnPointerPanZoomUpdate(device_id, pan_x, pan_y,
scale, 0));
183 handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
184 (IDirectManipulationContent*)&
content);
185 EXPECT_CALL(delegate, OnPointerPanZoomEnd(device_id));
186 EXPECT_CALL(viewport, GetViewportRect(_))
190 rect->right = DISPLAY_WIDTH;
191 rect->bottom = DISPLAY_HEIGHT;
194 EXPECT_CALL(viewport, ZoomToRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT,
false))
195 .WillOnce(::testing::Return(S_OK));
196 handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
197 DIRECTMANIPULATION_INERTIA,
198 DIRECTMANIPULATION_RUNNING);
199 handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
200 DIRECTMANIPULATION_READY,
201 DIRECTMANIPULATION_INERTIA);
205TEST(DirectManipulationTest, TestRounding) {
209 const float scale = 1.5;
210 const int DISPLAY_WIDTH = 800;
211 const int DISPLAY_HEIGHT = 600;
212 auto owner = std::make_unique<DirectManipulationOwner>(
nullptr);
213 owner->SetBindingHandlerDelegate(&delegate);
215 fml::MakeRefCounted<DirectManipulationEventHandler>(owner.get());
216 int32_t device_id = (int32_t)
reinterpret_cast<int64_t
>(handler.get());
217 EXPECT_CALL(viewport, GetPrimaryContent(_, _))
222 .RetiresOnSaturation();
223 EXPECT_CALL(
content, GetContentTransform(_, 6))
230 .RetiresOnSaturation();
231 EXPECT_CALL(delegate, OnPointerPanZoomStart(device_id));
232 handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
233 DIRECTMANIPULATION_RUNNING,
234 DIRECTMANIPULATION_READY);
235 EXPECT_CALL(
content, GetContentTransform(_, 6))
242 .RetiresOnSaturation();
243 EXPECT_CALL(delegate,
244 OnPointerPanZoomUpdate(device_id, 4.0, 0, 1.5000001f, 0))
246 EXPECT_CALL(delegate, OnPointerPanZoomUpdate(device_id, 4.0, 0, 1.5f, 0))
248 .RetiresOnSaturation();
249 EXPECT_CALL(
content, GetContentTransform(_, 6))
256 .RetiresOnSaturation();
257 EXPECT_CALL(delegate,
258 OnPointerPanZoomUpdate(device_id, 2.0, 0, 1.50000065f, 0))
260 EXPECT_CALL(delegate,
261 OnPointerPanZoomUpdate(device_id, 2.0, 0, 1.50000047f, 0))
263 .RetiresOnSaturation();
264 EXPECT_CALL(delegate, OnPointerPanZoomEnd(device_id));
265 EXPECT_CALL(viewport, GetViewportRect(_))
269 rect->right = DISPLAY_WIDTH;
270 rect->bottom = DISPLAY_HEIGHT;
273 EXPECT_CALL(viewport, ZoomToRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT,
false))
274 .WillOnce(::testing::Return(S_OK));
275 handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
276 (IDirectManipulationContent*)&
content);
277 handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
278 (IDirectManipulationContent*)&
content);
279 handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
280 DIRECTMANIPULATION_INERTIA,
281 DIRECTMANIPULATION_RUNNING);
282 handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
283 DIRECTMANIPULATION_READY,
284 DIRECTMANIPULATION_INERTIA);
287TEST(DirectManipulationTest, TestInertiaCancelSentForUserCancel) {
291 const int DISPLAY_WIDTH = 800;
292 const int DISPLAY_HEIGHT = 600;
293 auto owner = std::make_unique<DirectManipulationOwner>(
nullptr);
294 owner->SetBindingHandlerDelegate(&delegate);
296 fml::MakeRefCounted<DirectManipulationEventHandler>(owner.get());
297 int32_t device_id = (int32_t)
reinterpret_cast<int64_t
>(handler.get());
299 EXPECT_CALL(viewport, GetViewportRect(_))
303 rect->right = DISPLAY_WIDTH;
304 rect->bottom = DISPLAY_HEIGHT;
307 EXPECT_CALL(viewport, ZoomToRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT,
false))
308 .WillOnce(::testing::Return(S_OK));
309 EXPECT_CALL(delegate, OnPointerPanZoomEnd(device_id));
310 handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
311 DIRECTMANIPULATION_INERTIA,
312 DIRECTMANIPULATION_RUNNING);
314 EXPECT_CALL(
content, GetContentTransform(_, 6))
321 handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
322 (IDirectManipulationContent*)&
content);
323 EXPECT_CALL(
content, GetContentTransform(_, 6))
330 handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
331 (IDirectManipulationContent*)&
content);
334 EXPECT_CALL(delegate, OnScrollInertiaCancel(device_id));
335 handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
336 DIRECTMANIPULATION_READY,
337 DIRECTMANIPULATION_INERTIA);
340TEST(DirectManipulationTest, TestInertiaCamcelNotSentAtInertiaEnd) {
344 const int DISPLAY_WIDTH = 800;
345 const int DISPLAY_HEIGHT = 600;
346 auto owner = std::make_unique<DirectManipulationOwner>(
nullptr);
347 owner->SetBindingHandlerDelegate(&delegate);
349 fml::MakeRefCounted<DirectManipulationEventHandler>(owner.get());
350 int32_t device_id = (int32_t)
reinterpret_cast<int64_t
>(handler.get());
352 EXPECT_CALL(viewport, GetViewportRect(_))
356 rect->right = DISPLAY_WIDTH;
357 rect->bottom = DISPLAY_HEIGHT;
360 EXPECT_CALL(viewport, ZoomToRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT,
false))
361 .WillOnce(::testing::Return(S_OK));
362 EXPECT_CALL(delegate, OnPointerPanZoomEnd(device_id));
363 handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
364 DIRECTMANIPULATION_INERTIA,
365 DIRECTMANIPULATION_RUNNING);
367 EXPECT_CALL(
content, GetContentTransform(_, 6))
374 handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
375 (IDirectManipulationContent*)&
content);
376 EXPECT_CALL(
content, GetContentTransform(_, 6))
383 handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
384 (IDirectManipulationContent*)&
content);
386 EXPECT_CALL(delegate, OnScrollInertiaCancel(device_id)).Times(0);
387 handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
388 DIRECTMANIPULATION_READY,
389 DIRECTMANIPULATION_INERTIA);
394TEST(DirectManipulationTest, TestGestureWithInitialData) {
398 const float scale = 1.5;
399 const float pan_x = 32.0;
400 const float pan_y = 16.0;
401 const int DISPLAY_WIDTH = 800;
402 const int DISPLAY_HEIGHT = 600;
403 auto owner = std::make_unique<DirectManipulationOwner>(
nullptr);
404 owner->SetBindingHandlerDelegate(&delegate);
406 fml::MakeRefCounted<DirectManipulationEventHandler>(owner.get());
407 int32_t device_id = (int32_t)
reinterpret_cast<int64_t
>(handler.get());
408 EXPECT_CALL(viewport, GetPrimaryContent(_, _))
413 .RetiresOnSaturation();
414 EXPECT_CALL(
content, GetContentTransform(_, 6))
421 .RetiresOnSaturation();
422 EXPECT_CALL(delegate, OnPointerPanZoomStart(device_id));
423 handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
424 DIRECTMANIPULATION_RUNNING,
425 DIRECTMANIPULATION_READY);
426 EXPECT_CALL(
content, GetContentTransform(_, 6))
434 EXPECT_CALL(delegate,
435 OnPointerPanZoomUpdate(device_id, pan_x, pan_y,
scale, 0));
436 handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
437 (IDirectManipulationContent*)&
content);
438 EXPECT_CALL(delegate, OnPointerPanZoomEnd(device_id));
439 EXPECT_CALL(viewport, GetViewportRect(_))
443 rect->right = DISPLAY_WIDTH;
444 rect->bottom = DISPLAY_HEIGHT;
447 EXPECT_CALL(viewport, ZoomToRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT,
false))
448 .WillOnce(::testing::Return(S_OK));
449 handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
450 DIRECTMANIPULATION_INERTIA,
451 DIRECTMANIPULATION_RUNNING);
452 handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
453 DIRECTMANIPULATION_READY,
454 DIRECTMANIPULATION_INERTIA);
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, QueryInterface, HRESULT(REFIID, void **))
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, GetContentTransform, HRESULT(float *, DWORD))
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, GetOutputTransform, HRESULT(float *, DWORD))
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, Release, ULONG())
MOCK_METHOD3_WITH_CALLTYPE(STDMETHODCALLTYPE, GetTag, HRESULT(REFIID, void **, UINT32 *))
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, SyncContentTransform, HRESULT(const float *, DWORD))
MockIDirectManipulationContent()
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, GetContentRect, HRESULT(RECT *))
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, AddRef, ULONG())
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, SetTag, HRESULT(IUnknown *, UINT32))
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, SetContentRect, HRESULT(const RECT *))
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, GetViewport, HRESULT(REFIID, void **))
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, QueryInterface, HRESULT(REFIID, void **))
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, Abandon, HRESULT())
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, AddRef, ULONG())
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, SetViewportRect, HRESULT(const RECT *))
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, SyncDisplayTransform, HRESULT(const float *, DWORD))
MOCK_METHOD5_WITH_CALLTYPE(STDMETHODCALLTYPE, ZoomToRect, HRESULT(const float, const float, const float, const float, BOOL))
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, Enable, HRESULT())
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, Disable, HRESULT())
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, RemoveEventHandler, HRESULT(DWORD))
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, AddConfiguration, HRESULT(DIRECTMANIPULATION_CONFIGURATION))
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, SetViewportOptions, HRESULT(DIRECTMANIPULATION_VIEWPORT_OPTIONS))
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, RemoveContent, HRESULT(IDirectManipulationContent *))
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, SetTag, HRESULT(IUnknown *, UINT32))
MOCK_METHOD3_WITH_CALLTYPE(STDMETHODCALLTYPE, GetTag, HRESULT(REFIID, void **, UINT32 *))
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, SetInputMode, HRESULT(DIRECTMANIPULATION_INPUT_MODE))
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, Stop, HRESULT())
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, SetViewportTransform, HRESULT(const float *, DWORD))
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, ReleaseAllContacts, HRESULT())
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, SetUpdateMode, HRESULT(DIRECTMANIPULATION_INPUT_MODE))
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, Release, ULONG())
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, ActivateConfiguration, HRESULT(DIRECTMANIPULATION_CONFIGURATION))
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, RemoveConfiguration, HRESULT(DIRECTMANIPULATION_CONFIGURATION))
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, AddContent, HRESULT(IDirectManipulationContent *))
MOCK_METHOD3_WITH_CALLTYPE(STDMETHODCALLTYPE, AddEventHandler, HRESULT(HWND, IDirectManipulationViewportEventHandler *, DWORD *))
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, SetChaining, HRESULT(DIRECTMANIPULATION_MOTION_TYPES))
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, GetStatus, HRESULT(DIRECTMANIPULATION_STATUS *))
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, GetPrimaryContent, HRESULT(REFIID, void **))
MockIDirectManipulationViewport()
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, ReleaseContact, HRESULT(UINT32))
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, GetViewportRect, HRESULT(RECT *))
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, SetContact, HRESULT(UINT32))
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, SetManualGesture, HRESULT(DIRECTMANIPULATION_GESTURE_CONFIGURATION))
union flutter::testing::@2836::KeyboardChange::@76 content
sk_sp< SkBlender > blender SkRect rect
ObjectPtr Invoke(const Library &lib, const char *name)
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 Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)