| Flutter iOS Embedder |

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
9 FLUTTER_ASSERT_ARC
10
11 @interface FakeDelegate : NSObject <FlutterViewEngineDelegate>
12 @property(nonatomic) BOOL callbackCalled;
13 @end
14
15 @implementation FakeDelegate
16
17 @synthesize platformViewsController = _platformViewsController;
18
19 - (instancetype)init {
20 _callbackCalled = NO;
21 return self;
22 }
23
24 - (flutter::Rasterizer::Screenshot)takeScreenshot:(flutter::Rasterizer::ScreenshotType)type
25 asBase64Encoded:(BOOL)base64Encode {
26 return {};
27 }
28
29 - (void)flutterViewAccessibilityDidCall {
30 _callbackCalled = YES;
31 }
32
33 @end
34
35 @interface FlutterViewTest : XCTestCase
36 @end
37
38 @implementation FlutterViewTest
39
40 - (void)testFlutterViewEnableSemanticsWhenIsAccessibilityElementIsCalled {
41 FakeDelegate* delegate = [[FakeDelegate alloc] init];
42 FlutterView* view = [[FlutterView alloc] initWithDelegate:delegate opaque:NO enableWideGamut:NO];
43 delegate.callbackCalled = NO;
44 XCTAssertFalse(view.isAccessibilityElement);
45 XCTAssertTrue(delegate.callbackCalled);
46 }
47
48 - (void)testFlutterViewBackgroundColorIsNil {
49 FakeDelegate* delegate = [[FakeDelegate alloc] init];
50 FlutterView* view = [[FlutterView alloc] initWithDelegate:delegate opaque:NO enableWideGamut:NO];
51 XCTAssertNil(view.backgroundColor);
52 }
53
54 - (void)testLayerScalesMatchScreenAfterLayoutSubviews {
55 FakeDelegate* delegate = [[FakeDelegate alloc] init];
56 FlutterView* view = [[FlutterView alloc] initWithDelegate:delegate opaque:NO enableWideGamut:NO];
57 view.layer.contentsScale = CGFloat(-99.0);
58 view.layer.rasterizationScale = CGFloat(-99.0);
59 UIScreen* screen = [view screen];
60 XCTAssertNotEqual(view.layer.contentsScale, screen.scale);
61 XCTAssertNotEqual(view.layer.rasterizationScale, screen.scale);
62 [view layoutSubviews];
63 XCTAssertEqual(view.layer.contentsScale, screen.scale);
64 XCTAssertEqual(view.layer.rasterizationScale, screen.scale);
65 }
66
67 @end
FlutterView.h
FakeDelegate
Definition: FlutterViewTest.mm:11
FakeDelegate::callbackCalled
BOOL callbackCalled
Definition: FlutterViewTest.mm:12
FlutterView
Definition: FlutterView.h:33
-[FlutterView screen]
UIScreen * screen()
Definition: FlutterView.mm:36
FlutterViewTest
Definition: FlutterViewTest.mm:36
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13
FlutterViewEngineDelegate-p
Definition: FlutterView.h:14
FlutterViewEngineDelegate-p::platformViewsController
FlutterPlatformViewsController * platformViewsController
Definition: FlutterView.h:16
-[FlutterViewEngineDelegate-p flutterViewAccessibilityDidCall]
void flutterViewAccessibilityDidCall()