Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native skip #2278

Merged
merged 10 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ public void runDartTest() {
PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation();
instrumentation.runDartTest(dartTestName);
}
}
}
30 changes: 30 additions & 0 deletions dev/e2e_app/integration_test/android_app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,34 @@ void main() {

await $.native.pressBack();
});

patrol('taps around 2', skip: true, ($) async {
await createApp($);

await $.native.pressHome();
await $.native.pressDoubleRecentApps();

await $.native.openNotifications();

await $.native.enableWifi();
await $.native.disableWifi();
await $.native.enableWifi();

await $.native.enableCellular();
await $.native.disableCellular();
await $.native.enableCellular();

await $.native.enableDarkMode();
await $.native.disableDarkMode();
await $.native.enableDarkMode();

await $.native.pressBack();
});

patrol('taps around 3', ($) async {
await createApp($);

await $.native.pressHome();
await $.native.pressDoubleRecentApps();
});
}
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,
);
});
}
25 changes: 25 additions & 0 deletions dev/e2e_app/integration_test/open_app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,31 @@ void main() {
expect($(#counterText).text, '1');
});

patrol('same open maps test that should be skipped', skip: true, ($) async {
final String mapsId;
if (io.Platform.isIOS) {
mapsId = 'com.apple.Maps';
} else if (io.Platform.isAndroid) {
mapsId = 'com.google.android.apps.maps';
} else {
throw UnsupportedError('Unsupported platform');
}

await createApp($);
await $.waitUntilVisible($(#counterText));

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

await $(FloatingActionButton).tap();

await $.native.pressHome();
await $.native.openApp(appId: mapsId);
await $.native.pressHome();
await $.native.openApp();

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

patrol('open browser', ($) async {
final String browserId;
if (io.Platform.isIOS) {
Expand Down
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
1 change: 1 addition & 0 deletions packages/patrol/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Implement `enableAirplaneMode` and `disableAirplaneMode` methods for Android. (#2254)
- Implement `enableLocation` and `disableLocation` methods for Android. (#2259)
- Fix opening settings app with clean state on iOS. (#2275)
- Add native skip. (#2278)

## 3.9.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package pl.leancode.patrol;

import static org.junit.Assume.*;

import android.app.Instrumentation;
import android.content.Intent;
import android.os.Bundle;
Expand All @@ -16,7 +18,9 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;

import static pl.leancode.patrol.contracts.Contracts.DartGroupEntry;
Expand All @@ -29,6 +33,7 @@
*/
public class PatrolJUnitRunner extends AndroidJUnitRunner {
public PatrolAppServiceClient patrolAppServiceClient;
private Map<String, Boolean> dartTestCaseSkipMap = new HashMap<>();

@Override
protected boolean shouldWaitForActivitiesToComplete() {
Expand Down Expand Up @@ -110,6 +115,7 @@ public Object[] listDartTests() {
List<DartGroupEntry> dartTestCases = ContractsExtensionsKt.listTestsFlat(dartTestGroup, "");
List<String> dartTestCaseNamesList = new ArrayList<>();
for (DartGroupEntry dartTestCase : dartTestCases) {
dartTestCaseSkipMap.put(dartTestCase.getName(), dartTestCase.getSkip());
dartTestCaseNamesList.add(dartTestCase.getName());
}
Object[] dartTestCaseNames = dartTestCaseNamesList.toArray();
Expand All @@ -127,6 +133,12 @@ public Object[] listDartTests() {
*/
public RunDartTestResponse runDartTest(String name) {
final String TAG = "PatrolJUnitRunner.runDartTest(" + name + "): ";

final Boolean skip = dartTestCaseSkipMap.get(name);
if (skip) {
Logger.INSTANCE.i(TAG + "Test skipped");
assumeFalse(skip);
}

try {
Logger.INSTANCE.i(TAG + "Requested execution");
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ fun dartTestGroup(
name: String,
entries: List<DartGroupEntry>,
): DartGroupEntry {
return DartGroupEntry(name, GroupEntryType.group, entries)
return DartGroupEntry(name, GroupEntryType.group, entries, false)
}

fun dartTestCase(name: String): DartGroupEntry {
return DartGroupEntry(name, GroupEntryType.test, listOf())
return DartGroupEntry(name, GroupEntryType.test, listOf(), false)
}

class DartTestGroupExtensionsTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public struct DartGroupEntry: Codable {
public var name: String
public var type: GroupEntryType
public var entries: [DartGroupEntry]
public var skip: Bool
}

public struct ListDartTestsResponse: Codable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ class PatrolAppServiceClient {
urlconfig.timeoutIntervalForRequest = timeout
urlconfig.timeoutIntervalForResource = timeout

urlconfig.connectionProxyDictionary = [
kCFNetworkProxiesHTTPEnable: false
]

var request = URLRequest(url: url)
request.httpMethod = "POST"
request.httpBody = body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@
NSLog("PatrolAppServiceClient: created, port: \(port)")
}

@objc public func listDartTests(completion: @escaping ([String]?, Error?) -> Void) {
@objc public func listDartTests(completion: @escaping ([[String: Any]]?, Error?) -> Void) {
NSLog("PatrolAppServiceClient.listDartTests()")

client.listDartTests { result in
switch result {
case .success(let result):
NSLog("PatrolAppServiceClient.listDartTests(): succeeded")
let output = result.group.listTestsFlat(parentGroupName: "").map {
$0.name
["name": $0.name, "skip": $0.skip]
}
completion(output, nil)
case .failure(let error):
Expand Down
Loading
Loading