Skip to content

Commit 7a5533c

Browse files
authored
Updated to EarlGrey 1.15.0 (wix#895)
* Updated to EarlGrey 1.15.0
1 parent 234d611 commit 7a5533c

File tree

9 files changed

+78
-154
lines changed

9 files changed

+78
-154
lines changed

detox/ios/EarlGrey

Submodule EarlGrey updated 327 files

detox/src/client/Client.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const AsyncWebSocket = require('./AsyncWebSocket');
22
const actions = require('./actions/actions');
33
const argparse = require('../utils/argparse');
4-
const retry = require('../utils/retry');
54

65
class Client {
76
constructor(config) {
@@ -70,13 +69,13 @@ class Client {
7069

7170
// when this test run fails, we want a stack trace from up here where the
7271
// $callee is still available, and not inside the catch block where it isn't
73-
const potentialError = new Error()
72+
const potentialError = new Error();
7473

7574
try {
7675
await this.sendAction(new actions.Invoke(invocation));
7776
} catch (err) {
7877
this.successfulTestRun = false;
79-
potentialError.message = err
78+
potentialError.message = err;
8079
throw potentialError;
8180
}
8281
clearTimeout(this.slowInvocationStatusHandler);

detox/src/devices/drivers/IosDriver.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const InvocationManager = require('../../invoke').InvocationManager;
66
const invoke = require('../../invoke');
77
const GREYConfigurationApi = require('../../ios/earlgreyapi/GREYConfiguration');
88
const GREYConfigurationDetox = require('../../ios/earlgreyapi/GREYConfigurationDetox');
9-
const EarlyGrey = require('../../ios/earlgreyapi/EarlGrey');
9+
const EarlyGreyImpl = require('../../ios/earlgreyapi/EarlGreyImpl');
1010

1111
class IosDriver extends DeviceDriverBase {
1212
constructor(config) {
@@ -57,8 +57,7 @@ class IosDriver extends DeviceDriverBase {
5757
}
5858

5959
async setOrientation(deviceId, orientation) {
60-
const call = EarlyGrey.rotateDeviceToOrientationErrorOrNil(invoke.EarlGrey.instance,orientation);
61-
60+
const call = EarlyGreyImpl.rotateDeviceToOrientationErrorOrNil(invoke.EarlGrey.instance,orientation);
6261
await this.client.execute(call);
6362
}
6463

detox/src/ios/earlgreyapi/EarlGrey.js renamed to detox/src/ios/earlgreyapi/EarlGreyImpl.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ failure will be reported if the rotation attempt fails.
6363
};
6464
}
6565

66+
/*Shakes the device. If a non-nil @c errorOrNil is provided, it will
67+
be populated with the failure reason if the orientation change fails, otherwise a test failure
68+
will be registered.
69+
70+
@param[out] errorOrNil Error that will be populated on failure. If @c nil, the a test
71+
failure will be reported if the shake attempt fails.
72+
73+
@throws GREYFrameworkException if the action fails and @c errorOrNil is @c nil.
74+
@return @c YES if the shake was successful, @c NO otherwise. If @c errorOrNil is @c nil and
75+
the operation fails, it will throw an exception.
76+
*/static shakeDeviceWithError(element) {
77+
return {
78+
target: element,
79+
method: "shakeDeviceWithError:",
80+
args: []
81+
};
82+
}
83+
6684
/*Dismisses the keyboard by resigning the first responder, if any. Will populate the provided
6785
error if the first responder is not present or if the keyboard is not visible.
6886

detox/src/ios/earlgreyapi/GREYInteraction.js

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ will be performed on.
2626
};
2727
}
2828

29-
/*Performs the @c action repeatedly on the the element matching the @c matcher until the element
29+
/*Performs the @c action repeatedly on the element matching the @c matcher until the element
3030
to interact with (specified by GREYInteraction::selectElementWithMatcher:) is found or a
3131
timeout occurs. The search action is only performed when coupled with
3232
GREYInteraction::performAction:, GREYInteraction::assert:, or
@@ -81,26 +81,6 @@ performAction:grey_tap()] // This should be separately called for the action.
8181
};
8282
}
8383

84-
/*Performs an @c action on the selected UI element with an error set on failure.
85-
86-
@param action The action to be performed on the @c element.
87-
@param[out] errorOrNil Error populated on failure.
88-
@throws NSException on action failure if @c errorOrNil is not set.
89-
90-
@return The provided GREYInteraction instance, with an action and an error that will be
91-
populated on failure.
92-
*/static performActionError(element, action) {
93-
if (typeof action !== "object" || action.type !== "Invocation" || typeof action.value !== "object" || typeof action.value.target !== "object" || action.value.target.value !== "GREYActions") {
94-
throw new Error('action should be a GREYAction, but got ' + JSON.stringify(action));
95-
}
96-
97-
return {
98-
target: element,
99-
method: "performAction:error:",
100-
args: [action]
101-
};
102-
}
103-
10484
/*Performs an assertion that evaluates @c matcher on the selected UI element.
10585
10686
@param matcher The matcher to be evaluated on the @c element.
@@ -118,26 +98,6 @@ populated on failure.
11898
};
11999
}
120100

121-
/*Performs an assertion that evaluates @c matcher on the selected UI element.
122-
123-
@param matcher The matcher to be evaluated on the @c element.
124-
@param[out] errorOrNil Error populated on failure.
125-
@throws NSException on assertion failure if @c errorOrNil is not set.
126-
127-
@return The provided GREYInteraction instance, with a matcher to be evaluated on an element and
128-
an error that will be populated on failure.
129-
*/static assertWithMatcherError(element, matcher) {
130-
if (typeof matcher !== "object" || matcher.type !== "Invocation" || typeof matcher.value !== "object" || typeof matcher.value.target !== "object" || matcher.value.target.value !== "GREYMatchers") {
131-
throw new Error('matcher should be a GREYMatcher, but got ' + JSON.stringify(matcher));
132-
}
133-
134-
return {
135-
target: element,
136-
method: "assertWithMatcher:error:",
137-
args: [matcher]
138-
};
139-
}
140-
141101
/*In case of multiple matches, selects the element at the specified index. In case of the
142102
index being over the number of matched elements, it throws an exception. Please make sure
143103
that this is used after you've created the matcher. For example, in case three elements are

detox/src/ios/earlgreyapi/GREYMatchers.js

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,13 @@ unimplemented matcher is required, please implement it similar to @c grey_closeT
373373
};
374374
}
375375

376-
/*Matcher that matches UI element based on the presence of an ancestor in its hierarchy.
377-
The given matcher is used to match decendants.
376+
/*Matcher that matches any UI element with an ancestor matching the given @c ancestorMatcher.
378377
379-
@param ancestorMatcher The ancestor UI element whose descendants are to be matched.
378+
@param ancestorMatcher A matcher that's run against the ancestors of the UI element being
379+
matched.
380380
381-
@return A matcher to check if a UI element is the descendant of another.
381+
@return A matcher to check if a specified element has an ancestor that matches
382+
@c ancestorMatcher.
382383
*/static matcherForAncestor(ancestorMatcher) {
383384
if (typeof ancestorMatcher !== "object" || ancestorMatcher.type !== "Invocation" || typeof ancestorMatcher.value !== "object" || typeof ancestorMatcher.value.target !== "object" || ancestorMatcher.value.target.value !== "GREYMatchers") {
384385
throw new Error('ancestorMatcher should be a GREYMatcher, but got ' + JSON.stringify(ancestorMatcher));
@@ -394,12 +395,13 @@ The given matcher is used to match decendants.
394395
};
395396
}
396397

397-
/*Matcher that matches any UI element with a descendant matching the given matcher.
398+
/*Matcher that matches any UI element with a descendant matching the given @c descendantMatcher.
398399
399-
@param descendantMatcher A matcher being checked to be a descendant
400-
of the UI element being checked.
400+
@param descendantMatcher A matcher that's run against the descendants of the UI element being
401+
matched.
401402
402-
@return A matcher to check if a the specified element is in a descendant of another UI element.
403+
@return A matcher to check if a specified element has a descendant that matches
404+
@c descendantMatcher.
403405
*/static matcherForDescendant(descendantMatcher) {
404406
if (typeof descendantMatcher !== "object" || descendantMatcher.type !== "Invocation" || typeof descendantMatcher.value !== "object" || typeof descendantMatcher.value.target !== "object" || descendantMatcher.value.target.value !== "GREYMatchers") {
405407
throw new Error('descendantMatcher should be a GREYMatcher, but got ' + JSON.stringify(descendantMatcher));
@@ -485,31 +487,6 @@ is required, please implement it similar to @c grey_closeTo.
485487
};
486488
}
487489

488-
/*Matcher that matches UIPickerView that has a column set to @c value.
489-
490-
@param column The column of the UIPickerView to be matched.
491-
@param value The value that should be set in the column of the UIPickerView.
492-
493-
@return A matcher to check the value in a particular column of a UIPickerView.
494-
*/static matcherForPickerColumnSetToValue(column, value) {
495-
if (typeof column !== "number") throw new Error("column should be a number, but got " + (column + (" (" + (typeof column + ")"))));
496-
if (typeof value !== "string") throw new Error("value should be a string, but got " + (value + (" (" + (typeof value + ")"))));
497-
return {
498-
target: {
499-
type: "Class",
500-
value: "GREYMatchers"
501-
},
502-
method: "matcherForPickerColumn:setToValue:",
503-
args: [{
504-
type: "NSInteger",
505-
value: column
506-
}, {
507-
type: "NSString",
508-
value: value
509-
}]
510-
};
511-
}
512-
513490
/*Matcher that verifies whether an element, that is a UIControl, is enabled.
514491
515492
@return A matcher for checking whether a UI element is an enabled UIControl.

detox/test/ios/example.xcodeproj/project.pbxproj

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -244,20 +244,6 @@
244244
remoteGlobalIDString = 394767961DBF985400D72256;
245245
remoteInfo = Detox;
246246
};
247-
4613EAA72051F21100C6DF2D /* PBXContainerItemProxy */ = {
248-
isa = PBXContainerItemProxy;
249-
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
250-
proxyType = 2;
251-
remoteGlobalIDString = EBF21BDC1FC498900052F4D5;
252-
remoteInfo = jsinspector;
253-
};
254-
4613EAA92051F21100C6DF2D /* PBXContainerItemProxy */ = {
255-
isa = PBXContainerItemProxy;
256-
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
257-
proxyType = 2;
258-
remoteGlobalIDString = EBF21BFA1FC4989A0052F4D5;
259-
remoteInfo = "jsinspector-tvOS";
260-
};
261247
4613EAAB2051F21100C6DF2D /* PBXContainerItemProxy */ = {
262248
isa = PBXContainerItemProxy;
263249
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
@@ -519,8 +505,6 @@
519505
39A34C5D1E30ED3600BEBB59 /* libcxxreact.a */,
520506
39A34C5F1E30ED3600BEBB59 /* libjschelpers.a */,
521507
39A34C611E30ED3600BEBB59 /* libjschelpers.a */,
522-
4613EAA82051F21100C6DF2D /* libjsinspector.a */,
523-
4613EAAA2051F21100C6DF2D /* libjsinspector-tvOS.a */,
524508
4644B8651F897583003223D4 /* libthird-party.a */,
525509
4644B8671F897583003223D4 /* libthird-party.a */,
526510
4644B8691F897583003223D4 /* libdouble-conversion.a */,
@@ -948,20 +932,6 @@
948932
remoteRef = 39B044611DAED76400431EC5 /* PBXContainerItemProxy */;
949933
sourceTree = BUILT_PRODUCTS_DIR;
950934
};
951-
4613EAA82051F21100C6DF2D /* libjsinspector.a */ = {
952-
isa = PBXReferenceProxy;
953-
fileType = archive.ar;
954-
path = libjsinspector.a;
955-
remoteRef = 4613EAA72051F21100C6DF2D /* PBXContainerItemProxy */;
956-
sourceTree = BUILT_PRODUCTS_DIR;
957-
};
958-
4613EAAA2051F21100C6DF2D /* libjsinspector-tvOS.a */ = {
959-
isa = PBXReferenceProxy;
960-
fileType = archive.ar;
961-
path = "libjsinspector-tvOS.a";
962-
remoteRef = 4613EAA92051F21100C6DF2D /* PBXContainerItemProxy */;
963-
sourceTree = BUILT_PRODUCTS_DIR;
964-
};
965935
4613EAAC2051F21100C6DF2D /* libprivatedata.a */ = {
966936
isa = PBXReferenceProxy;
967937
fileType = archive.ar;
@@ -1082,7 +1052,7 @@
10821052
);
10831053
runOnlyForDeploymentPostprocessing = 0;
10841054
shellPath = /bin/sh;
1085-
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
1055+
shellScript = "../node_modules/react-native/scripts/react-native-xcode.sh";
10861056
};
10871057
/* End PBXShellScriptBuildPhase section */
10881058

generation/index.js

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,48 @@ const iosFiles = {
2121
"../detox/src/ios/earlgreyapi/GREYConfigurationDetox.js",
2222
"../detox/ios/EarlGrey/EarlGrey/Common/GREYConfiguration.h":
2323
"../detox/src/ios/earlgreyapi/GREYConfiguration.js",
24-
"../detox/ios/EarlGrey/EarlGrey/EarlGrey.h":
25-
"../detox/src/ios/earlgreyapi/EarlGrey.js"
24+
"../detox/ios/EarlGrey/EarlGrey/Core/EarlGreyImpl.h":
25+
"../detox/src/ios/earlgreyapi/EarlGreyImpl.js"
2626
};
2727

2828
generateIOSAdapters(iosFiles);
29-
const espressoFilesToDownload = {
30-
"android.support.test.espresso.action.ViewActions":
31-
"../detox/src/android/espressoapi/ViewActions.js"
32-
};
33-
34-
const downloadedEspressoFilesMap = Object.entries(
35-
espressoFilesToDownload
36-
).reduce(
37-
(obj, [fullyQualifiedClass, dest]) => ({
38-
...obj,
39-
[downloadEspressoFileByClass(fullyQualifiedClass)]: dest
40-
}),
41-
{}
42-
);
43-
44-
const externalFilesToDownload = {
45-
'https://android.googlesource.com/platform/frameworks/uiautomator/+/master/src/com/android/uiautomator/core/UiDevice.java?format=TEXT': '../detox/src/android/espressoapi/UIDevice.js'
46-
}
47-
48-
const downloadedAndroidFilesMap = Object.entries(
49-
externalFilesToDownload
50-
).reduce(
51-
(obj, [url, dest]) => ({
52-
...obj,
53-
[downloadFile(url)]: dest
54-
}),
55-
{}
56-
);
57-
58-
const androidFiles = {
59-
...downloadedAndroidFilesMap,
60-
...downloadedEspressoFilesMap,
61-
'../detox/android/detox/src/main/java/com/wix/detox/espresso/DetoxAction.java': '../detox/src/android/espressoapi/DetoxAction.js',
62-
'../detox/android/detox/src/main/java/com/wix/detox/espresso/DetoxMatcher.java': '../detox/src/android/espressoapi/DetoxMatcher.js',
63-
'../detox/android/detox/src/main/java/com/wix/detox/Detox.java': '../detox/src/android/espressoapi/Detox.js',
64-
'../detox/android/detox/src/main/java/com/wix/detox/espresso/EspressoDetox.java': '../detox/src/android/espressoapi/EspressoDetox.js',
65-
'../detox/android/detox/src/main/java/com/wix/detox/uiautomator/UiAutomator.java': '../detox/src/android/espressoapi/UIAutomator.js',
66-
};
67-
generateAndroidAdapters(androidFiles);
29+
//TODO - network failing on CI, check ASAP
30+
// const espressoFilesToDownload = {
31+
// "android.support.test.espresso.action.ViewActions":
32+
// "../detox/src/android/espressoapi/ViewActions.js"
33+
// };
34+
//
35+
// const downloadedEspressoFilesMap = Object.entries(
36+
// espressoFilesToDownload
37+
// ).reduce(
38+
// (obj, [fullyQualifiedClass, dest]) => ({
39+
// ...obj,
40+
// [downloadEspressoFileByClass(fullyQualifiedClass)]: dest
41+
// }),
42+
// {}
43+
// );
44+
//
45+
// const externalFilesToDownload = {
46+
// 'https://android.googlesource.com/platform/frameworks/uiautomator/+/master/src/com/android/uiautomator/core/UiDevice.java?format=TEXT': '../detox/src/android/espressoapi/UIDevice.js'
47+
// }
48+
//
49+
// const downloadedAndroidFilesMap = Object.entries(
50+
// externalFilesToDownload
51+
// ).reduce(
52+
// (obj, [url, dest]) => ({
53+
// ...obj,
54+
// [downloadFile(url)]: dest
55+
// }),
56+
// {}
57+
// );
58+
//
59+
// const androidFiles = {
60+
// ...downloadedAndroidFilesMap,
61+
// ...downloadedEspressoFilesMap,
62+
// '../detox/android/detox/src/main/java/com/wix/detox/espresso/DetoxAction.java': '../detox/src/android/espressoapi/DetoxAction.js',
63+
// '../detox/android/detox/src/main/java/com/wix/detox/espresso/DetoxMatcher.java': '../detox/src/android/espressoapi/DetoxMatcher.js',
64+
// '../detox/android/detox/src/main/java/com/wix/detox/Detox.java': '../detox/src/android/espressoapi/Detox.js',
65+
// '../detox/android/detox/src/main/java/com/wix/detox/espresso/EspressoDetox.java': '../detox/src/android/espressoapi/EspressoDetox.js',
66+
// '../detox/android/detox/src/main/java/com/wix/detox/uiautomator/UiAutomator.java': '../detox/src/android/espressoapi/UIAutomator.js',
67+
// };
68+
// generateAndroidAdapters(androidFiles);

generation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"babel-types": "6.25.0",
2727
"download-file-sync": "1.0.4",
2828
"java-method-parser": "0.4.7",
29-
"objective-c-parser": "1.2.3",
29+
"objective-c-parser": "1.2.4",
3030
"remove": "0.1.5",
3131
"uuid": "^3.2.1"
3232
},

0 commit comments

Comments
 (0)