calabash-android 0.4.22.pre4 → 0.5.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/calabash-android +66 -45
- data/lib/calabash-android/calabash_steps.rb +0 -8
- data/lib/calabash-android/canned_steps.md +2 -30
- data/lib/calabash-android/lib/TestServer.apk +0 -0
- data/lib/calabash-android/operations.rb +199 -23
- data/lib/calabash-android/removed_actions.txt +52 -0
- data/lib/calabash-android/steps/assert_steps.rb +9 -24
- data/lib/calabash-android/steps/check_box_steps.rb +2 -2
- data/lib/calabash-android/steps/context_menu_steps.rb +11 -4
- data/lib/calabash-android/steps/date_picker_steps.rb +2 -2
- data/lib/calabash-android/steps/enter_text_steps.rb +13 -13
- data/lib/calabash-android/steps/l10n_steps.rb +5 -5
- data/lib/calabash-android/steps/map_steps.rb +12 -12
- data/lib/calabash-android/steps/navigation_steps.rb +12 -12
- data/lib/calabash-android/steps/press_button_steps.rb +16 -12
- data/lib/calabash-android/steps/progress_steps.rb +19 -22
- data/lib/calabash-android/steps/search_steps.rb +2 -2
- data/lib/calabash-android/steps/spinner_steps.rb +10 -2
- data/lib/calabash-android/steps/time_picker_steps.rb +2 -2
- data/lib/calabash-android/version.rb +1 -1
- data/lib/calabash-android/wait_helpers.rb +29 -1
- data/test-server/instrumentation-backend/antlr/UIQuery.g +11 -11
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/CalabashInstrumentationTestRunner.java +3 -2
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/InstrumentationBackend.java +9 -4
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/Result.java +16 -12
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/application/Backdoor.java +55 -0
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/gestures/LongPressCoordinate.java +19 -2
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/JavaScriptExecuter.java +105 -0
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/QueryHelper.java +27 -30
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ViewMapper.java +27 -18
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/ComparisonOperator.java +7 -1
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/UIQueryASTPredicate.java +16 -4
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/UIQueryASTWith.java +13 -6
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/UIQueryUtils.java +94 -48
- metadata +5 -59
- data/lib/calabash-android/steps/additions_manual_steps.rb +0 -11
- data/lib/calabash-android/steps/app_steps.rb +0 -10
- data/lib/calabash-android/steps/list_steps.rb +0 -41
- data/lib/calabash-android/steps/rotation_steps.rb +0 -7
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/PressButtonNumber.java +0 -22
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/PressButtonText.java +0 -27
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/PressImageButtonDescription.java +0 -39
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/PressImageButtonNumber.java +0 -22
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java +0 -47
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/checkbox/ToggleCheckboxNumber.java +0 -22
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/contextmenu/LongPressText.java +0 -22
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/contextmenu/LongPressTextAndSelectFromMenuById.java +0 -26
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/contextmenu/LongPressTextAndSelectFromMenuByIndex.java +0 -22
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/contextmenu/LongPressTextAndSelectFromMenuByText.java +0 -26
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/helpers/InspectCurrentDialog.java +0 -76
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/list/GetListData.java +0 -85
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/list/GetListItemProperties.java +0 -194
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/list/GetListItemText.java +0 -136
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/list/LongPressListItems.java +0 -22
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/list/PressListItems.java +0 -22
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/scrolling/ScrollDown.java +0 -22
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/scrolling/ScrollUp.java +0 -22
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/search/EnterQueryByIndex.java +0 -29
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/softkey/SelectFromMenuByText.java +0 -24
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/spinner/GetSelectedSpinnerItemText.java +0 -36
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/spinner/SelectSpinnerItemByContentDescription.java +0 -43
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/text/AssertGridViewContainsNoDuplicates.java +0 -72
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/text/AssertText.java +0 -31
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/text/AssertTextOfSpecificTextViewByContentDescription.java +0 -32
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/text/ClearTextById.java +0 -30
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/text/ClearTextByIndex.java +0 -22
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/text/ClearTextFieldByContentDescription.java +0 -33
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/text/ClickOnText.java +0 -22
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/text/EnterTextByContentDescription.java +0 -32
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/text/EnterTextById.java +0 -33
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/text/EnterTextByIndex.java +0 -22
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/text/GetTextById.java +0 -42
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/AssertViewProperty.java +0 -141
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewByDescription.java +0 -46
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java +0 -56
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/GetViewProperty.java +0 -101
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/HasView.java +0 -31
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsEnabled.java +0 -30
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/LongPressOnViewById.java +0 -34
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/Press.java +0 -89
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/SelectTab.java +0 -110
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/Wait.java +0 -24
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForDialogClose.java +0 -21
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java +0 -47
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java +0 -54
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForTab.java +0 -108
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForText.java +0 -37
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForView.java +0 -43
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForViewById.java +0 -58
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/JavaScriptOperation.java +0 -44
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java +0 -70
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetText.java +0 -64
@@ -1,31 +0,0 @@
|
|
1
|
-
package sh.calaba.instrumentationbackend.actions.view;
|
2
|
-
|
3
|
-
import sh.calaba.instrumentationbackend.Result;
|
4
|
-
import sh.calaba.instrumentationbackend.TestHelpers;
|
5
|
-
import sh.calaba.instrumentationbackend.actions.Action;
|
6
|
-
import android.view.View;
|
7
|
-
|
8
|
-
public class HasView implements Action {
|
9
|
-
|
10
|
-
@Override
|
11
|
-
public Result execute(String... args) {
|
12
|
-
final String idArgument = args[0];
|
13
|
-
final View foundView = TestHelpers.getViewById(idArgument);
|
14
|
-
|
15
|
-
if( null == foundView ) {
|
16
|
-
return notFoundResult(idArgument);
|
17
|
-
}
|
18
|
-
|
19
|
-
return Result.successResult();
|
20
|
-
}
|
21
|
-
|
22
|
-
@Override
|
23
|
-
public String key() {
|
24
|
-
return "has_view";
|
25
|
-
}
|
26
|
-
|
27
|
-
private Result notFoundResult(final String firstArgument) {
|
28
|
-
return Result.failedResult(String.format("View with id %s was not found", firstArgument));
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
@@ -1,30 +0,0 @@
|
|
1
|
-
package sh.calaba.instrumentationbackend.actions.view;
|
2
|
-
|
3
|
-
import sh.calaba.instrumentationbackend.Result;
|
4
|
-
import sh.calaba.instrumentationbackend.TestHelpers;
|
5
|
-
import sh.calaba.instrumentationbackend.actions.Action;
|
6
|
-
import android.view.View;
|
7
|
-
|
8
|
-
public class IsEnabled implements Action {
|
9
|
-
|
10
|
-
@Override
|
11
|
-
public Result execute(String... args) {
|
12
|
-
final String firstArgument = args[0];
|
13
|
-
final View foundView = TestHelpers.getViewById(firstArgument);
|
14
|
-
|
15
|
-
if( null == foundView ) {
|
16
|
-
return notFoundResult(firstArgument);
|
17
|
-
}
|
18
|
-
|
19
|
-
return new Result(foundView.isEnabled());
|
20
|
-
}
|
21
|
-
|
22
|
-
@Override
|
23
|
-
public String key() {
|
24
|
-
return "is_enabled";
|
25
|
-
}
|
26
|
-
|
27
|
-
private Result notFoundResult(final String firstArgument) {
|
28
|
-
return Result.failedResult(String.format("View with id %s was not found", firstArgument));
|
29
|
-
}
|
30
|
-
}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
package sh.calaba.instrumentationbackend.actions.view;
|
2
|
-
|
3
|
-
|
4
|
-
import sh.calaba.instrumentationbackend.InstrumentationBackend;
|
5
|
-
import sh.calaba.instrumentationbackend.Result;
|
6
|
-
import sh.calaba.instrumentationbackend.TestHelpers;
|
7
|
-
import sh.calaba.instrumentationbackend.actions.Action;
|
8
|
-
import android.view.View;
|
9
|
-
|
10
|
-
|
11
|
-
/*
|
12
|
-
* Warning: Unlike most other actions this action will allow you to click on views that are not visible.
|
13
|
-
*/
|
14
|
-
public class LongPressOnViewById implements Action {
|
15
|
-
|
16
|
-
@Override
|
17
|
-
public Result execute(String... args) {
|
18
|
-
final View view = TestHelpers.getViewById(args[0]);
|
19
|
-
|
20
|
-
if(view == null) {
|
21
|
-
return new Result(false, "Could not find view with id: '" + args[0] + "'");
|
22
|
-
}
|
23
|
-
InstrumentationBackend.solo.clickLongOnView(view);
|
24
|
-
return Result.successResult();
|
25
|
-
}
|
26
|
-
|
27
|
-
@Override
|
28
|
-
public String key() {
|
29
|
-
return "long_press_on_view_by_id";
|
30
|
-
}
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
}
|
@@ -1,89 +0,0 @@
|
|
1
|
-
package sh.calaba.instrumentationbackend.actions.view;
|
2
|
-
|
3
|
-
|
4
|
-
import sh.calaba.instrumentationbackend.InstrumentationBackend;
|
5
|
-
import sh.calaba.instrumentationbackend.Result;
|
6
|
-
import sh.calaba.instrumentationbackend.actions.Action;
|
7
|
-
import android.view.View;
|
8
|
-
import android.widget.Button;
|
9
|
-
import android.widget.TextView;
|
10
|
-
|
11
|
-
|
12
|
-
public class Press implements Action {
|
13
|
-
|
14
|
-
@Override
|
15
|
-
public Result execute(String... args) {
|
16
|
-
View viewToPress = null;
|
17
|
-
String helpText = "";
|
18
|
-
String description = args[0];
|
19
|
-
// Try to press button
|
20
|
-
|
21
|
-
InstrumentationBackend.solo.searchButton(description);
|
22
|
-
helpText += "Buttons:\n";
|
23
|
-
for (Button b : InstrumentationBackend.solo.getCurrentViews(Button.class)) {
|
24
|
-
helpText += b.getText() + "\n";
|
25
|
-
if (b.getText().toString().equalsIgnoreCase(description)) {
|
26
|
-
System.out.println("Found button to press:" + b);
|
27
|
-
viewToPress = b;
|
28
|
-
break;
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
// Try to press view with content description
|
33
|
-
if (viewToPress == null) {
|
34
|
-
helpText += "Content descriptions:\n";
|
35
|
-
for (View view : InstrumentationBackend.solo.getCurrentViews()) {
|
36
|
-
String viewDescription = view.getContentDescription() != null ? view.getContentDescription().toString() : "";
|
37
|
-
|
38
|
-
if (viewDescription.length() > 0) {
|
39
|
-
helpText += viewDescription + "\n";
|
40
|
-
}
|
41
|
-
if (viewDescription != null && viewDescription.equalsIgnoreCase(description)) {
|
42
|
-
System.out.println("Found view to press:" + view);
|
43
|
-
viewToPress = view;
|
44
|
-
break;
|
45
|
-
}
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
// Try to find view with matching class name
|
50
|
-
if (viewToPress == null) {
|
51
|
-
InstrumentationBackend.solo.searchText(description);
|
52
|
-
System.out.println("searchText(" + description + ")");
|
53
|
-
helpText += "Classes:\n";
|
54
|
-
for (View v : InstrumentationBackend.solo.getCurrentViews()) {
|
55
|
-
if (v.getClass() == TextView.class) {
|
56
|
-
TextView tv = (TextView) v;
|
57
|
-
helpText += v.getClass().getName() + "(" + tv.getText().toString() + ")(" + tv.getParent().getClass() + ")\n";
|
58
|
-
if (tv.getText().toString().equalsIgnoreCase(description)) {
|
59
|
-
viewToPress = v;
|
60
|
-
break;
|
61
|
-
}
|
62
|
-
|
63
|
-
} else {
|
64
|
-
helpText += v.getClass().getName() + "\n";
|
65
|
-
if (v.getClass().getName().endsWith(description)) {
|
66
|
-
viewToPress = v;
|
67
|
-
break;
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}
|
71
|
-
}
|
72
|
-
if (viewToPress != null) {
|
73
|
-
System.out.println("Pressing:" + viewToPress);
|
74
|
-
if (viewToPress instanceof TextView) {
|
75
|
-
System.out.println("Pressing(.getText()):" + ((TextView) viewToPress).getText());
|
76
|
-
}
|
77
|
-
InstrumentationBackend.solo.clickOnView(viewToPress);
|
78
|
-
return Result.successResult();
|
79
|
-
} else {
|
80
|
-
return new Result(false, ("Could not find anything to press matching: '" + description + "' found: \n" + helpText));
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
@Override
|
85
|
-
public String key() {
|
86
|
-
return "press";
|
87
|
-
}
|
88
|
-
|
89
|
-
}
|
@@ -1,110 +0,0 @@
|
|
1
|
-
package sh.calaba.instrumentationbackend.actions.view;
|
2
|
-
|
3
|
-
import java.util.LinkedList;
|
4
|
-
import java.util.List;
|
5
|
-
|
6
|
-
import sh.calaba.instrumentationbackend.InstrumentationBackend;
|
7
|
-
import sh.calaba.instrumentationbackend.Result;
|
8
|
-
import sh.calaba.instrumentationbackend.actions.Action;
|
9
|
-
import android.app.Activity;
|
10
|
-
import android.app.TabActivity;
|
11
|
-
import android.util.Log;
|
12
|
-
import android.view.View;
|
13
|
-
import android.widget.TabHost;
|
14
|
-
import android.widget.TextView;
|
15
|
-
|
16
|
-
/**
|
17
|
-
* Select the tab by 1-based index or by name
|
18
|
-
*
|
19
|
-
* @author Nicholas Albion
|
20
|
-
*/
|
21
|
-
@SuppressWarnings("deprecation")
|
22
|
-
public class SelectTab implements Action {
|
23
|
-
@Override
|
24
|
-
public Result execute(String... args) {
|
25
|
-
|
26
|
-
Activity currentActivity = InstrumentationBackend.solo.getCurrentActivity();
|
27
|
-
|
28
|
-
if( currentActivity instanceof TabActivity == false ) {
|
29
|
-
Activity parent = currentActivity.getParent();
|
30
|
-
if( parent != null ) {
|
31
|
-
currentActivity = parent;
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
if( currentActivity instanceof TabActivity ) {
|
36
|
-
final TabHost tabHost = ((TabActivity)currentActivity).getTabHost();
|
37
|
-
|
38
|
-
String tabName = args[0];
|
39
|
-
if( tabName.length() == 1 ) {
|
40
|
-
char c = tabName.charAt(0);
|
41
|
-
if( c >= '0' && c <= '9' ) {
|
42
|
-
int index = (c - '0') - 1;
|
43
|
-
tabHost.setCurrentTab( index );
|
44
|
-
return Result.successResult();
|
45
|
-
}
|
46
|
-
}
|
47
|
-
|
48
|
-
List<String> foundTabs = new LinkedList<String>();
|
49
|
-
int numberOfTabs = ((TabActivity)currentActivity).getTabWidget().getTabCount();
|
50
|
-
Log.i("SelectTab", "numberOfTabs: " + numberOfTabs);
|
51
|
-
|
52
|
-
String resultMessage = null;
|
53
|
-
int tabIndex;
|
54
|
-
FIND_TAB:
|
55
|
-
for( tabIndex = 0; tabIndex < numberOfTabs; tabIndex++ ) {
|
56
|
-
if( tabName.equals( tabHost.getTag(tabIndex) ) ) {
|
57
|
-
resultMessage = "Selected the tab by tag";
|
58
|
-
break;
|
59
|
-
}
|
60
|
-
|
61
|
-
String currentTab;
|
62
|
-
View view = tabHost.getTabWidget().getChildTabViewAt(tabIndex);
|
63
|
-
if( view instanceof TextView ) {
|
64
|
-
currentTab = ((TextView)view).getText().toString();
|
65
|
-
if( tabName.equals(currentTab) ) {
|
66
|
-
resultMessage = "Selected the tab by text view";
|
67
|
-
break;
|
68
|
-
}
|
69
|
-
foundTabs.add(currentTab);
|
70
|
-
} else {
|
71
|
-
Log.i("SelectTab", "current tab view: " + view.getId() + ", " + view.getClass().getSimpleName());
|
72
|
-
List<TextView> textViews = InstrumentationBackend.solo.getCurrentViews(TextView.class, view);
|
73
|
-
for( TextView textView : textViews ) {
|
74
|
-
currentTab = textView.getText().toString();
|
75
|
-
Log.i("SelectTab", " child text view: " + currentTab);
|
76
|
-
if( tabName.equals(currentTab) ) {
|
77
|
-
resultMessage = "Selected the tab by child text view";
|
78
|
-
break FIND_TAB;
|
79
|
-
}
|
80
|
-
foundTabs.add(currentTab);
|
81
|
-
}
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
if( resultMessage != null ) {
|
86
|
-
final int matchingTabIndex = tabIndex;
|
87
|
-
|
88
|
-
currentActivity.runOnUiThread( new Runnable() {
|
89
|
-
@Override
|
90
|
-
public void run() {
|
91
|
-
tabHost.setCurrentTab( matchingTabIndex );
|
92
|
-
}
|
93
|
-
});
|
94
|
-
|
95
|
-
return new Result(true, resultMessage);
|
96
|
-
}
|
97
|
-
|
98
|
-
Result result = new Result(false, "Was unable to find a matching tab");
|
99
|
-
result.setExtras( foundTabs );
|
100
|
-
return result;
|
101
|
-
} else {
|
102
|
-
return new Result(false, "The current activity is not a TabActivity: " + currentActivity.getLocalClassName() );
|
103
|
-
}
|
104
|
-
}
|
105
|
-
|
106
|
-
@Override
|
107
|
-
public String key() {
|
108
|
-
return "select_tab";
|
109
|
-
}
|
110
|
-
}
|
data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/Wait.java
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
package sh.calaba.instrumentationbackend.actions.wait;
|
2
|
-
|
3
|
-
|
4
|
-
import sh.calaba.instrumentationbackend.Result;
|
5
|
-
import sh.calaba.instrumentationbackend.TestHelpers;
|
6
|
-
import sh.calaba.instrumentationbackend.actions.Action;
|
7
|
-
|
8
|
-
|
9
|
-
public class Wait implements Action {
|
10
|
-
|
11
|
-
@Override
|
12
|
-
public Result execute(String... args) {
|
13
|
-
int seconds = Integer.parseInt(args[0]);
|
14
|
-
|
15
|
-
TestHelpers.wait(seconds);
|
16
|
-
|
17
|
-
return Result.successResult();
|
18
|
-
}
|
19
|
-
|
20
|
-
@Override
|
21
|
-
public String key() {
|
22
|
-
return "wait";
|
23
|
-
}
|
24
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
package sh.calaba.instrumentationbackend.actions.wait;
|
2
|
-
|
3
|
-
|
4
|
-
import sh.calaba.instrumentationbackend.InstrumentationBackend;
|
5
|
-
import sh.calaba.instrumentationbackend.Result;
|
6
|
-
import sh.calaba.instrumentationbackend.actions.Action;
|
7
|
-
|
8
|
-
|
9
|
-
public class WaitForDialogClose implements Action {
|
10
|
-
|
11
|
-
@Override
|
12
|
-
public Result execute(String... args) {
|
13
|
-
InstrumentationBackend.solo.waitForDialogToClose(30000);
|
14
|
-
return Result.successResult();
|
15
|
-
}
|
16
|
-
|
17
|
-
@Override
|
18
|
-
public String key() {
|
19
|
-
return "wait_for_dialog_to_close";
|
20
|
-
}
|
21
|
-
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
package sh.calaba.instrumentationbackend.actions.wait;
|
2
|
-
|
3
|
-
|
4
|
-
import sh.calaba.instrumentationbackend.InstrumentationBackend;
|
5
|
-
import sh.calaba.instrumentationbackend.Result;
|
6
|
-
import sh.calaba.instrumentationbackend.actions.Action;
|
7
|
-
import android.view.View;
|
8
|
-
import android.widget.ProgressBar;
|
9
|
-
|
10
|
-
|
11
|
-
public class WaitForProgress implements Action {
|
12
|
-
|
13
|
-
@Override
|
14
|
-
public Result execute(String... args) {
|
15
|
-
int timeout = 60000;
|
16
|
-
long waitUntil = System.currentTimeMillis() + timeout;
|
17
|
-
|
18
|
-
while (numberOfVisibleProgressBars() > 0) {
|
19
|
-
if (System.currentTimeMillis() > waitUntil) {
|
20
|
-
return new Result(false, "Timedout waiting for no visible progressbars (" + numberOfVisibleProgressBars() +" still visible).");
|
21
|
-
}
|
22
|
-
try {
|
23
|
-
Thread.sleep(100);
|
24
|
-
} catch (InterruptedException e) {
|
25
|
-
e.printStackTrace();
|
26
|
-
}
|
27
|
-
}
|
28
|
-
return Result.successResult();
|
29
|
-
}
|
30
|
-
|
31
|
-
@Override
|
32
|
-
public String key() {
|
33
|
-
return "wait_for_no_progress_bars";
|
34
|
-
}
|
35
|
-
|
36
|
-
private int numberOfVisibleProgressBars() {
|
37
|
-
int visibleProgressBars = 0;
|
38
|
-
for (ProgressBar v : InstrumentationBackend.solo.getCurrentViews(ProgressBar.class)) {
|
39
|
-
if (v != null & v.getVisibility() != View.GONE && v.getVisibility() != View.INVISIBLE && v.isShown()) {
|
40
|
-
visibleProgressBars++;
|
41
|
-
System.out.println("Found visible progressbar number:" + visibleProgressBars);
|
42
|
-
}
|
43
|
-
}
|
44
|
-
return visibleProgressBars;
|
45
|
-
}
|
46
|
-
|
47
|
-
}
|
@@ -1,54 +0,0 @@
|
|
1
|
-
package sh.calaba.instrumentationbackend.actions.wait;
|
2
|
-
|
3
|
-
import sh.calaba.instrumentationbackend.InstrumentationBackend;
|
4
|
-
import sh.calaba.instrumentationbackend.Result;
|
5
|
-
import sh.calaba.instrumentationbackend.actions.Action;
|
6
|
-
|
7
|
-
public class WaitForScreen implements Action {
|
8
|
-
private static final int DEFAULT_TIMEOUT = 5 * 1000;
|
9
|
-
|
10
|
-
@Override
|
11
|
-
public Result execute(String... args) {
|
12
|
-
switch (args.length) {
|
13
|
-
case 0:
|
14
|
-
return new Result(false, "Cannot check for correct screen. No Activity name supplied!");
|
15
|
-
case 1: {
|
16
|
-
if (InstrumentationBackend.solo.waitForActivity(args[0], DEFAULT_TIMEOUT)) {
|
17
|
-
return Result.successResult();
|
18
|
-
} else {
|
19
|
-
String currentActivity = InstrumentationBackend.solo.getCurrentActivity().getClass().getSimpleName();
|
20
|
-
Result result = new Result(false, "Screen " + args[0] + " not found. Current activity is " + currentActivity);
|
21
|
-
result.addBonusInformation(currentActivity);
|
22
|
-
return result;
|
23
|
-
}
|
24
|
-
}
|
25
|
-
case 2: { // 1st arg is Activity name, 2nd arg is timeout
|
26
|
-
int timeout;
|
27
|
-
|
28
|
-
try {
|
29
|
-
// given seconds; want milliseconds
|
30
|
-
timeout = 1000 * Integer.parseInt(args[1]);
|
31
|
-
} catch (NumberFormatException e) {
|
32
|
-
return new Result(false, "Invalid timeout supplied. Should be an integer!");
|
33
|
-
}
|
34
|
-
|
35
|
-
if (InstrumentationBackend.solo.waitForActivity(args[0], timeout)) {
|
36
|
-
return Result.successResult();
|
37
|
-
} else {
|
38
|
-
String currentActivity = InstrumentationBackend.solo.getCurrentActivity().getClass().getSimpleName();
|
39
|
-
Result result = new Result(false, "Screen " + args[0] + " not found. Current activity is " + currentActivity);
|
40
|
-
result.addBonusInformation(currentActivity);
|
41
|
-
return result;
|
42
|
-
}
|
43
|
-
}
|
44
|
-
default:
|
45
|
-
return new Result(false, "Too many argument supplied to wait_for_screen!");
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
@Override
|
50
|
-
public String key() {
|
51
|
-
return "wait_for_screen";
|
52
|
-
}
|
53
|
-
|
54
|
-
}
|