|
| 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/FlutterEngine_Internal.h" |
| 8 | +#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h" |
| 9 | + |
| 10 | +@interface FakeDelegate : NSObject <FlutterViewEngineDelegate> |
| 11 | +@property(nonatomic) BOOL callbackCalled; |
| 12 | +@end |
| 13 | + |
| 14 | +@implementation FakeDelegate { |
| 15 | + std::shared_ptr<flutter::FlutterPlatformViewsController> _platformViewsController; |
| 16 | +} |
| 17 | + |
| 18 | +- (instancetype)init { |
| 19 | + _callbackCalled = NO; |
| 20 | + _platformViewsController = std::shared_ptr<flutter::FlutterPlatformViewsController>(nullptr); |
| 21 | + return self; |
| 22 | +} |
| 23 | + |
| 24 | +- (flutter::Rasterizer::Screenshot)takeScreenshot:(flutter::Rasterizer::ScreenshotType)type |
| 25 | + asBase64Encoded:(BOOL)base64Encode { |
| 26 | + return {}; |
| 27 | +} |
| 28 | + |
| 29 | +- (std::shared_ptr<flutter::FlutterPlatformViewsController>&)platformViewsController { |
| 30 | + return _platformViewsController; |
| 31 | +} |
| 32 | + |
| 33 | +- (void)flutterViewAccessibilityDidCall { |
| 34 | + _callbackCalled = YES; |
| 35 | +} |
| 36 | + |
| 37 | +@end |
| 38 | + |
| 39 | +@interface FlutterViewTest : XCTestCase |
| 40 | +@end |
| 41 | + |
| 42 | +@implementation FlutterViewTest |
| 43 | + |
| 44 | +- (void)testFlutterViewEnableSemanticsWhenIsAccessibilityElementIsCalled { |
| 45 | + FakeDelegate* delegate = [[FakeDelegate alloc] init]; |
| 46 | + FlutterView* view = [[FlutterView alloc] initWithDelegate:delegate opaque:NO]; |
| 47 | + delegate.callbackCalled = NO; |
| 48 | + XCTAssertFalse(view.isAccessibilityElement); |
| 49 | + XCTAssertTrue(delegate.callbackCalled); |
| 50 | +} |
| 51 | + |
| 52 | +@end |
0 commit comments