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

Commit 0170774

Browse files
author
Chris Yang
committed
review
format
1 parent b3cfd92 commit 0170774

4 files changed

Lines changed: 15 additions & 24 deletions

File tree

shell/platform/darwin/ios/framework/Source/FlutterChannelKeyResponderTest.mm

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
XCTAssertTrue([value isEqualToString:expected], \
1717
@"String \"%@\" not equal to the expected value of \"%@\"", value, expected)
1818

19-
namespace {
20-
API_AVAILABLE(ios(13.4))
21-
// NOLINTNEXTLINE(readability-identifier-naming)
22-
constexpr UIKeyboardHIDUsage keyACode = (UIKeyboardHIDUsage)0x4; // KeyA iOS scan code.
23-
} // namespace
24-
2519
using namespace flutter::testing;
2620

2721
API_AVAILABLE(ios(13.4))
@@ -38,8 +32,8 @@ - (void)setUp {
3832
} else {
3933
XCTSkip(@"Required API not present for test.");
4034
}
41-
_testKeyDownEvent = keyDownEvent(keyACode, 0x0, 0.0f, "a", "a");
42-
_testKeyUpEvent = keyUpEvent(keyACode, 0x0, 0.0f);
35+
_testKeyDownEvent = keyDownEvent(UIKeyboardHIDUsageKeyboardA, 0x0, 0.0f, "a", "a");
36+
_testKeyUpEvent = keyUpEvent(UIKeyboardHIDUsageKeyboardA, 0x0, 0.0f);
4337
}
4438

