forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
434 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
testing/scenario_app/ios/Scenarios/Scenarios/FlutterEngine+ScenariosTest.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import <Flutter/Flutter.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
@interface FlutterEngine (ScenariosTest) | ||
- (instancetype)initWithScenario:(NSString*)scenario | ||
withCompletion:(nullable void (^)(void))engineRunCompletion; | ||
@end | ||
NS_ASSUME_NONNULL_END |
28 changes: 28 additions & 0 deletions
28
testing/scenario_app/ios/Scenarios/Scenarios/FlutterEngine+ScenariosTest.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import "FlutterEngine+ScenariosTest.h" | ||
|
||
@implementation FlutterEngine (ScenariosTest) | ||
|
||
- (instancetype)initWithScenario:(NSString*)scenario | ||
withCompletion:(nullable void (^)(void))engineRunCompletion { | ||
NSAssert([scenario length] != 0, @"You need to provide a scenario"); | ||
self = [self initWithName:[NSString stringWithFormat:@"Test engine for %@", scenario] | ||
project:nil]; | ||
[self runWithEntrypoint:nil]; | ||
[self.binaryMessenger | ||
setMessageHandlerOnChannel:@"scenario_status" | ||
binaryMessageHandler:^(NSData* message, FlutterBinaryReply reply) { | ||
[self.binaryMessenger | ||
sendOnChannel:@"set_scenario" | ||
message:[scenario dataUsingEncoding:NSUTF8StringEncoding]]; | ||
if (engineRunCompletion != nil) { | ||
engineRunCompletion(); | ||
} | ||
}]; | ||
return self; | ||
} | ||
|
||
@end |
14 changes: 14 additions & 0 deletions
14
testing/scenario_app/ios/Scenarios/Scenarios/ScreenBeforeFlutter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import <Flutter/Flutter.h> | ||
|
||
@interface ScreenBeforeFlutter : UIViewController | ||
|
||
- (id)initWithEngineRunCompletion:(void (^)(void))engineRunCompletion; | ||
- (FlutterViewController*)showFlutter; | ||
|
||
@property(nonatomic, readonly) FlutterEngine* engine; | ||
|
||
@end |
54 changes: 54 additions & 0 deletions
54
testing/scenario_app/ios/Scenarios/Scenarios/ScreenBeforeFlutter.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import "ScreenBeforeFlutter.h" | ||
#import "FlutterEngine+ScenariosTest.h" | ||
|
||
@implementation ScreenBeforeFlutter | ||
|
||
FlutterEngine* _engine; | ||
|
||
- (id)initWithEngineRunCompletion:(void (^)(void))engineRunCompletion { | ||
self = [super init]; | ||
_engine = [[FlutterEngine alloc] initWithScenario:@"poppable_screen" | ||
withCompletion:engineRunCompletion]; | ||
return self; | ||
} | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
self.view.backgroundColor = UIColor.grayColor; | ||
|
||
UIButton* showFlutterButton = [UIButton buttonWithType:UIButtonTypeSystem]; | ||
showFlutterButton.translatesAutoresizingMaskIntoConstraints = NO; | ||
showFlutterButton.backgroundColor = UIColor.blueColor; | ||
[showFlutterButton setTitle:@"Show Flutter" forState:UIControlStateNormal]; | ||
showFlutterButton.tintColor = UIColor.whiteColor; | ||
showFlutterButton.clipsToBounds = YES; | ||
[showFlutterButton addTarget:self | ||
action:@selector(showFlutter) | ||
forControlEvents:UIControlEventTouchUpInside]; | ||
|
||
[self.view addSubview:showFlutterButton]; | ||
[[showFlutterButton.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor] setActive:YES]; | ||
[[showFlutterButton.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor] setActive:YES]; | ||
[[showFlutterButton.heightAnchor constraintEqualToConstant:50] setActive:YES]; | ||
[[showFlutterButton.widthAnchor constraintEqualToConstant:150] setActive:YES]; | ||
|
||
[_engine runWithEntrypoint:nil]; | ||
} | ||
|
||
- (FlutterViewController*)showFlutter { | ||
FlutterViewController* flutterVC = [[FlutterViewController alloc] initWithEngine:_engine | ||
nibName:nil | ||
bundle:nil]; | ||
[self presentViewController:flutterVC animated:NO completion:nil]; | ||
return flutterVC; | ||
} | ||
|
||
- (FlutterEngine*)engine { | ||
return _engine; | ||
} | ||
|
||
@end |
Oops, something went wrong.