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];
36 EXPECT_EQ([view layer:view.layer shouldInheritContentsScale:3.0 fromWindow:view.window], YES);
41 @property(readwrite, nonatomic) NSView* (^onHitTest)(NSPoint point);
49 - (NSView*)hitTest:(NSPoint)point {
50 return self.onHitTest(point);
60 @property(readwrite, nonatomic) BOOL setCalled;
72 id<MTLDevice> device = MTLCreateSystemDefaultDevice();
73 id<MTLCommandQueue> queue = [device newCommandQueue];
78 viewIdentifier:kImplicitViewId];
79 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
80 styleMask:NSBorderlessWindowMask
81 backing:NSBackingStoreBuffered
86 window.contentView = view;
87 __weak NSView* weakView = view;
88 __block BOOL hitTestCalled = NO;
89 __block NSPoint hitTestCoordinate = NSZeroPoint;
90 view.
onHitTest = ^NSView*(NSPoint point) {
92 hitTestCoordinate = point;
95 NSEvent* mouseEvent = [NSEvent mouseEventWithType:NSEventTypeMouseMoved
96 location:NSMakePoint(100, 100)
105 [view cursorUpdate:mouseEvent];
107 EXPECT_TRUE(hitTestCalled);
109 EXPECT_TRUE(CGPointEqualToPoint(hitTestCoordinate, CGPointMake(100, 100)));
114 id<MTLDevice> device = MTLCreateSystemDefaultDevice();
115 id<MTLCommandQueue> queue = [device newCommandQueue];
120 viewIdentifier:kImplicitViewId];
121 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
122 styleMask:NSBorderlessWindowMask
123 backing:NSBackingStoreBuffered
128 NSView* platformView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
130 window.contentView = view;
131 __block BOOL hitTestCalled = NO;
132 __block NSPoint hitTestCoordinate = NSZeroPoint;
133 view.
onHitTest = ^NSView*(NSPoint point) {
135 hitTestCoordinate = point;
138 NSEvent* mouseEvent = [NSEvent mouseEventWithType:NSEventTypeMouseMoved
139 location:NSMakePoint(100, 100)
148 [view cursorUpdate:mouseEvent];
150 EXPECT_TRUE(hitTestCalled);
152 EXPECT_TRUE(CGPointEqualToPoint(hitTestCoordinate, CGPointMake(100, 100)));
TEST(FlutterView, ShouldInheritContentsScaleReturnsYes)
constexpr int64_t kImplicitViewId
void didUpdateMouseCursor:(nonnull NSCursor *cursor)
NSView *(^ onHitTest)(NSPoint point)