| Flutter iOS Embedder |

FlutterSceneDelegateTest.m
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 <Foundation/Foundation.h>
6 #import <OCMock/OCMock.h>
7 #import <XCTest/XCTest.h>
8
9 #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h"
10 #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h"
11 #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterSceneDelegate.h"
12 #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate_Internal.h"
13
14 @interface FlutterSceneDelegateTest : XCTestCase
15 @end
16
17 @implementation FlutterSceneDelegateTest
18
19 - (void)setUp {
20 }
21
22 - (void)tearDown {
23 }
24
25 - (void)testBridgeShortcut {
26 id mockApplication = OCMClassMock([UIApplication class]);
27 OCMStub([mockApplication sharedApplication]).andReturn(mockApplication);
28 id mockAppDelegate = OCMClassMock([FlutterAppDelegate class]);
29 id mockLifecycleDelegate = OCMClassMock([FlutterPluginAppLifeCycleDelegate class]);
30 OCMStub([mockApplication delegate]).andReturn(mockAppDelegate);
31 OCMStub([mockAppDelegate lifeCycleDelegate]).andReturn(mockLifecycleDelegate);
32 id windowScene = OCMClassMock([UIWindowScene class]);
33 id shortcut = OCMClassMock([UIApplicationShortcutItem class]);
34
35 FlutterSceneDelegate* sceneDelegate = [[FlutterSceneDelegate alloc] init];
36 [sceneDelegate windowScene:windowScene
37 performActionForShortcutItem:shortcut
38 completionHandler:^(BOOL succeeded){
39 }];
40
41 OCMVerify([(FlutterPluginAppLifeCycleDelegate*)mockLifecycleDelegate application:[OCMArg any]
42 performActionForShortcutItem:[OCMArg any]
43 completionHandler:[OCMArg any]]);
44 }
45
46 - (void)testOpenURL {
47 id mockApplication = OCMClassMock([UIApplication class]);
48 OCMStub([mockApplication sharedApplication]).andReturn(mockApplication);
49 id mockAppDelegate = OCMClassMock([FlutterAppDelegate class]);
50 id mockLifecycleDelegate = OCMClassMock([FlutterPluginAppLifeCycleDelegate class]);
51 OCMStub([mockApplication delegate]).andReturn(mockAppDelegate);
52 OCMStub([mockAppDelegate lifeCycleDelegate]).andReturn(mockLifecycleDelegate);
53 id windowScene = OCMClassMock([UIWindowScene class]);
54 id urlContext = OCMClassMock([UIOpenURLContext class]);
55 NSURL* url = [NSURL URLWithString:@"http://example.com"];
56 OCMStub([urlContext URL]).andReturn(url);
57
58 FlutterSceneDelegate* sceneDelegate = [[FlutterSceneDelegate alloc] init];
59 [sceneDelegate scene:windowScene openURLContexts:[NSSet setWithArray:@[ urlContext ]]];
60
61 OCMVerify([(FlutterPluginAppLifeCycleDelegate*)mockLifecycleDelegate application:[OCMArg any]
62 openURL:url
63 options:[OCMArg any]]);
64 }
65
66 @end
FlutterAppDelegate.h
FlutterAppDelegate_Internal.h
FlutterPluginAppLifeCycleDelegate.h
FlutterSceneDelegate.h
FlutterAppDelegate
Definition: FlutterAppDelegate.h:28
FlutterPluginAppLifeCycleDelegate
Definition: FlutterPluginAppLifeCycleDelegate.h:16
FlutterSceneDelegate
Definition: FlutterSceneDelegate.h:19
FlutterSceneDelegateTest
Definition: FlutterSceneDelegateTest.m:15