forked from upstream-mirrors/OpenTracks
Add checks about the status of recording, pause and not in recording. Add method findTextView and sleep to help current and following tests.
This commit is contained in:
+35
-2
@@ -726,13 +726,13 @@ public class EndToEndTestUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a text view with specified test in a view.
|
||||
* Finds a displayed text view with specified text in a view.
|
||||
*
|
||||
* @param findText text to find
|
||||
* @param parent which text view in in
|
||||
* @return the text view, null means can not find it
|
||||
*/
|
||||
static TextView findTextView(String findText, View parent) {
|
||||
static TextView findTextViewInView(String findText, View parent) {
|
||||
ArrayList<TextView> textViews = SOLO.getCurrentTextViews(parent);
|
||||
for (TextView textView : textViews) {
|
||||
String text = (String) textView.getText();
|
||||
@@ -742,6 +742,26 @@ public class EndToEndTestUtils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a displayed text view with specified text.
|
||||
*
|
||||
* @param findText text to find
|
||||
* @return the text view, null means can not find it
|
||||
*/
|
||||
static TextView findTextView(String findText) {
|
||||
ArrayList<View> allViews = SOLO.getViews();
|
||||
for (View view : allViews) {
|
||||
if (view instanceof TextView) {
|
||||
TextView textView = (TextView) view;
|
||||
String text = (String) textView.getText();
|
||||
if (textView.isShown() && text.endsWith(findText)) {
|
||||
return textView;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ChartView.
|
||||
@@ -788,5 +808,18 @@ public class EndToEndTestUtils {
|
||||
imm.hideSoftInputFromWindow(editText.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
|
||||
SOLO.enterText(editText, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits n milliseconds.
|
||||
*
|
||||
* @param milliseconds time to sleep
|
||||
*/
|
||||
public static void sleep(long milliseconds) {
|
||||
try {
|
||||
Thread.sleep(milliseconds);
|
||||
} catch (InterruptedException e) {
|
||||
Log.e(EndToEndTestUtils.LOG_TAG, "Unable to sleep " + milliseconds, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user