Flutter Engine
The Flutter Engine
FlutterViewTest.mm
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#import <XCTest/XCTest.h>
6
7#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h"
8
10
12@property(nonatomic) BOOL callbackCalled;
13@property(nonatomic, assign) BOOL isUsingImpeller;
14@end
15
16@implementation FakeDelegate {
17 std::shared_ptr<flutter::FlutterPlatformViewsController> _platformViewsController;
18}
19
20- (instancetype)init {
21 _callbackCalled = NO;
22 _platformViewsController = std::shared_ptr<flutter::FlutterPlatformViewsController>(nullptr);
23 return self;
24}
25
26- (flutter::Rasterizer::Screenshot)takeScreenshot:(flutter::Rasterizer::ScreenshotType)type
27 asBase64Encoded:(BOOL)base64Encode {
28 return {};
29}
30
31- (std::shared_ptr<flutter::FlutterPlatformViewsController>&)platformViewsController {
33}
34
35- (void)flutterViewAccessibilityDidCall {
36 _callbackCalled = YES;
37}
38
39@end
40
41@interface FlutterViewTest : XCTestCase
42@end
43
44@implementation FlutterViewTest
45
47 FakeDelegate* delegate = [[FakeDelegate alloc] init];
48 FlutterView* view = [[FlutterView alloc] initWithDelegate:delegate opaque:NO enableWideGamut:NO];
49 delegate.callbackCalled = NO;
50 XCTAssertFalse(view.isAccessibilityElement);
51 XCTAssertTrue(delegate.callbackCalled);
52}
53
55 FakeDelegate* delegate = [[FakeDelegate alloc] init];
56 FlutterView* view = [[FlutterView alloc] initWithDelegate:delegate opaque:NO enableWideGamut:NO];
57 XCTAssertNotNil(view.backgroundColor);
58}
59
61 FakeDelegate* delegate = [[FakeDelegate alloc] init];
62 delegate.isUsingImpeller = NO;
63 FlutterView* view = [[FlutterView alloc] initWithDelegate:delegate opaque:NO enableWideGamut:YES];
64 [view layoutSubviews];
65 XCTAssertTrue([view.layer isKindOfClass:NSClassFromString(@"CAMetalLayer")]);
66 CAMetalLayer* layer = (CAMetalLayer*)view.layer;
67 XCTAssertEqual(layer.pixelFormat, MTLPixelFormatBGRA8Unorm);
68}
69
71 FakeDelegate* delegate = [[FakeDelegate alloc] init];
72 FlutterView* view = [[FlutterView alloc] initWithDelegate:delegate opaque:NO enableWideGamut:NO];
73 view.layer.contentsScale = CGFloat(-99.0);
74 view.layer.rasterizationScale = CGFloat(-99.0);
75 UIScreen* screen = [view screen];
76 XCTAssertNotEqual(view.layer.contentsScale, screen.scale);
77 XCTAssertNotEqual(view.layer.rasterizationScale, screen.scale);
78 [view layoutSubviews];
79 XCTAssertEqual(view.layer.contentsScale, screen.scale);
80 XCTAssertEqual(view.layer.rasterizationScale, screen.scale);
81}
82
83@end
instancetype init()
void testFlutterViewEnableSemanticsWhenIsAccessibilityElementIsCalled()
void testLayerScalesMatchScreenAfterLayoutSubviews()
void testIgnoreWideColorWithoutImpeller()
void testFlutterViewBackgroundColorIsNotNil()
UIScreen * screen()
Definition: FlutterView.mm:34
BOOL isAccessibilityElement()
Definition: FlutterView.mm:222
void layoutSubviews()
Definition: FlutterView.mm:100
std::shared_ptr< flutter::FlutterPlatformViewsController > _platformViewsController
Definition: ref_ptr.h:256
int BOOL
Definition: windows_types.h:37