Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
LocalizationInitializationTest.m
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#import <Flutter/Flutter.h>
6#import <XCTest/XCTest.h>
7
9
10@interface LocalizationInitializationTest : XCTestCase
11@property(nonatomic, strong) XCUIApplication* application;
12@end
13
15
16- (void)setUp {
17 [super setUp];
18 self.continueAfterFailure = NO;
19
20 self.application = [[XCUIApplication alloc] init];
21 self.application.launchArguments = @[ @"--locale-initialization" ];
22 [self.application launch];
23}
24
25- (void)testNoLocalePrepend {
26 NSTimeInterval timeout = 10.0;
27
28 // The locales received by dart:ui are exposed onBeginFrame via semantics label.
29 // There should only be one locale. The list should consist of the default
30 // locale provided by the iOS app.
31 NSArray<NSString*>* preferredLocales = [NSLocale preferredLanguages];
32 XCTAssertEqual(preferredLocales.count, 1);
33 // Dart connects the locale parts with `_` while iOS connects them with `-`.
34 // Converts to dart format before comparing.
35 NSString* localeDart = [preferredLocales.firstObject stringByReplacingOccurrencesOfString:@"-"
36 withString:@"_"];
37 NSString* expectedIdentifier = [NSString stringWithFormat:@"[%@]", localeDart];
38 XCUIElement* textInputSemanticsObject =
39 [self.application.textFields matchingIdentifier:expectedIdentifier].element;
40 XCTAssertTrue([textInputSemanticsObject waitForExistenceWithTimeout:timeout]);
41
42 [textInputSemanticsObject tap];
43}
44
45@end