7 #import <Metal/Metal.h>
9 #import "flutter/testing/testing.h"
19 - (void)viewDidReshape:(nonnull NSView*)view {
22 - (BOOL)viewShouldAcceptFirstResponder:(NSView*)view {
29 id<MTLDevice> device = MTLCreateSystemDefaultDevice();
30 id<MTLCommandQueue> queue = [device newCommandQueue];
35 viewIdentifier:kImplicitViewId
37 EXPECT_EQ([view layer:view.layer shouldInheritContentsScale:3.0 fromWindow:view.window], YES);
42 @property(readwrite, nonatomic) NSView* (^onHitTest)(NSPoint point);
50 - (NSView*)hitTest:(NSPoint)point {
51 return self.onHitTest(point);
61 @property(readwrite, nonatomic) BOOL setCalled;
73 id<MTLDevice> device = MTLCreateSystemDefaultDevice();
74 id<MTLCommandQueue> queue = [device newCommandQueue];
79 viewIdentifier:kImplicitViewId
81 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
82 styleMask:NSBorderlessWindowMask
83 backing:NSBackingStoreBuffered
88 window.contentView = view;
89 __weak NSView* weakView = view;
90 __block BOOL hitTestCalled = NO;
91 __block NSPoint hitTestCoordinate = NSZeroPoint;
92 view.
onHitTest = ^NSView*(NSPoint point) {
94 hitTestCoordinate = point;
97 NSEvent* mouseEvent = [NSEvent mouseEventWithType:NSEventTypeMouseMoved
98 location:NSMakePoint(100, 100)
107 [view cursorUpdate:mouseEvent];
109 EXPECT_TRUE(hitTestCalled);
111 EXPECT_TRUE(CGPointEqualToPoint(hitTestCoordinate, CGPointMake(100, 100)));
116 id<MTLDevice> device = MTLCreateSystemDefaultDevice();
117 id<MTLCommandQueue> queue = [device newCommandQueue];
122 viewIdentifier:kImplicitViewId
124 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
125 styleMask:NSBorderlessWindowMask
126 backing:NSBackingStoreBuffered
131 NSView* platformView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
133 window.contentView = view;
134 __block BOOL hitTestCalled = NO;
135 __block NSPoint hitTestCoordinate = NSZeroPoint;
136 view.
onHitTest = ^NSView*(NSPoint point) {
138 hitTestCoordinate = point;
141 NSEvent* mouseEvent = [NSEvent mouseEventWithType:NSEventTypeMouseMoved
142 location:NSMakePoint(100, 100)
151 [view cursorUpdate:mouseEvent];
153 EXPECT_TRUE(hitTestCalled);
155 EXPECT_TRUE(CGPointEqualToPoint(hitTestCoordinate, CGPointMake(100, 100)));
TEST(FlutterView, ShouldInheritContentsScaleReturnsYes)
constexpr int64_t kImplicitViewId
void didUpdateMouseCursor:(nonnull NSCursor *cursor)
NSView *(^ onHitTest)(NSPoint point)