-
Notifications
You must be signed in to change notification settings - Fork 6k
Remove currentLocale prepend on iOS #18379
Changes from 8 commits
94e0989
68da62f
fa51472
af24191
94a839d
cff57ba
8bdd19d
73d2d8d
a9e37ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // 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 <Flutter/Flutter.h> | ||
| #import <XCTest/XCTest.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
||
|
|
||
| @interface LocalizationInitializationTest : XCTestCase | ||
| @property(nonatomic, strong) XCUIApplication* application; | ||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // 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 "LocalizationInitialization.h" | ||
|
|
||
| FLUTTER_ASSERT_ARC | ||
|
|
||
| @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]); | ||
| XCTAssertEqualObjects([textInputSemanticsObject valueForKey:@"hasKeyboardFocus"], @(NO)); | ||
|
||
| } | ||
|
|
||
| @end | ||
| 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() | ||
| ); | ||
| } | ||
| } |
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!