Skip to content

Commit

Permalink
Add native skip on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
pdenert committed Jul 26, 2024
1 parent 6c74642 commit 8818029
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
25 changes: 25 additions & 0 deletions dev/e2e_app/integration_test/macos/macos_app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,29 @@ void main() {
scrollDirection: AxisDirection.up,
);
});

patrol('taps around test to skip', skip: true, ($) async {
await createApp($);
await $.waitUntilVisible($(#counterText));

expect($(#counterText).text, '0');

await $(FloatingActionButton).tap();

expect($(#counterText).text, '1');

await $(#textField).enterText('Hello, Flutter!');
expect($('Hello, Flutter!'), findsOneWidget);

await $('Open scrolling screen').scrollTo().tap();
await $.waitUntilVisible($(#topText));

await $.scrollUntilVisible(finder: $(#bottomText));

await $.tap($(#backButton));
await $.scrollUntilVisible(
finder: $(#counterText),
scrollDirection: AxisDirection.up,
);
});
}
2 changes: 1 addition & 1 deletion dev/e2e_app/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ SPEC CHECKSUMS:
flutter_timezone: 6b906d1740654acb16e50b639835628fea851037
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
geolocator_apple: 72a78ae3f3e4ec0db62117bd93e34523f5011d58
patrol: 3e21d514020dbee24b3e3383caac9e8e051292ac
patrol: 0564cee315ff6c86fb802b3647db05cc2d3d0624

PODFILE CHECKSUM: 4dcdd5fa8959bf7a21c4e3da36b083ff9ad52d38

Expand Down
19 changes: 12 additions & 7 deletions packages/patrol/darwin/Classes/PatrolIntegrationTestMacosRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
\
NSLog(@"listDartTests"); \
\
__block NSArray<NSString *> *dartTests = NULL; \
[appServiceClient listDartTestsWithCompletion:^(NSArray<NSString *> *_Nullable tests, NSError *_Nullable err) { \
__block NSArray<NSDictionary *> *dartTests = NULL; \
[appServiceClient listDartTestsWithCompletion:^(NSArray<NSDictionary *> *_Nullable tests, NSError *_Nullable err) { \
if (err != NULL) { \
NSLog(@"listDartTests(): failed, err: %@", err); \
} \
Expand All @@ -71,15 +71,20 @@
* Step 2. Create invocations to the generated methods and return them \
*/ \
\
for (NSString * dartTest in dartTests) { \
for (NSDictionary * dartTest in dartTests) { \
/* Step 1 - dynamically create test cases */ \
NSString * dartTestName = dartTest[@"name"]; \
BOOL skip = [dartTest[@"skip"] boolValue]; \
\
IMP implementation = imp_implementationWithBlock(^(id _self) { \
[[[XCUIApplication alloc] init] launch]; \
if (skip) { \
XCTSkip(@"Skip that test \"%@\"", dartTestName); \
} \
\
__block ObjCRunDartTestResponse *response = NULL; \
__block NSError *error; \
[appServiceClient runDartTestWithName:dartTest \
[appServiceClient runDartTestWithName:dartTestName \
completion:^(ObjCRunDartTestResponse *_Nullable r, NSError *_Nullable err) { \
NSString *status; \
if (err != NULL) { \
Expand All @@ -89,7 +94,7 @@
response = r; \
status = response.passed ? @"PASSED" : @"FAILED"; \
} \
NSLog(@"runDartTest(\"%@\"): call finished, test result: %@", dartTest, status); \
NSLog(@"runDartTest(\"%@\"): call finished, test result: %@", dartTestName, status); \
}]; \
\
/* Wait until Dart test finishes (either fails or passes) or crashes */ \
Expand All @@ -100,15 +105,15 @@
NSString *details = response ? response.details : @"(no details - app likely crashed)"; \
XCTAssertTrue(passed, @"%@", details); \
}); \
SEL selector = NSSelectorFromString(dartTest); \
SEL selector = NSSelectorFromString(dartTestName); \
class_addMethod(self, selector, implementation, "v@:"); \
\
/* Step 2 – create invocations to the dynamically created methods */ \
NSMethodSignature *signature = [self instanceMethodSignatureForSelector:selector]; \
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; \
invocation.selector = selector; \
\
NSLog(@"RunnerUITests.testInvocations(): selectorName = %@, signature: %@", dartTest, signature); \
NSLog(@"RunnerUITests.testInvocations(): selectorName = %@, signature: %@", dartTestName, signature); \
\
[invocations addObject:invocation]; \
} \
Expand Down

0 comments on commit 8818029

Please sign in to comment.