aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java33
1 files changed, 19 insertions, 14 deletions
diff --git a/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java b/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java
index 05b4ee1..985733a 100644
--- a/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java
+++ b/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java
@@ -1,18 +1,18 @@
package cgeo.geocaching.files;
-import com.jayway.android.robotium.solo.Solo;
+import cgeo.geocaching.Intents;
+
+import com.robotium.solo.Solo;
import android.annotation.TargetApi;
+import android.content.Intent;
import android.os.Build;
import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.Suppress;
import android.widget.CheckBox;
import java.util.ArrayList;
@TargetApi(Build.VERSION_CODES.FROYO)
-@Suppress()
-/* This test breaks the continuous integration server, do not run it for now. */
public class SimpleDirChooserUITest extends ActivityInstrumentationTestCase2<SimpleDirChooser> {
private Solo solo;
@@ -24,9 +24,14 @@ public class SimpleDirChooserUITest extends ActivityInstrumentationTestCase2<Sim
@Override
public void setUp() throws Exception {
super.setUp();
+ setActivityIntent(new Intent().putExtra(Intents.EXTRA_START_DIR, "").putExtra(SimpleDirChooser.EXTRA_CHOOSE_FOR_WRITING, false));
solo = new Solo(getInstrumentation(), getActivity());
}
+ public ArrayList<CheckBox> getCurrentCheckBoxes() {
+ return solo.getCurrentViews(CheckBox.class);
+ }
+
public void testSingleSelection() throws InterruptedException {
// normally our activity should be ready, but we already had Jenkins report no checkboxes right here at the beginning
solo.waitForActivity(solo.getCurrentActivity().getClass().getSimpleName(), 2000);
@@ -37,11 +42,11 @@ public class SimpleDirChooserUITest extends ActivityInstrumentationTestCase2<Sim
// according to the documentation, automatic pauses only happen in the clickXYZ() methods.
// Therefore lets introduce a manual pause after the scrolling methods.
- final int lastIndex = solo.getCurrentCheckBoxes().size() - 1;
+ final int lastIndex = getCurrentCheckBoxes().size() - 1;
solo.clickOnCheckBox(lastIndex);
- assertTrue(solo.getCurrentCheckBoxes().get(lastIndex).isChecked());
- assertFalse(solo.getCurrentCheckBoxes().get(0).isChecked());
+ assertTrue(solo.isCheckBoxChecked(lastIndex));
+ assertFalse(solo.isCheckBoxChecked(0));
assertChecked("Clicked last checkbox", 1);
solo.scrollUp();
@@ -54,23 +59,23 @@ public class SimpleDirChooserUITest extends ActivityInstrumentationTestCase2<Sim
pause();
solo.clickOnCheckBox(0);
assertChecked("Clicked first checkbox", 1);
- assertTrue(solo.getCurrentCheckBoxes().get(0).isChecked());
+ assertTrue(solo.isCheckBoxChecked(0));
solo.clickOnCheckBox(1);
assertChecked("Clicked second checkbox", 1);
- assertTrue(solo.getCurrentCheckBoxes().get(1).isChecked());
+ assertTrue(solo.isCheckBoxChecked(1));
}
private static void pause() throws InterruptedException {
- Thread.sleep(500);
+ Thread.sleep(100);
}
private void assertChecked(String message, int expectedChecked) {
- int checked = 0;
- final ArrayList<CheckBox> boxes = solo.getCurrentCheckBoxes();
+ final ArrayList<CheckBox> boxes = getCurrentCheckBoxes();
assertNotNull("Could not get checkboxes", boxes);
assertTrue("There are no checkboxes", boxes.size() > 1);
- for (CheckBox checkBox : boxes) {
- if (checkBox.isChecked()) {
+ int checked = 0;
+ for (int i = 0; i < boxes.size(); i++) {
+ if (solo.isCheckBoxChecked(i)) {
checked++;
}
}