This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Remove currentLocale prepend on iOS #18379
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
94e0989
Remove locale prepend on iOS
GaryQian 68da62f
add test
GaryQian fa51472
Fix import
GaryQian af24191
Add new test to map
GaryQian 94a839d
Cleanup
GaryQian cff57ba
Fix test targets
GaryQian 8bdd19d
Passes tests now
GaryQian 73d2d8d
Remove extra code
GaryQian a9e37ec
Address comments
GaryQian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
36 changes: 36 additions & 0 deletions
36
testing/scenario_app/ios/Scenarios/ScenariosUITests/LocalizationInitializationTest.m
This file contains hidden or 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,36 @@ | ||
| // Copyright 2013 The Flutter 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> | ||
| #import <XCTest/XCTest.h> | ||
|
|
||
| FLUTTER_ASSERT_ARC | ||
|
|
||
| @interface LocalizationInitializationTest : XCTestCase | ||
| @property(nonatomic, strong) XCUIApplication* application; | ||
| @end | ||
|
|
||
| @implementation LocalizationInitializationTest | ||
|
|
||
| - (void)setUp { | ||
| [super setUp]; | ||
| self.continueAfterFailure = NO; | ||
|
|
||
| self.application = [[XCUIApplication alloc] init]; | ||
| self.application.launchArguments = @[ @"--locale-initialization" ]; | ||
| [self.application launch]; | ||
| } | ||
|
|
||
| - (void)testNoLocalePrepend { | ||
| NSTimeInterval timeout = 10.0; | ||
|
|
||
| XCUIElement* textInputSemanticsObject = | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know the engine has variable usage of dot notation, but the "modern" syntax (like circa 2006 modern) of properties would be: XCUIElement* textInputSemanticsObject = [self.application.textFields matchingIdentifier:@"[en]"].element; |
||
| [self.application.textFields matchingIdentifier:@"[en]"].element; | ||
|
|
||
| // The locales recieved by dart:ui are exposed onBeginFrame via semantics label. | ||
| // There should only be one locale, as we have removed the locale prepend on iOS. | ||
| XCTAssertTrue([textInputSemanticsObject waitForExistenceWithTimeout:timeout]); | ||
| } | ||
|
|
||
| @end | ||
This file contains hidden or 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,69 @@ | ||
| // Copyright 2020 The Flutter 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 'dart:typed_data'; | ||
| import 'dart:ui'; | ||
|
|
||
| import 'package:vector_math/vector_math_64.dart'; | ||
|
|
||
| import 'scenario.dart'; | ||
|
|
||
| /// Sends the recieved locale data back as semantics information. | ||
| class LocaleInitialization extends Scenario { | ||
| /// Constructor | ||
| LocaleInitialization(Window window) | ||
| : assert(window != null), | ||
| super(window); | ||
|
|
||
| @override | ||
| void onBeginFrame(Duration duration) { | ||
| // Doesn't matter what we draw. Just paint white. | ||
| final SceneBuilder builder = SceneBuilder(); | ||
| final PictureRecorder recorder = PictureRecorder(); | ||
| final Canvas canvas = Canvas(recorder); | ||
|
|
||
| canvas.drawRect( | ||
| Rect.fromLTWH(0, 0, window.physicalSize.width, window.physicalSize.height), | ||
| Paint()..color = const Color.fromARGB(255, 255, 255, 255), | ||
| ); | ||
| final Picture picture = recorder.endRecording(); | ||
|
|
||
| builder.addPicture( | ||
| Offset.zero, | ||
| picture, | ||
| ); | ||
| final Scene scene = builder.build(); | ||
| window.render(scene); | ||
| scene.dispose(); | ||
|
|
||
| // On the first frame, pretend that it drew a text field. Send the | ||
| // corresponding semantics tree comprised of 1 node with the locale data | ||
| // as the label. | ||
| window.updateSemantics((SemanticsUpdateBuilder() | ||
| ..updateNode( | ||
| id: 0, | ||
| // SemanticsFlag.isTextField. | ||
| flags: 16, | ||
| // SemanticsAction.tap. | ||
| actions: 1, | ||
| rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0), | ||
| label: window.locales.toString(), | ||
| textDirection: TextDirection.ltr, | ||
| textSelectionBase: -1, | ||
| textSelectionExtent: -1, | ||
| platformViewId: -1, | ||
| maxValueLength: -1, | ||
| currentValueLength: 0, | ||
| scrollChildren: 0, | ||
| scrollIndex: 0, | ||
| transform: Matrix4.identity().storage, | ||
| elevation: 0.0, | ||
| thickness: 0.0, | ||
| childrenInTraversalOrder: Int32List(0), | ||
| childrenInHitTestOrder: Int32List(0), | ||
| additionalActions: Int32List(0), | ||
| )).build() | ||
| ); | ||
| } | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Fun fact: you can change the app's locale and language with launch args
-AppleLanguagesand-AppleLocale.https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPInternational/TestingYourInternationalApp/TestingYourInternationalApp.html#//apple_ref/doc/uid/10000171i-CH7-SW2
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.
Thanks, Will be super useful for the next set of changes that I'll be making immediately after this one!