Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1743eab
Initial copy of e2e plugin renamed to espresso
collinjackson Nov 26, 2019
0bf791e
Switch to a new project based on template plugin
collinjackson Nov 26, 2019
f47c5a4
Update example app to be a button app
collinjackson Nov 26, 2019
45bf214
switch to Java
collinjackson Nov 26, 2019
195bb22
Add example Espresso test
collinjackson Nov 26, 2019
fded8ad
Midpoint check-in while addressing dependency errors
collinjackson Nov 26, 2019
60da0af
Demonstration of Espresso tests passing
collinjackson Nov 26, 2019
4f65053
All tests pass
collinjackson Nov 26, 2019
7c77635
Add shared preferences integration test
collinjackson Nov 26, 2019
86f133c
Fix test to match internal version
collinjackson Nov 26, 2019
02adfc8
Tests pass for shared prefs plugin
collinjackson Nov 26, 2019
f343591
Open source Espresso files
collinjackson Nov 26, 2019
521eb6c
License
collinjackson Dec 6, 2019
f2e0e56
SDK constraints
collinjackson Dec 6, 2019
6b86f04
Update README, changelog, remove test
collinjackson Dec 6, 2019
0b70161
Revert shared_preferences
collinjackson Dec 6, 2019
ce9de53
Update README.md
collinjackson Dec 7, 2019
cc2ebe5
Update README to make it clear this package is Android-only
collinjackson Dec 9, 2019
11b38af
Update licenses
collinjackson Dec 9, 2019
da89fee
Merge remote-tracking branch 'cj/new_espresso_plugin' into new_espres…
collinjackson Dec 9, 2019
211e358
remove commented dependencies
collinjackson Dec 9, 2019
b823741
More README updates
collinjackson Dec 9, 2019
5a1d274
Add a click test
collinjackson Dec 9, 2019
226a0d6
Fix build error
collinjackson Dec 9, 2019
2d0d9a1
More README updates
collinjackson Dec 9, 2019
0a2b5ab
fix file that wasn't meant to be checked in
collinjackson Dec 9, 2019
56360ff
Update README
collinjackson Dec 9, 2019
e3d340c
Merge remote-tracking branch 'origin/master' into new_espresso_plugin
collinjackson Dec 10, 2019
5377d27
Fix build failure
collinjackson Dec 10, 2019
8663ebd
Update README.md
collinjackson Dec 10, 2019
f69d012
Update README to clarify that iOS example is for the bots.
collinjackson Jan 9, 2020
a33410d
Code review feedback on plaintext traffic
collinjackson Jan 9, 2020
3a00269
Update README.md
collinjackson Jan 9, 2020
e5c1ae1
reformat
collinjackson Jan 9, 2020
5bf41b2
update pubspec.yaml
collinjackson Jan 9, 2020
9a85ad9
remove unused test
collinjackson Jan 9, 2020
d69e407
reformat
collinjackson Jan 9, 2020
6b6ff85
Merge remote-tracking branch 'origin/master' into new_espresso_plugin
collinjackson Jan 9, 2020
acef95e
Merge remote-tracking branch 'cj/new_espresso_plugin' into new_espres…
collinjackson Jan 9, 2020
a5a9c46
Fix analyzer issues
collinjackson Jan 9, 2020
8b6542b
fix ios build
collinjackson Jan 9, 2020
d18b2a0
remove lib/espresso.dart
collinjackson Jan 9, 2020
8129481
reformat
collinjackson Jan 9, 2020
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
Prev Previous commit
Next Next commit
reformat
  • Loading branch information
