Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Sep 22, 2020

Description

Started setting the intiailRoute and entryPoint via launch urls if no plugin handles the URL.

Related Issues

flutter/flutter#66294 (comment)

Tests

I added the following tests:

Replace this with a list of the tests that you added as part of this PR. A
change in behaviour with no test covering it will likely get reverted
accidentally sooner or later. PRs must include tests for all
changed/updated/fixed behaviors. See testing the engine for instructions on
writing and running engine tests.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the contributor guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the C++, Objective-C, Java style guides for the engine.
  • I read the tree hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation.
  • All existing and new tests are passing.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read handling breaking changes.

@gaaclarke gaaclarke force-pushed the initial-route-launch-url branch from 83cd04a to 3a2ab05 Compare September 22, 2020 22:11
@gaaclarke gaaclarke force-pushed the initial-route-launch-url branch 3 times, most recently from f800400 to 4287dd0 Compare October 1, 2020 23:48
@gaaclarke gaaclarke marked this pull request as ready for review October 1, 2020 23:49
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@gaaclarke
Copy link
Member Author

ping @goderbauer @chunhtai

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good. just need a test

#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h"

#include "flutter/fml/logging.h"
#import "flutter/fml/logging.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we decide whether we use import vs include? I originally thought we always include c++ file and import objective c file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the file is objective-c or objective-c++ just always use import.

}];
return YES;
} else {
FML_LOG(ERROR) << "Attempting to open an URL without a Flutter RootViewController.";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what situation this can happen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unlikely but if you edit the storyboard for the iOS project this could happen. Also, if you were doing add to app and you call into a FlutterAppDelegate it could be a problem.

@gaaclarke
Copy link
Member Author

@chunhtai tests added, thanks for pushing on that.

if ([viewController isKindOfClass:[FlutterViewController class]]) {
return (FlutterViewController*)viewController;
- (FlutterViewController*)rootFlutterViewController {
if (_rootFlutterViewControllerGetter != nil) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only used in test? It seems weird that we inject the getter this way, is it possible for the test to override this class and override this method to inject the getter there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could, but it's the class I'm testing. In order to do that I'd have to make a partial mock of the class I actually want to test which is weird, too.

I could do more traditional dependency injection and pass in an object that can get the root FlutterViewController in with the FlutterAppDelegate's initializer. This is basically the same thing but with a setter. I wanted to introduce the least amount of overhead possible, that's why it's a pointer check that will basically be ignored with branch prediction. If I always passed the logic through a block or a protocol we would always incur a dynamic dispatch.


- (void)dealloc {
[_lifeCycleDelegate release];
[_rootFlutterViewControllerGetter release];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class does not create the getter, it seems weird that this class is responsible for destroying it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually does create it in its declaration of the property. This is related to your other comment, too. The file FlutterAppDelegate_Test is a thing called a category which allows you to extend classes or make methods selectively visible. You can think of this as declaring that property as @VisibleForTesting.

@gaaclarke gaaclarke force-pushed the initial-route-launch-url branch from c276c88 to 43e792f Compare October 23, 2020 23:48
@gaaclarke
Copy link
Member Author

@chunhtai let me know what you want to do. You said "looks good" for the code but had some questions on the tests. I just want to make sure you get your concerns addressed before landing this.

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 27, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 27, 2020
chunhtai added a commit to chunhtai/engine that referenced this pull request Nov 5, 2020
chaselatta pushed a commit to chaselatta/engine that referenced this pull request Nov 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants