-
Notifications
You must be signed in to change notification settings - Fork 37
PT-429: input scripting #121
Changes from 8 commits
e82dcaf
4c9c08b
2f218ed
8272bfd
6ee04a7
18560d2
dc63af1
1c86533
0eb4475
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,23 @@ import org.gradle.api.tasks.TaskAction | |
|
||
class Input extends AdbTask { | ||
|
||
Closure script | ||
InputSpec inputSpec | ||
|
||
/** | ||
* Manual creation of Input task is deprecated. | ||
* Please refer to scripting documentation for details: | ||
* https://github.com/novoda/gradle-android-command-plugin#input-scripting | ||
*/ | ||
@Deprecated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method has been just added and already deprecated: what's the point of it? 😕 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want to deprecate the field Before we had This method is now introduced to support that the old behavior.
I didn't want to keep all the methods because that would cause a lot of duplication. I know that it is not ideal but with this we are 100% backward compatible. I will look into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're talking from the perspective of the sample we provide, not the real public API: if you remove public methods you're introducing breaking changes, right? Duplication in this case is not correct, because you will not duplicate the implementation, will just be tedious to make those method to use delegation instead. I feel we can bare with that as long as we have a proper strategy to move forward :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's very true :) |
||
void setScript(Closure script) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
logger.warn """\ | ||
Manual creation of Input task is deprecated. | ||
Please refer to scripting documentation to modify your task '$name' | ||
https://github.com/novoda/gradle-android-command-plugin#input-scripting | ||
""".stripIndent() | ||
inputSpec = new InputSpec() | ||
inputSpec.script = script | ||
} | ||
|
||
void text(String value) { | ||
input('text', "$value") | ||
|
@@ -21,11 +37,11 @@ class Input extends AdbTask { | |
void key(int code) { | ||
input('keyevent', code) | ||
} | ||
|
||
void home() { | ||
key 3 | ||
} | ||
|
||
void back() { | ||
key 4 | ||
} | ||
|
@@ -37,7 +53,7 @@ class Input extends AdbTask { | |
void down() { | ||
key 20 | ||
} | ||
|
||
void left() { | ||
key 21 | ||
} | ||
|
@@ -49,15 +65,15 @@ class Input extends AdbTask { | |
void power() { | ||
key 26 | ||
} | ||
|
||
void clear() { | ||
key 28 | ||
} | ||
|
||
void tab() { | ||
key 61 | ||
} | ||
|
||
void enter() { | ||
key 66 | ||
} | ||
|
@@ -67,14 +83,13 @@ class Input extends AdbTask { | |
} | ||
|
||
private input(... values) { | ||
def command = ["shell", "input"] | ||
command.addAll(values) | ||
runCommand(command) | ||
runCommand(['shell', 'input', *values]) | ||
} | ||
|
||
@TaskAction | ||
void exec() { | ||
assertDeviceConnected() | ||
script.call() | ||
inputSpec.script.delegate = this | ||
inputSpec.script.call() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.novoda.gradle.command | ||
|
||
class InputSpec { | ||
|
||
String name | ||
Closure script | ||
|
||
InputSpec(name) { | ||
this.name = name | ||
} | ||
|
||
void execute(script) { | ||
this.script = script | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to have a brand new
group
calledadb script
. Suggestions are welcome.