4539
- (void)tearDown API_AVAILABLE(ios(13.4)) {
@@ -79,7 +73,7 @@ - (void)testBasicKeyEvent API_AVAILABLE(ios(13.4)) {
7973
XCTAssertEqual([messages count], 1u);
8074
XCTAssertStrEqual([messages lastObject][@"keymap"], @"ios");
8175
XCTAssertStrEqual([messages lastObject][@"type"], @"keydown");
82-
XCTAssertEqual([[messages lastObject][@"keyCode"] intValue], keyACode);
76+
XCTAssertEqual([[messages lastObject][@"keyCode"] intValue], UIKeyboardHIDUsageKeyboardA);
8377
XCTAssertEqual([[messages lastObject][@"modifiers"] intValue], 0x0);
8478
XCTAssertStrEqual([messages lastObject][@"characters"], @"a");
8579
XCTAssertStrEqual([messages lastObject][@"charactersIgnoringModifiers"], @"a");
@@ -100,7 +94,7 @@ - (void)testBasicKeyEvent API_AVAILABLE(ios(13.4)) {
10094
XCTAssertEqual([messages count], 1u);
10195
XCTAssertStrEqual([messages lastObject][@"keymap"], @"ios");
10296
XCTAssertStrEqual([messages lastObject][@"type"], @"keyup");
103-
XCTAssertEqual([[messages lastObject][@"keyCode"] intValue], keyACode);
97+
XCTAssertEqual([[messages lastObject][@"keyCode"] intValue], UIKeyboardHIDUsageKeyboardA);
10498
XCTAssertEqual([[messages lastObject][@"modifiers"] intValue], 0x0);
10599

106100
XCTAssertEqual([responses count], 1u);
@@ -137,7 +131,7 @@ - (void)testEmptyResponseIsTakenAsHandled API_AVAILABLE(ios(13.4)) {
137131
XCTAssertEqual([messages count], 1u);
138132
XCTAssertStrEqual([messages lastObject][@"keymap"], @"ios");
139133
XCTAssertStrEqual([messages lastObject][@"type"], @"keydown");
140-
XCTAssertEqual([[messages lastObject][@"keyCode"] intValue], keyACode);
134+
XCTAssertEqual([[messages lastObject][@"keyCode"] intValue], UIKeyboardHIDUsageKeyboardA);
141135
XCTAssertEqual([[messages lastObject][@"modifiers"] intValue], 0x0);
142136
XCTAssertStrEqual([messages lastObject][@"characters"], @"a");
143137
XCTAssertStrEqual([messages lastObject][@"charactersIgnoringModifiers"], @"a");

shell/platform/darwin/ios/framework/Source/FlutterEngineGroupTest.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ - (void)testReleasesProjectOnDealloc {
130130
__weak FlutterDartProject* weakProject;
131131
@autoreleasepool {
132132
FlutterDartProject* mockProject = OCMClassMock([FlutterDartProject class]);
133-
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
134133
FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo"
135134
project:mockProject];
135+
XCTAssertNotNil(group);
136136
weakProject = mockProject;
137137
XCTAssertNotNil(weakProject);
138138
group = nil;

shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,7 @@ - (void)testWillDeallocNotification {
15851585
usingBlock:^(NSNotification* _Nonnull note) {
15861586
[expectation fulfill];
15871587
}];
1588+
XCTAssertNotNil(realVC);
15881589
realVC = nil;
15891590
}
15901591
[self waitForExpectations:@[ expectation ] timeout:1.0];

shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212

1313
const CGRect kScreenSize = CGRectMake(0, 0, 600, 800);
1414

15-
// copied from clang document: https://clang-analyzer.llvm.org/faq.html#unlocalized_string
16-
__attribute__((annotate("returns_localized_nsstring"))) static inline NSString*
17-
LocalizationNotNeeded(NSString* s) {
18-
return s;
19-
}
20-
2115
namespace flutter {
2216
namespace {
2317

@@ -666,9 +660,11 @@ - (void)testFlutterScrollableSemanticsObjectWithLabelValueHintIsNotHiddenWhenVoi
666660
[scrollable accessibilityBridgeDidFinishUpdate];
667661
UIScrollView* scrollView = [scrollable nativeAccessibility];
668662
XCTAssertTrue(scrollView.isAccessibilityElement);
669-
XCTAssertTrue([scrollView.accessibilityLabel isEqualToString:LocalizationNotNeeded(@"label")]);
670-
XCTAssertTrue([scrollView.accessibilityValue isEqualToString:LocalizationNotNeeded(@"value")]);
671-
XCTAssertTrue([scrollView.accessibilityHint isEqualToString:LocalizationNotNeeded(@"hint")]);
663+
XCTAssertTrue(
664+
[scrollView.accessibilityLabel isEqualToString:NSLocalizedString(@"label", @"test")]);
665+
XCTAssertTrue(
666+
[scrollView.accessibilityValue isEqualToString:NSLocalizedString(@"value", @"test")]);
667+
XCTAssertTrue([scrollView.accessibilityHint isEqualToString:NSLocalizedString(@"hint", @"test")]);
672668
}
673669

674670
- (void)testFlutterSemanticsObjectMergeTooltipToLabel {
@@ -794,7 +790,7 @@ - (void)testSemanticsObjectBuildsAttributedString {
794790
FlutterSemanticsObject* object = [[FlutterSemanticsObject alloc] initWithBridge:bridge uid:0];
795791
[object setSemanticsNode:&node];
796792
NSMutableAttributedString* expectedAttributedLabel =
797-
[[NSMutableAttributedString alloc] initWithString:LocalizationNotNeeded(@"label")];
793+
[[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"label", @"test")];
798794
NSDictionary* attributeDict = @{
799795
UIAccessibilitySpeechAttributeSpellOut : @YES,
800796
};
@@ -803,7 +799,7 @@ - (void)testSemanticsObjectBuildsAttributedString {
803799
[object.accessibilityAttributedLabel isEqualToAttributedString:expectedAttributedLabel]);
804800

805801
NSMutableAttributedString* expectedAttributedValue =
806-
[[NSMutableAttributedString alloc] initWithString:LocalizationNotNeeded(@"value")];
802+
[[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"value", @"test")];
807803
attributeDict = @{
808804
UIAccessibilitySpeechAttributeSpellOut : @YES,
809805
};
@@ -812,7 +808,7 @@ - (void)testSemanticsObjectBuildsAttributedString {
812808
[object.accessibilityAttributedValue isEqualToAttributedString:expectedAttributedValue]);
813809

814810
NSMutableAttributedString* expectedAttributedHint =
815-
[[NSMutableAttributedString alloc] initWithString:LocalizationNotNeeded(@"hint")];
811+
[[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"hint", @"test")];
816812
attributeDict = @{
817813
UIAccessibilitySpeechAttributeLanguage : @"en-MX",
818814
};

0 commit comments

Comments
 (0)