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

Generation: Add Android Matchers to generated code #492

Merged
merged 1 commit into from
Jan 9, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
67 changes: 67 additions & 0 deletions detox/src/android/espressoapi/DetoxMatcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**

This code is generated.
For more information see generation/README.md.
*/



class DetoxMatcher {
static matcherForSufficientlyVisible() {
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxMatcher"
},
method: "matcherForSufficientlyVisible",
args: []
};
}

static matcherForNotVisible() {
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxMatcher"
},
method: "matcherForNotVisible",
args: []
};
}

static matcherForNotNull() {
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxMatcher"
},
method: "matcherForNotNull",
args: []
};
}

static matcherForNull() {
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxMatcher"
},
method: "matcherForNull",
args: []
};
}

static matcherForAnything() {
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxMatcher"
},
method: "matcherForAnything",
args: []
};
}

}

module.exports = DetoxMatcher;
13 changes: 7 additions & 6 deletions detox/src/android/matcher.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const invoke = require('../invoke');
const DetoxMatcherApi = require('./espressoapi/DetoxMatcher');

const DetoxMatcher = 'com.wix.detox.espresso.DetoxMatcher';

Expand Down Expand Up @@ -77,28 +78,28 @@ class TypeMatcher extends Matcher {
class VisibleMatcher extends Matcher {
constructor() {
super();
this._call = invoke.call(invoke.Android.Class(DetoxMatcher), 'matcherForSufficientlyVisible');
this._call = invoke.callDirectly(DetoxMatcherApi.matcherForSufficientlyVisible());
}
}

class NotVisibleMatcher extends Matcher {
constructor() {
super();
this._call = invoke.call(invoke.Android.Class(DetoxMatcher), 'matcherForNotVisible');
this._call = invoke.callDirectly(DetoxMatcherApi.matcherForNotVisible());
}
}

class ExistsMatcher extends Matcher {
constructor() {
super();
this._call = invoke.call(invoke.Android.Class(DetoxMatcher), 'matcherForNotNull');
this._call = invoke.callDirectly(DetoxMatcherApi.matcherForNotNull());
}
}

class NotExistsMatcher extends Matcher {
constructor() {
super();
this._call = invoke.call(invoke.Android.Class(DetoxMatcher), 'matcherForNull');
this._call = invoke.callDirectly(DetoxMatcherApi.matcherForNull());
}
}

Expand All @@ -124,8 +125,8 @@ class TraitsMatcher extends Matcher {
constructor(value) {
super();
if ((typeof value !== 'object') || (!value instanceof Array)) throw new Error(`TraitsMatcher ctor argument must be an array, got ${typeof value}`);
this._call = invoke.call(invoke.Android.Class(DetoxMatcher), 'matcherForAnything');

this._call = invoke.callDirectly(DetoxMatcherApi.matcherForAnything());
}
}

Expand Down
16 changes: 11 additions & 5 deletions generation/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#!/usr/bin/env node
const generateIOSAdapters = require("./adapters/ios");
const iosFiles = {
"../detox/ios/EarlGrey/EarlGrey/Action/GREYActions.h": "../detox/src/ios/earlgreyapi/GREYActions.js",
"../detox/ios/Detox/GREYMatchers+Detox.h": "../detox/src/ios/earlgreyapi/GREYMatchers+Detox.js",
"../detox/ios/EarlGrey/EarlGrey/Matcher/GREYMatchers.h": "../detox/src/ios/earlgreyapi/GREYMatchers.js",
"../detox/ios/EarlGrey/EarlGrey/Action/GREYActions.h":
"../detox/src/ios/earlgreyapi/GREYActions.js",
"../detox/ios/Detox/GREYMatchers+Detox.h":
"../detox/src/ios/earlgreyapi/GREYMatchers+Detox.js",
"../detox/ios/EarlGrey/EarlGrey/Matcher/GREYMatchers.h":
"../detox/src/ios/earlgreyapi/GREYMatchers.js"
};

generateIOSAdapters(iosFiles);

const generateAndroidAdapters = require("./adapters/android");
const androidFiles = {
"../detox/android/detox/src/main/java/com/wix/detox/espresso/DetoxAction.java": "../detox/src/android/espressoapi/DetoxAction.js"
"../detox/android/detox/src/main/java/com/wix/detox/espresso/DetoxAction.java":
"../detox/src/android/espressoapi/DetoxAction.js",
"../detox/android/detox/src/main/java/com/wix/detox/espresso/DetoxMatcher.java":
"../detox/src/android/espressoapi/DetoxMatcher.js"
};
generateAndroidAdapters(androidFiles);
generateAndroidAdapters(androidFiles);
2 changes: 1 addition & 1 deletion generation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
"dependencies": {
"babel-generate-guard-clauses": "^2.0.0",
"babel-template": "^6.26.0",
"java-method-parser": "^0.4.0"
"java-method-parser": "^0.4.5"
}
}