collinjackson committed Jan 9, 2020
commit e5c1ae1bccc13f4cbe9d58d5fc633e8cbb238d36
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ public void perform(UiController uiController, View flutterView) {
ListenableFuture<Void> testingProtocolReadyFuture =
JdkFutureAdapters.listenInPoolThread(flutterTestingProtocol.connect());
AsyncFunction<Void, Void> flutterIdleFunc =
new AsyncFunction<Void, Void>() {
public ListenableFuture<Void> apply(Void readyResult) {
return JdkFutureAdapters.listenInPoolThread(flutterTestingProtocol.waitUntilIdle());
}};
new AsyncFunction<Void, Void>() {
public ListenableFuture<Void> apply(Void readyResult) {
return JdkFutureAdapters.listenInPoolThread(flutterTestingProtocol.waitUntilIdle());
}
};
ListenableFuture<Void> flutterIdleFuture =
transformAsync(testingProtocolReadyFuture, flutterIdleFunc, taskExecutor);
loopUntilCompletion(FLUTTER_IDLE_TASK_NAME, uiController, flutterIdleFuture, taskExecutor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,29 @@ public Future<Void> connect() {
}

@Override
public Future<Void> perform(@Nullable final WidgetMatcher widgetMatcher, final SyntheticAction action) {
public Future<Void> perform(
@Nullable final WidgetMatcher widgetMatcher, final SyntheticAction action) {
// Assumes all the actions require a response.
ListenableFuture<JsonRpcResponse> responseFuture =
client.request(getActionRequest(widgetMatcher, action));
Function<JsonRpcResponse, Void> resultTransformFunc =
new Function<JsonRpcResponse, Void>() {
public Void apply(JsonRpcResponse response) {
if (response.getError() == null) {
return null;
} else {
// TODO(https://github.com/android/android-test/issues/251): Update error case handling
// like
// AmbiguousWidgetMatcherException, NoMatchingWidgetException after nailing down the
// design with
// Flutter team.
throw new RuntimeException(
String.format(
"Error occurred when performing the given action %s on widget matched %s",
action, widgetMatcher));
public Void apply(JsonRpcResponse response) {
if (response.getError() == null) {
return null;
} else {
// TODO(https://github.com/android/android-test/issues/251): Update error case handling
// like
// AmbiguousWidgetMatcherException, NoMatchingWidgetException after nailing down the
// design with
// Flutter team.
throw new RuntimeException(
String.format(
"Error occurred when performing the given action %s on widget matched %s",
action, widgetMatcher));
}
}
}};
};
return transform(responseFuture, resultTransformFunc, directExecutor());
}

Expand All @@ -149,12 +151,13 @@ public Future<WidgetInfo> matchWidget(@Nonnull WidgetMatcher widgetMatcher) {
ListenableFuture<JsonRpcResponse> jsonResponseFuture = client.request(request);

Function<JsonRpcResponse, WidgetInfo> widgetInfoTransformer =
new Function<JsonRpcResponse, WidgetInfo>() {
public WidgetInfo apply(JsonRpcResponse jsonResponse) {
GetWidgetDiagnosticsResponse widgetDiagnostics =
GetWidgetDiagnosticsResponse.fromJsonRpcResponse(jsonResponse);
return WidgetInfoFactory.createWidgetInfo(widgetDiagnostics);
}};
new Function<JsonRpcResponse, WidgetInfo>() {
public WidgetInfo apply(JsonRpcResponse jsonResponse) {
GetWidgetDiagnosticsResponse widgetDiagnostics =
GetWidgetDiagnosticsResponse.fromJsonRpcResponse(jsonResponse);
return WidgetInfoFactory.createWidgetInfo(widgetDiagnostics);
}
};
return transform(jsonResponseFuture, widgetInfoTransformer, directExecutor());
}

Expand All @@ -168,35 +171,36 @@ public Future<Rect> getLocalRect(@Nonnull WidgetMatcher widgetMatcher) {
ListenableFuture<List<JsonRpcResponse>> responses =
Futures.allAsList(topLeftFuture, bottomRightFuture);
Function<List<JsonRpcResponse>, Rect> rectTransformer =
new Function<List<JsonRpcResponse>, Rect>() {
public Rect apply(List<JsonRpcResponse> jsonResponses) {
GetOffsetResponse topLeft = GetOffsetResponse.fromJsonRpcResponse(jsonResponses.get(0));
GetOffsetResponse bottomRight =
GetOffsetResponse.fromJsonRpcResponse(jsonResponses.get(1));
checkState(
topLeft.getX() >= 0 && topLeft.getY() >= 0,
String.format(
"The relative coordinates [%.1f, %.1f] of a widget's top left vertex cannot be"
+ " negative (negative means it's off the outer Flutter view)!",
topLeft.getX(), topLeft.getY()));
checkState(
bottomRight.getX() >= 0 && bottomRight.getY() >= 0,
String.format(
"The relative coordinates [%.1f, %.1f] of a widget's bottom right vertex cannot"
+ " be negative (negative means it's off the outer Flutter view)!",
bottomRight.getX(), bottomRight.getY()));
checkState(
topLeft.getX() <= bottomRight.getX() && topLeft.getY() <= bottomRight.getY(),
String.format(
"The coordinates of the bottom right vertex [%.1f, %.1f] are not actually to the"
+ " bottom right of the top left vertex [%.1f, %.1f]!",
topLeft.getX(), topLeft.getY(), bottomRight.getX(), bottomRight.getY()));
return new Rect(
(int) topLeft.getX(),
(int) topLeft.getY(),
(int) bottomRight.getX(),
(int) bottomRight.getY());
}};
new Function<List<JsonRpcResponse>, Rect>() {
public Rect apply(List<JsonRpcResponse> jsonResponses) {
GetOffsetResponse topLeft = GetOffsetResponse.fromJsonRpcResponse(jsonResponses.get(0));
GetOffsetResponse bottomRight =
GetOffsetResponse.fromJsonRpcResponse(jsonResponses.get(1));
checkState(
topLeft.getX() >= 0 && topLeft.getY() >= 0,
String.format(
"The relative coordinates [%.1f, %.1f] of a widget's top left vertex cannot be"
+ " negative (negative means it's off the outer Flutter view)!",
topLeft.getX(), topLeft.getY()));
checkState(
bottomRight.getX() >= 0 && bottomRight.getY() >= 0,
String.format(
"The relative coordinates [%.1f, %.1f] of a widget's bottom right vertex cannot"
+ " be negative (negative means it's off the outer Flutter view)!",
bottomRight.getX(), bottomRight.getY()));
checkState(
topLeft.getX() <= bottomRight.getX() && topLeft.getY() <= bottomRight.getY(),
String.format(
"The coordinates of the bottom right vertex [%.1f, %.1f] are not actually to the"
+ " bottom right of the top left vertex [%.1f, %.1f]!",
topLeft.getX(), topLeft.getY(), bottomRight.getX(), bottomRight.getY()));
return new Rect(
(int) topLeft.getX(),
(int) topLeft.getY(),
(int) bottomRight.getX(),
(int) bottomRight.getY());
}
};
return transform(responses, rectTransformer, directExecutor());
}

Expand Down Expand Up @@ -234,9 +238,10 @@ public ListenableFuture<GetVmResponse> getVmInfo() {
ListenableFuture<JsonRpcResponse> jsonGetVmResp = client.request(getVmReq);
Function<JsonRpcResponse, GetVmResponse> jsonToResponse =
new Function<JsonRpcResponse, GetVmResponse>() {
public GetVmResponse apply(JsonRpcResponse jsonResp) {
return GetVmResponse.fromJsonRpcResponse(jsonResp);
}};
public GetVmResponse apply(JsonRpcResponse jsonResp) {
return GetVmResponse.fromJsonRpcResponse(jsonResp);
}
};
return transform(jsonGetVmResp, jsonToResponse, directExecutor());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
public class EspressoPlugin implements FlutterPlugin, MethodCallHandler {
@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
final MethodChannel channel = new MethodChannel(flutterPluginBinding.getFlutterEngine().getDartExecutor(), "espresso");
final MethodChannel channel =
new MethodChannel(flutterPluginBinding.getFlutterEngine().getDartExecutor(), "espresso");
channel.setMethodCallHandler(new EspressoPlugin());
}

Expand Down Expand Up @@ -40,6 +41,5 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
}

@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
}
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {}
}
2 changes: 1 addition & 1 deletion packages/espresso/ios/Classes/EspressoPlugin.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import <Flutter/Flutter.h>

@interface EspressoPlugin : NSObject<FlutterPlugin>
@interface EspressoPlugin : NSObject <FlutterPlugin>
@end
3 changes: 1 addition & 2 deletions packages/espresso/lib/espresso.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import 'dart:async';
import 'package:flutter/services.dart';

class Espresso {
static const MethodChannel _channel =
const MethodChannel('espresso');
static const MethodChannel _channel = const MethodChannel('espresso');

static Future<String> get platformVersion async {
final String version = await _channel.invokeMethod('getPlatformVersion');
Expand Down