Flutter Engine
FlutterPluginAppLifeCycleDelegateTest.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 <OCMock/OCMock.h>
6 #import <XCTest/XCTest.h>
7 
8 #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
9 #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h"
10 
12 
14 
15 @end
16 
18 
19 - (void)testCreate {
21  XCTAssertNotNil(delegate);
22 }
23 
24 - (void)testDidEnterBackground {
26  id plugin = OCMProtocolMock(@protocol(FlutterPlugin));
27  [delegate addDelegate:plugin];
28  [[NSNotificationCenter defaultCenter]
29  postNotificationName:UIApplicationDidEnterBackgroundNotification
30  object:nil];
31  OCMVerify([plugin applicationDidEnterBackground:[UIApplication sharedApplication]]);
32 }
33 
34 - (void)testWillEnterForeground {
36  id plugin = OCMProtocolMock(@protocol(FlutterPlugin));
37  [delegate addDelegate:plugin];
38  [[NSNotificationCenter defaultCenter]
39  postNotificationName:UIApplicationWillEnterForegroundNotification
40  object:nil];
41  OCMVerify([plugin applicationWillEnterForeground:[UIApplication sharedApplication]]);
42 }
43 
44 - (void)testWillResignActive {
46  id plugin = OCMProtocolMock(@protocol(FlutterPlugin));
47  [delegate addDelegate:plugin];
48  [[NSNotificationCenter defaultCenter]
49  postNotificationName:UIApplicationWillResignActiveNotification
50  object:nil];
51  OCMVerify([plugin applicationWillResignActive:[UIApplication sharedApplication]]);
52 }
53 
54 - (void)skip_testDidBecomeActive {
56  id plugin = OCMProtocolMock(@protocol(FlutterPlugin));
57  [delegate addDelegate:plugin];
58  [[NSNotificationCenter defaultCenter]
59  postNotificationName:UIApplicationDidBecomeActiveNotification
60  object:nil];
61  OCMVerify([plugin applicationDidBecomeActive:[UIApplication sharedApplication]]);
62 }
63 
64 - (void)testWillTerminate {
66  id plugin = OCMProtocolMock(@protocol(FlutterPlugin));
67  [delegate addDelegate:plugin];
68  [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillTerminateNotification
69  object:nil];
70  OCMVerify([plugin applicationWillTerminate:[UIApplication sharedApplication]]);
71 }
72 
73 @end
void addDelegate:(NSObject< FlutterApplicationLifeCycleDelegate > *delegate)
#define FLUTTER_ASSERT_ARC
Definition: FlutterMacros.h:44