Skip to content

Commit

Permalink
add replace action to generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMSchmidt committed Jan 8, 2018
1 parent 771819a commit 3fb0c54
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
15 changes: 15 additions & 0 deletions detox/src/android/espressoapi/ViewActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,21 @@ class ViewActions {
};
}

static replaceText(stringToBeSet) {
if (typeof stringToBeSet !== "string") throw new Error("stringToBeSet should be a string, but got " + (stringToBeSet + (" (" + (typeof stringToBeSet + ")"))));
return {
target: {
type: "Class",
value: "android.support.test.espresso.action.ViewActions"
},
method: "replaceText",
args: [{
type: "String",
value: stringToBeSet
}]
};
}

static openLinkWithText(linkText) {
if (typeof linkText !== "string") throw new Error("linkText should be a string, but got " + (linkText + (" (" + (typeof linkText + ")"))));
return {
Expand Down
4 changes: 1 addition & 3 deletions detox/src/android/expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function setInvocationManager(im) {
invocationManager = im;
}

const ViewActions = 'android.support.test.espresso.action.ViewActions';
const ViewAssertions = 'android.support.test.espresso.assertion.ViewAssertions';
const DetoxMatcher = 'com.wix.detox.espresso.DetoxMatcher';
const DetoxAction = 'com.wix.detox.espresso.DetoxAction';
Expand Down Expand Up @@ -67,8 +66,7 @@ class TypeTextAction extends Action {
class ReplaceTextAction extends Action {
constructor(value) {
super();
if (typeof value !== 'string') throw new Error(`ReplaceTextAction ctor argument must be a string, got ${typeof value}`);
this._call = invoke.call(invoke.Android.Class(ViewActions), 'replaceText', value);
this._call = invoke.callDirectly(ViewActionsApi.replaceText(value));
}
}

Expand Down
2 changes: 1 addition & 1 deletion generation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
"dependencies": {
"babel-generate-guard-clauses": "^2.0.0",
"babel-template": "^6.26.0",
"java-method-parser": "^0.4.2"
"java-method-parser": "^0.4.3"
}
}

0 comments on commit 3fb0c54

Please sign in to comment.