Skip to content

Commit 11e04bc

Browse files
author
Chris Yang
committed
Revert "Revert "Reland "Build iOS unittest target in unopt builds" (flutter#44356)"" (flutter#45346)"
This reverts commit ca513c9. fix 1 fix fix temp ci change fix name space fix fix fix format
1 parent b91d1aa commit 11e04bc

14 files changed

+107
-81
lines changed

.ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ targets:
393393

394394
- name: Mac mac_clang_tidy
395395
recipe: engine_v2/engine_v2
396-
presubmit: false
396+
presubmit: true
397397
timeout: 120
398398
properties:
399399
config_name: mac_clang_tidy

BUILD.gn

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ group("unittests") {
149149
[ "//flutter/shell/platform/android:flutter_shell_native_unittests" ]
150150
}
151151

152+
if (is_ios) {
153+
public_deps += [ "//flutter/shell/platform/darwin/ios:ios_test_flutter" ]
154+
}
155+
152156
# Compile all unittests targets if enabled.
153157
if (enable_unittests) {
154158
public_deps += [

shell/platform/darwin/ios/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ source_set("ios_test_flutter_mrc") {
270270

271271
shared_library("ios_test_flutter") {
272272
testonly = true
273-
visibility = [ ":*" ]
273+
visibility = [ "*" ]
274274
cflags = [
275275
"-fvisibility=default",
276276
"-F$platform_frameworks_path",

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818

1919
namespace {
2020
API_AVAILABLE(ios(13.4))
21+
// NOLINTNEXTLINE(readability-identifier-naming)
2122
constexpr UIKeyboardHIDUsage keyACode = (UIKeyboardHIDUsage)0x4; // KeyA iOS scan code.
2223
} // namespace
2324

25+
using namespace flutter::testing;
26+
2427
API_AVAILABLE(ios(13.4))
2528
@interface FlutterChannelKeyResponderTest : XCTestCase
2629
@property(copy, nonatomic) FlutterUIPressProxy* testKeyDownEvent API_AVAILABLE(ios(13.4));

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "flutter/shell/platform/embedder/test_utils/key_codes.g.h"
1616

1717
using namespace flutter::testing::keycodes;
18+
using namespace flutter::testing;
1819

1920
FLUTTER_ASSERT_ARC;
2021

@@ -43,7 +44,7 @@ - (instancetype)initWithEvent:(const FlutterKeyEvent*)event
4344
if (event->character != nullptr) {
4445
size_t len = strlen(event->character);
4546
char* character = new char[len + 1];
46-
strcpy(character, event->character);
47+
strlcpy(character, event->character, len);
4748
_data->character = character;
4849
}
4950
_callback = callback;
@@ -63,8 +64,9 @@ - (void)respond:(BOOL)handled {
6364
}
6465

6566
- (void)dealloc {
66-
if (_data->character != nullptr)
67+
if (_data->character != nullptr) {
6768
delete[] _data->character;
69+
}
6870
delete _data;
6971
}
7072
@end

shell/platform/darwin/ios/framework/Source/FlutterFakeKeyEvents.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,29 @@ API_AVAILABLE(ios(13.4))
4747
@property(readwrite, nonatomic) NSString* dataCharactersIgnoringModifiers;
4848
@end
4949

50-
FlutterUIPressProxy* keyDownEvent(UIKeyboardHIDUsage keyCode,
51-
UIKeyModifierFlags modifierFlags = 0x0,
52-
NSTimeInterval timestamp = 0.0f,
53-
const char* characters = "",
54-
const char* charactersIgnoringModifiers = "")
50+
namespace flutter {
51+
namespace testing {
52+
extern FlutterUIPressProxy* keyDownEvent(UIKeyboardHIDUsage keyCode,
53+
UIKeyModifierFlags modifierFlags = 0x0,
54+
NSTimeInterval timestamp = 0.0f,
55+
const char* characters = "",
56+
const char* charactersIgnoringModifiers = "")
5557
API_AVAILABLE(ios(13.4));
5658

57-
FlutterUIPressProxy* keyUpEvent(UIKeyboardHIDUsage keyCode,
58-
UIKeyModifierFlags modifierFlags = 0x0,
59-
NSTimeInterval timestamp = 0.0f,
60-
const char* characters = "",
61-
const char* charactersIgnoringModifiers = "")
62-
API_AVAILABLE(ios(13.4));
63-
64-
FlutterUIPressProxy* keyEventWithPhase(UIPressPhase phase,
65-
UIKeyboardHIDUsage keyCode,
59+
extern FlutterUIPressProxy* keyUpEvent(UIKeyboardHIDUsage keyCode,
6660
UIKeyModifierFlags modifierFlags = 0x0,
6761
NSTimeInterval timestamp = 0.0f,
6862
const char* characters = "",
6963
const char* charactersIgnoringModifiers = "")
7064
API_AVAILABLE(ios(13.4));
7165

66+
extern FlutterUIPressProxy* keyEventWithPhase(UIPressPhase phase,
67+
UIKeyboardHIDUsage keyCode,
68+
UIKeyModifierFlags modifierFlags = 0x0,
69+
NSTimeInterval timestamp = 0.0f,
70+
const char* characters = "",
71+
const char* charactersIgnoringModifiers = "")
72+
API_AVAILABLE(ios(13.4));
73+
} // namespace testing
74+
} // namespace flutter
7275
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTER_FAKE_KEY_EVENTS_H_

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ - (NSString*)charactersIgnoringModifiers API_AVAILABLE(ios(13.4)) {
8484
}
8585
@end
8686

87+
namespace flutter {
88+
namespace testing {
89+
8790
FlutterUIPressProxy* keyDownEvent(UIKeyboardHIDUsage keyCode,
8891
UIKeyModifierFlags modifierFlags,
8992
NSTimeInterval timestamp,
@@ -123,3 +126,5 @@ - (NSString*)charactersIgnoringModifiers API_AVAILABLE(ios(13.4)) {
123126
type:UIEventTypePresses
124127
timestamp:timestamp];
125128
}
129+
} // namespace testing
130+
} // namespace flutter

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
class PointerDataPacket {};
2222
} // namespace flutter
2323

24+
using namespace flutter::testing;
25+
2426
/// Sometimes we have to use a custom mock to avoid retain cycles in ocmock.
2527
@interface FlutterEnginePartialMock : FlutterEngine
2628
@property(nonatomic, strong) FlutterBasicMessageChannel* lifecycleChannel;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ - (void)testRetainCycle {
6161
weakEngine = engine;
6262
}
6363
XCTAssertNil(weakEngine);
64+
XCTAssertNotNil(strongRelay);
6465
}
6566

6667
@end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ - (void)setUp {
4141

4242
self.undoManagerPlugin = [[FlutterUndoManagerPluginForTest alloc] initWithDelegate:self.engine];
4343

44-
self.viewController = [FlutterViewController new];
44+
self.viewController = [[FlutterViewController alloc] init];
4545
self.undoManagerPlugin.viewController = self.viewController;
4646

4747
self.undoManager = OCMClassMock([NSUndoManager class]);

0 commit comments

Comments
 (0)