-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move GREYConfiguration to generated code (wix#693)
* move GREYConfiguration to generated code * refactor GREYConfiguration callees to use generated APIs * rename GREYConfigurationApi to GREYConfiguration
- Loading branch information
1 parent
6cf3963
commit 2f6dca7
Showing
8 changed files
with
304 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,179 @@ | ||
/** | ||
const invoke = require('../../invoke'); | ||
This code is generated. | ||
For more information see generation/README.md. | ||
*/ | ||
|
||
/** | ||
* An 'invoke' wrapper for https://github.com/google/EarlGrey/blob/master/EarlGrey/Common/GREYConfiguration.h | ||
*/ | ||
|
||
/** | ||
* | ||
* @param blacklist - array of regular expressions, every matched URL will be ignored. example: [".*www\\.google\\.com", ".*www\\.youtube\\.com"] | ||
* @returns {*} | ||
*/ | ||
function setURLBlacklist(blacklist) { | ||
return setValueForConfigKey(blacklist, 'GREYConfigKeyURLBlacklistRegex'); | ||
} | ||
|
||
function enableSynchronization() { | ||
//return setValueForConfigKey(invoke.IOS.Boolean(true), 'kGREYConfigKeySynchronizationEnabled'); | ||
return invoke.call(GREYConfigurationInstance(), 'enableSynchronization'); | ||
} | ||
class GREYConfiguration { | ||
/*@return The singleton GREYConfiguration instance. | ||
*/static sharedInstance() { | ||
return { | ||
target: { | ||
type: "Class", | ||
value: "GREYConfiguration" | ||
}, | ||
method: "sharedInstance", | ||
args: [] | ||
}; | ||
} | ||
|
||
function disableSynchronization() { | ||
//return setValueForConfigKey(invoke.IOS.Boolean(false), 'kGREYConfigKeySynchronizationEnabled'); | ||
return invoke.call(GREYConfigurationInstance(), 'disableSynchronization'); | ||
} | ||
/*If a user-configured value is associated with the given @c configKey, it is returned, | ||
otherwise the default value is returned. If a default value is not found, or an | ||
NSInvalidArgumentException is raised. | ||
function setValueForConfigKey(value, configKey) { | ||
return invoke.call(GREYConfigurationInstance(), 'setValue:forConfigKey:', value, configKey); | ||
} | ||
@param configKey The key whose value is being queried. Must be a valid @c NSString. | ||
@throws NSInvalidArgumentException If no value could be found associated with @c configKey. | ||
@return The value for the configuration stored associate with @c configKey. | ||
*/static valueForConfigKey(element, configKey) { | ||
if (typeof configKey !== "string") throw new Error("configKey should be a string, but got " + (configKey + (" (" + (typeof configKey + ")")))); | ||
return { | ||
target: { | ||
type: "Invocation", | ||
value: element | ||
}, | ||
method: "valueForConfigKey:", | ||
args: [{ | ||
type: "NSString", | ||
value: configKey | ||
}] | ||
}; | ||
} | ||
|
||
/*If a user-configured value is associated with the given @c configKey, it is returned, otherwise | ||
the default value is returned. If a default value is not found, NSInvalidArgumentException is | ||
raised. | ||
@param configKey The key whose value is being queried. Must be a valid @c NSString. | ||
@throws NSInvalidArgumentException If no value could be found for the given @c configKey. | ||
@return The @c BOOL value for the configuration associated with @c configKey. | ||
*/static boolValueForConfigKey(element, configKey) { | ||
if (typeof configKey !== "string") throw new Error("configKey should be a string, but got " + (configKey + (" (" + (typeof configKey + ")")))); | ||
return { | ||
target: { | ||
type: "Invocation", | ||
value: element | ||
}, | ||
method: "boolValueForConfigKey:", | ||
args: [{ | ||
type: "NSString", | ||
value: configKey | ||
}] | ||
}; | ||
} | ||
|
||
/*If a user-configured value is associated with the given @c configKey, it is returned, otherwise | ||
the default value is returned. If a default value is not found, NSInvalidArgumentException is | ||
raised. | ||
@param configKey The key whose value is being queried. Must be a valid @c NSString. | ||
@throws NSInvalidArgumentException If no value could be found for the given @c configKey. | ||
@return The integer value for the configuration associated with @c configKey. | ||
*/static integerValueForConfigKey(element, configKey) { | ||
if (typeof configKey !== "string") throw new Error("configKey should be a string, but got " + (configKey + (" (" + (typeof configKey + ")")))); | ||
return { | ||
target: { | ||
type: "Invocation", | ||
value: element | ||
}, | ||
method: "integerValueForConfigKey:", | ||
args: [{ | ||
type: "NSString", | ||
value: configKey | ||
}] | ||
}; | ||
} | ||
|
||
/*If a user-configured value is associated with the given @c configKey, it is returned, otherwise | ||
the default value is returned. If a default value is not found, NSInvalidArgumentException is | ||
raised. | ||
@param configKey The key whose value is being queried. Must be a valid @c NSString. | ||
@throws NSInvalidArgumentException If no value could be found for the given @c configKey. | ||
@return The @c double value for the configuration associated with @c configKey. | ||
*/static doubleValueForConfigKey(element, configKey) { | ||
if (typeof configKey !== "string") throw new Error("configKey should be a string, but got " + (configKey + (" (" + (typeof configKey + ")")))); | ||
return { | ||
target: { | ||
type: "Invocation", | ||
value: element | ||
}, | ||
method: "doubleValueForConfigKey:", | ||
args: [{ | ||
type: "NSString", | ||
value: configKey | ||
}] | ||
}; | ||
} | ||
|
||
/*Resets all configurations to default values, removing all the configured values. | ||
@remark Any default values added by calling GREYConfiguration:setDefaultValue:forConfigKey: | ||
are not reset. | ||
*/static reset(element) { | ||
return { | ||
target: { | ||
type: "Invocation", | ||
value: element | ||
}, | ||
method: "reset", | ||
args: [] | ||
}; | ||
} | ||
|
||
/*Given a value and a key that identifies a configuration, set the value of the configuration. | ||
Overwrites any previous value for the configuration. | ||
@remark To restore original values, call GREYConfiguration::reset. | ||
@param value The configuration value to be set. Scalars should be wrapped in @c NSValue. | ||
@param configKey Key identifying an existing or new configuration. Must be a valid @c NSString. | ||
*/static setValueForConfigKey(element, value, configKey) { | ||
if (typeof configKey !== "string") throw new Error("configKey should be a string, but got " + (configKey + (" (" + (typeof configKey + ")")))); | ||
return { | ||
target: { | ||
type: "Invocation", | ||
value: element | ||
}, | ||
method: "setValue:forConfigKey:", | ||
args: [value, { | ||
type: "NSString", | ||
value: configKey | ||
}] | ||
}; | ||
} | ||
|
||
/*Associates configuration identified by @c configKey with the provided @c value. | ||
@remark Default values persist even after resetting the configuration | ||
(using GREYConfiguration::reset) | ||
@param value The configuration value to be set. Scalars should be wrapped in @c NSValue. | ||
@param configKey Key identifying an existing or new configuration. Must be a valid @c NSString. | ||
*/static setDefaultValueForConfigKey(element, value, configKey) { | ||
if (typeof configKey !== "string") throw new Error("configKey should be a string, but got " + (configKey + (" (" + (typeof configKey + ")")))); | ||
return { | ||
target: { | ||
type: "Invocation", | ||
value: element | ||
}, | ||
method: "setDefaultValue:forConfigKey:", | ||
args: [value, { | ||
type: "NSString", | ||
value: configKey | ||
}] | ||
}; | ||
} | ||
|
||
function GREYConfigurationInstance() { | ||
return invoke.call(invoke.IOS.Class('GREYConfiguration'), 'sharedInstance'); | ||
} | ||
|
||
module.exports = { | ||
setURLBlacklist, | ||
enableSynchronization, | ||
disableSynchronization | ||
}; | ||
module.exports = GREYConfiguration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
This code is generated. | ||
For more information see generation/README.md. | ||
*/ | ||
|
||
|
||
|
||
class GREYConfiguration { | ||
static enableSynchronization(element) { | ||
return { | ||
target: { | ||
type: "Invocation", | ||
value: element | ||
}, | ||
method: "enableSynchronization", | ||
args: [] | ||
}; | ||
} | ||
|
||
static disableSynchronization(element) { | ||
return { | ||
target: { | ||
type: "Invocation", | ||
value: element | ||
}, | ||
method: "disableSynchronization", | ||
args: [] | ||
}; | ||
} | ||
|
||
} | ||
|
||
module.exports = GREYConfiguration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.