-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forwards iOS dark mode trait to the Flutter framework (#34441). #9722
Forwards iOS dark mode trait to the Flutter framework (#34441). #9722
Conversation
a94504c
to
c1136d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For tests, take a look at https://github.com/flutter/engine/blob/master/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm
You could mock out the engine for the VC, mock out the settingschannel for the mock engine, and verify that calling the methods you're changing here resulted in a message on the settings channel.
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
Outdated
Show resolved
Hide resolved
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
Outdated
Show resolved
Hide resolved
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
Outdated
Show resolved
Hide resolved
@dnfield can we do any better in terms of test value? Seems like that kind of test fakes most of the important machinery to validate one of the simplest and least likely to change details, a channel message....seems very low value from a regression-prevention standpoint. |
My thought is that it would test that a channel message is sent on these events, which is all the new behavior this PR introduces. An end to end test of that would be even better, but harder to create IMO. You could put another integration test in ios_add2app but not sure how you would modify the system setting in a test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I can't think of a better way to test than what's been suggested. Not sure about changing system settings in an e2e test.
It sounds like reporting trait collection changes in one of the methods in the list should suffice? I wonder if we can reduce it down to EDIT: According to this article, |
In terms of preventing regressions, it would prevent someone from inadvertently removing one of the places where we need to invoke this channel. Part of the idea here is that channel message passing should also be well tested (but shouldn't be the responsibility of this PR), and the framework's handling of such a message should also be well tested (but also isn't the job of this PR). It's also not our responsibility to test whether iOS calls the methods it documents that it will call in the linked documentation. As I said, an integration test would also be good but is probably pretty challenging to get quite right in this case - I think at the least we'd end up mocking out the system preference change by just directly messaging the ViewController. |
@dnfield @justinmc I'll go ahead and try to write up that test as described. @LongCatIsLooong I'm open to removing excessive calls. Can you demonstrate that we don't need all of those methods? It may be the case that they are often called in succession, but the question is, are there ever moments where only 1 of them is called? If so, then we would need that call overridden. Unfortunately, I don't know nearly enough about ViewController lifecycles. CC @dnfield if you happen to know about this. |
@dnfield do we have any docs for how to run those tests locally? If not, would you mind providing instructions here? |
@gaaclarke should know, but I think you just run the shell scripts in that folder.... |
@dnfield I'm not seeing a shell script in that directory, or its parent directory. Can you point me to the script you're thinking of? |
@matthew-carroll do you plan to continue with this PR? |
Yep. I need to figure out how to write unit tests for iOS first. |
1d45ae2
to
ee52181
Compare
I finally got around to adding tests for this. @dnfield can you take another look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the test. Fyi @LongCatIsLooong
This patch causes LUCI failures on the iOS builder. https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket.appspot.com/8905650479855166128/+/steps/build_ios_debug_sim/0/stdout |
[email protected]:flutter/engine.git/compare/d9bbe37ce376...dd735c9 git log d9bbe37..dd735c9 --no-merges --oneline 2019-08-09 [email protected] [flutter_runner] Improve frame scheduling (flutter/engine#10780) 2019-08-09 [email protected] [flutter] Create the compositor context on the GPU task runner. (flutter/engine#10781) 2019-08-09 [email protected] Revert "Forwards iOS dark mode trait to the Flutter framework (#34441). (#9722)" (flutter/engine#10789) 2019-08-08 [email protected] Forwards iOS dark mode trait to the Flutter framework (#34441). (flutter/engine#9722) 2019-08-08 [email protected] Specify which android variant for tests (flutter/engine#10717) 2019-08-08 [email protected] Don't use gradle daemon for building (flutter/engine#10771) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff ([email protected]), and stop the roller if necessary.
Forwards iOS dark mode trait to the Flutter framework (#34441).
This change forwards iOS's dark mode setting to the Flutter framework from the appropriate
ViewController
methods:https://developer.apple.com/documentation/appkit/supporting_dark_mode_in_your_interface?language=objc
MaterialApp
will respect this setting on iOS. I don't believeCupertinoApp
is setup yet to respect brightness.This change does not include official color support for iOS's dark mode, nor does this PR resolve the issue of rendering correctly in the app switcher.