Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ targets:

- name: Mac mac_clang_tidy
recipe: engine_v2/engine_v2
presubmit: false
presubmit: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert before committing.

timeout: 120
properties:
config_name: mac_clang_tidy
Expand Down
4 changes: 4 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ group("unittests") {
[ "//flutter/shell/platform/android:flutter_shell_native_unittests" ]
}

if (is_ios) {
public_deps += [ "//flutter/shell/platform/darwin/ios:ios_test_flutter" ]
}

# Compile all unittests targets if enabled.
if (enable_unittests) {
public_deps += [
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/darwin/ios/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ source_set("ios_test_flutter_mrc") {

shared_library("ios_test_flutter") {
testonly = true
visibility = [ ":*" ]
visibility = [ "*" ]
cflags = [
"-fvisibility=default",
"-F$platform_frameworks_path",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@

namespace {
API_AVAILABLE(ios(13.4))
// NOLINTNEXTLINE(readability-identifier-naming)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do want to suppress this rather than fix the naming?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. There is actually a constant for it, I removed this declaration.

constexpr UIKeyboardHIDUsage keyACode = (UIKeyboardHIDUsage)0x4; // KeyA iOS scan code.
} // namespace

using namespace flutter::testing;

API_AVAILABLE(ios(13.4))
@interface FlutterChannelKeyResponderTest : XCTestCase
@property(copy, nonatomic) FlutterUIPressProxy* testKeyDownEvent API_AVAILABLE(ios(13.4));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "flutter/shell/platform/embedder/test_utils/key_codes.g.h"

using namespace flutter::testing::keycodes;
using namespace flutter::testing;

FLUTTER_ASSERT_ARC;

Expand Down Expand Up @@ -43,7 +44,7 @@ - (instancetype)initWithEvent:(const FlutterKeyEvent*)event
if (event->character != nullptr) {
size_t len = strlen(event->character);
char* character = new char[len + 1];
strcpy(character, event->character);
strlcpy(character, event->character, len + 1);
_data->character = character;
}
_callback = callback;
Expand All @@ -63,8 +64,9 @@ - (void)respond:(BOOL)handled {
}

- (void)dealloc {
if (_data->character != nullptr)
if (_data->character != nullptr) {
delete[] _data->character;
}
delete _data;
}
@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ - (void)testReleasesProjectOnDealloc {
__weak FlutterDartProject* weakProject;
@autoreleasepool {
FlutterDartProject* mockProject = OCMClassMock([FlutterDartProject class]);
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just XCTAssertNotNil(group) instead of doing this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just XCTAssertNotNil(group) instead of doing this?

FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo"
project:mockProject];
weakProject = mockProject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ - (void)testEnableSemanticsWhenFlutterViewAccessibilityDidCall {
engine.ensureSemanticsEnabledCalled = NO;
[engine flutterViewAccessibilityDidCall];
XCTAssertTrue(engine.ensureSemanticsEnabledCalled);
[engine release];
}

@end
31 changes: 17 additions & 14 deletions shell/platform/darwin/ios/framework/Source/FlutterFakeKeyEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,29 @@ API_AVAILABLE(ios(13.4))
@property(readwrite, nonatomic) NSString* dataCharactersIgnoringModifiers;
@end

FlutterUIPressProxy* keyDownEvent(UIKeyboardHIDUsage keyCode,
UIKeyModifierFlags modifierFlags = 0x0,
NSTimeInterval timestamp = 0.0f,
const char* characters = "",
const char* charactersIgnoringModifiers = "")
namespace flutter {
namespace testing {
extern FlutterUIPressProxy* keyDownEvent(UIKeyboardHIDUsage keyCode,
UIKeyModifierFlags modifierFlags = 0x0,
NSTimeInterval timestamp = 0.0f,
const char* characters = "",
const char* charactersIgnoringModifiers = "")
API_AVAILABLE(ios(13.4));

FlutterUIPressProxy* keyUpEvent(UIKeyboardHIDUsage keyCode,
UIKeyModifierFlags modifierFlags = 0x0,
NSTimeInterval timestamp = 0.0f,
const char* characters = "",
const char* charactersIgnoringModifiers = "")
API_AVAILABLE(ios(13.4));

FlutterUIPressProxy* keyEventWithPhase(UIPressPhase phase,
UIKeyboardHIDUsage keyCode,
extern FlutterUIPressProxy* keyUpEvent(UIKeyboardHIDUsage keyCode,
UIKeyModifierFlags modifierFlags = 0x0,
NSTimeInterval timestamp = 0.0f,
const char* characters = "",
const char* charactersIgnoringModifiers = "")
API_AVAILABLE(ios(13.4));

extern FlutterUIPressProxy* keyEventWithPhase(UIPressPhase phase,
UIKeyboardHIDUsage keyCode,
UIKeyModifierFlags modifierFlags = 0x0,
NSTimeInterval timestamp = 0.0f,
const char* characters = "",
const char* charactersIgnoringModifiers = "")
API_AVAILABLE(ios(13.4));
} // namespace testing
} // namespace flutter
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTER_FAKE_KEY_EVENTS_H_
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ - (NSString*)charactersIgnoringModifiers API_AVAILABLE(ios(13.4)) {
}
@end

namespace flutter {
namespace testing {

FlutterUIPressProxy* keyDownEvent(UIKeyboardHIDUsage keyCode,
UIKeyModifierFlags modifierFlags,
NSTimeInterval timestamp,
Expand Down Expand Up @@ -123,3 +126,5 @@ - (NSString*)charactersIgnoringModifiers API_AVAILABLE(ios(13.4)) {
type:UIEventTypePresses
timestamp:timestamp];
}
} // namespace testing
} // namespace flutter
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
class PointerDataPacket {};
} // namespace flutter

using namespace flutter::testing;

/// Sometimes we have to use a custom mock to avoid retain cycles in ocmock.
@interface FlutterEnginePartialMock : FlutterEngine
@property(nonatomic, strong) FlutterBasicMessageChannel* lifecycleChannel;
Expand Down
Loading