public void testSpinnerUpdatesRename() {
    String newName = "nameRenamed";

    solo.clickOnText(lookName);

    assertTrue(lookName + " is not in Spinner", solo.searchText(lookName));
    assertTrue(lookName2 + " is not in Spinner", solo.searchText(lookName2));

    solo.goBack();
    solo.goBack();

    solo.clickOnText(solo.getString(R.string.backgrounds));

    clickOnContextMenuItem(lookName, solo.getString(R.string.rename));

    solo.clearEditText(0);
    solo.enterText(0, newName);
    solo.clickOnButton(solo.getString(R.string.ok));

    clickOnSpinnerItem(solo.getString(R.string.category_looks), solo.getString(R.string.scripts));

    solo.clickOnText(newName);

    assertTrue(newName + " is not in Spinner", solo.searchText(newName));
    assertTrue(lookName2 + " is not in Spinner", solo.searchText(lookName2));
  }
 public void testAddCourseCrawlerError() {
   UpdateService.setCrawlerToUse(NullCrawler.class);
   solo.clickOnView(getActivity().findViewById(R.id.add));
   solo.enterText(0, "Course");
   solo.clickOnEditText(0);
   solo.sendKey(Solo.ENTER);
   assertTrue("Error dialog not shown", solo.searchText(solo.getString(R.string.error)));
   assertTrue("Error message not shown", solo.searchText(solo.getString(R.string.search_error)));
   solo.clickOnButton(0);
   assertFalse(
       "Error shows even after clicking ok", solo.searchText(solo.getString(R.string.error)));
   solo.goBack();
   solo.goBack();
 }
    public String getString(final Solo solo) {
      if (stringResource == null) {
        stringResource = solo.getString(resourceID);
      }

      return stringResource;
    }
Exemple #4
0
  public void testStrings() {

    solo.clickOnEditText(0);
    solo.sleep(100);

    boolean isFound = solo.searchText(solo.getString(R.string.brick_if_begin_second_part));
    assertTrue(
        "String: " + getActivity().getString(R.string.brick_if_begin_second_part) + " not found!",
        isFound);

    isFound = solo.searchText(solo.getString(R.string.brick_if_begin));
    assertTrue(
        "String: " + getActivity().getString(R.string.brick_if_begin) + " not found!", isFound);

    solo.goBack();
    solo.goBack();
  }
  public void testSpinnerUpdatesDelete() {
    solo.clickOnText(lookName);

    assertTrue(lookName + " is not in Spinner", solo.searchText(lookName));
    assertTrue(lookName2 + " is not in Spinner", solo.searchText(lookName2));

    solo.goBack();
    solo.goBack();
    solo.clickOnText(solo.getString(R.string.backgrounds));

    clickOnContextMenuItem(lookName, solo.getString(R.string.delete));
    solo.clickOnButton(solo.getString(R.string.ok));

    clickOnSpinnerItem(solo.getString(R.string.category_looks), solo.getString(R.string.scripts));

    solo.clickOnText(lookName2);

    assertFalse(lookName + " is still in Spinner", solo.searchText(lookName));
    assertTrue(lookName2 + " is not in Spinner", solo.searchText(lookName2));
  }
 public void testSpinnerUpdates() {
   String spinnerNothingText = solo.getString(R.string.broadcast_nothing_selected);
   solo.clickOnText(spinnerNothingText);
   assertTrue(costumeName + " is not in Spinner", solo.searchText(costumeName));
   assertTrue(costumeName2 + " is not in Spinner", solo.searchText(costumeName2));
   solo.goBack();
   solo.clickOnText(getActivity().getString(R.string.backgrounds));
   solo.clickOnButton(getActivity().getString(R.string.sound_delete));
   solo.clickOnButton(getActivity().getString(R.string.ok));
   solo.clickOnText(getActivity().getString(R.string.scripts));
   solo.clickOnText(spinnerNothingText);
   assertFalse(costumeName + " is still in Spinner", solo.searchText(costumeName));
   assertTrue(costumeName2 + " is not in Spinner", solo.searchText(costumeName2));
 }
  /**
   * The first walkthrough. Documented on the wiki. Starts on the login, ends up navigating to a
   * lesson after logging in.
   */
  @Test
  public void testWalkthroughLoginToDashboardToCoursesToCourseToLesson() {
    // Login first
    EditText user = solo.getEditText(0);
    EditText pass = solo.getEditText(1);
    solo.typeText(user, "*****@*****.**");
    solo.typeText(pass, "password");
    solo.clickOnButton(solo.getString(com.huskysoft.eduki.R.string.login));
    // Need to sleep to allow the activity to finish
    solo.sleep(8000);
    solo.assertCurrentActivity("Wrong activity", MainActivity.class);

    // Click on the all courses button
    solo.clickOnActionBarItem(com.huskysoft.eduki.R.id.action_courses);
    solo.sleep(1000);
    solo.assertCurrentActivity("Did not start the Course list Activity", CoursesListActivity.class);

    // Wait for the courses list to appear
    solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.courseListView));
    solo.sleep(1000);
    List<Course> courseList = ((CoursesListActivity) solo.getCurrentActivity()).getCourseList();
    assertNotSame(courseList.size(), 0);
    solo.clickOnText("INTRODUCTION");
    solo.assertCurrentActivity("Wrong activity", CourseActivity.class);

    // Wait for the course page to appear
    solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.course_activity));
    solo.sleep(1000);

    // Click a lesson, wait for it to appear
    List<Lesson> lessonList = ((CourseActivity) solo.getCurrentActivity()).getLessonList();
    assertNotSame(lessonList.size(), 0);
    solo.clickOnText(lessonList.get(0).toString());

    solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.lessonViewLayoutText));
    solo.sleep(1000);
    String content =
        ((TextView)
                solo.getCurrentActivity()
                    .findViewById(com.huskysoft.eduki.R.id.lessonViewLayoutText))
            .getText()
            .toString();
    assertFalse(content.equals(""));
  }
  public void testSpinnerUpdatesRename() {
    String newName = "nameRenamed";
    String spinnerNothingText = solo.getString(R.string.broadcast_nothing_selected);

    solo.clickOnText(spinnerNothingText);
    assertTrue(costumeName + " is not in Spinner", solo.searchText(costumeName));
    assertTrue(costumeName2 + " is not in Spinner", solo.searchText(costumeName2));
    solo.goBack();
    solo.clickOnText(getActivity().getString(R.string.backgrounds));
    solo.clickOnView(solo.getView(R.id.costume_name));
    solo.clearEditText(0);
    solo.enterText(0, newName);
    solo.clickOnButton(getActivity().getString(R.string.ok));
    solo.sleep(500);
    solo.clickOnText(getActivity().getString(R.string.scripts));
    solo.clickOnText(spinnerNothingText);
    assertTrue(newName + " is not in Spinner", solo.searchText(newName));
    assertTrue(costumeName2 + " is not in Spinner", solo.searchText(costumeName2));
  }
  @Smoke
  public void testNXTMotorActionBrick() {
    ScriptTabActivity activity = (ScriptTabActivity) solo.getCurrentActivity();
    ScriptFragment fragment =
        (ScriptFragment) activity.getTabFragment(ScriptTabActivity.INDEX_TAB_SCRIPTS);
    BrickAdapter adapter = fragment.getAdapter();

    int childrenCount = adapter.getChildCountFromLastGroup();
    int groupCount = adapter.getScriptCount();

    assertEquals(
        "Incorrect number of bricks.",
        2 + 1,
        solo.getCurrentListViews().get(0).getChildCount()); // don't forget the footer
    assertEquals("Incorrect number of bricks.", 1, childrenCount);

    ArrayList<Brick> projectBrickList = project.getSpriteList().get(0).getScript(0).getBrickList();
    assertEquals("Incorrect number of bricks.", 1, projectBrickList.size());

    assertEquals(
        "Wrong Brick instance.", projectBrickList.get(0), adapter.getChild(groupCount - 1, 0));
    assertNotNull(
        "TextView does not exist.",
        solo.getText(getActivity().getString(R.string.brick_motor_action)));
    assertNotNull(
        "TextView does not exist.", solo.getText(getActivity().getString(R.string.motor_speed)));

    String buttonOkText = solo.getString(R.string.ok);
    solo.clickOnEditText(0);
    solo.waitForText(buttonOkText);
    solo.clearEditText(0);
    solo.enterText(0, SET_SPEED + "");
    solo.clickOnButton(buttonOkText);

    int speed = (Integer) UiTestUtils.getPrivateField("speed", motorBrick);
    assertEquals("Wrong text in field.", SET_SPEED, speed);
    assertEquals(
        "Value in Brick is not updated.", SET_SPEED + "", solo.getEditText(0).getText().toString());
    assertEquals(
        "SeekBar is at wrong position",
        SET_SPEED + 100,
        solo.getCurrentProgressBars().get(0).getProgress());

    solo.setProgressBar(
        0,
        SET_SPEED_INITIALLY
            + 100); // robotium doesnt go through proper function onProgressChanged() to change
                    // value on progress bar!
    solo.sleep(200);
    speed = (Integer) UiTestUtils.getPrivateField("speed", motorBrick);
    assertEquals("Wrong text in field.", SET_SPEED_INITIALLY, speed);
    assertEquals(
        "Value in Brick is not updated.",
        SET_SPEED_INITIALLY + "",
        solo.getEditText(0).getText().toString());
    assertEquals(
        "SeekBar is at wrong position",
        SET_SPEED_INITIALLY + 100,
        solo.getCurrentProgressBars().get(0).getProgress());

    solo.clickOnButton(0);
    int speedCounter = (Integer) UiTestUtils.getPrivateField("speed", motorBrick);
    assertEquals("Wrong text in field.", speedCounter, speed - 1);
    assertEquals(
        "Value in Brick is not updated.", speed - 1 + "", solo.getEditText(0).getText().toString());
    assertEquals(
        "SeekBar is at wrong position",
        speed - 1 + 100,
        solo.getCurrentProgressBars().get(0).getProgress());

    solo.clickOnButton(1);
    speedCounter = (Integer) UiTestUtils.getPrivateField("speed", motorBrick);
    assertEquals("Wrong text in field.", speedCounter, speed);
    assertEquals(
        "Value in Brick is not updated.", speed + "", solo.getEditText(0).getText().toString());
    assertEquals(
        "SeekBar is at wrong position",
        speed + 100,
        solo.getCurrentProgressBars().get(0).getProgress());

    solo.setProgressBar(0, 1);
    solo.clickOnButton(0);
    solo.clickOnButton(0);
    speed = (Integer) UiTestUtils.getPrivateField("speed", motorBrick);
    assertEquals("Wrong text in field.", speed, MIN_SPEED);
    assertEquals(
        "Value in Brick is not updated.", speed + "", solo.getEditText(0).getText().toString());
    assertEquals(
        "SeekBar is at wrong position",
        speed + 100,
        solo.getCurrentProgressBars().get(0).getProgress());

    solo.setProgressBar(0, MAX_SPEED + 100);
    solo.clickOnButton(1);
    solo.clickOnButton(1);
    speed = (Integer) UiTestUtils.getPrivateField("speed", motorBrick);
    assertEquals("Wrong text in field.", speed, MAX_SPEED);
    assertEquals(
        "Value in Brick is not updated.", speed + "", solo.getEditText(0).getText().toString());
    assertEquals(
        "SeekBar is at wrong position",
        speed + 100,
        solo.getCurrentProgressBars().get(0).getProgress());

    String[] motors = getActivity().getResources().getStringArray(R.array.nxt_motor_chooser);
    assertTrue("Spinner items list too short!", motors.length == 4);

    Spinner currentSpinner = solo.getCurrentSpinners().get(0);
    solo.pressSpinnerItem(0, 0);
    solo.waitForActivity(ScriptTabActivity.class.getSimpleName());
    assertEquals("Wrong item in spinner!", motors[0], currentSpinner.getSelectedItem());
    solo.pressSpinnerItem(0, 1);
    solo.waitForActivity(ScriptTabActivity.class.getSimpleName());
    assertEquals("Wrong item in spinner!", motors[1], currentSpinner.getSelectedItem());
    solo.pressSpinnerItem(0, 1);
    solo.waitForActivity(ScriptTabActivity.class.getSimpleName());
    assertEquals("Wrong item in spinner!", motors[2], currentSpinner.getSelectedItem());
    solo.pressSpinnerItem(0, 1);
    solo.waitForActivity(ScriptTabActivity.class.getSimpleName());
    assertEquals("Wrong item in spinner!", motors[3], currentSpinner.getSelectedItem());
  }
Exemple #10
0
  public void testIfBrickParts() {
    ArrayList<Integer> yPosition;
    ArrayList<Brick> projectBrickList = project.getSpriteList().get(0).getScript(0).getBrickList();
    Log.e("info", "Befor drag item 1 to item 4 + 20");
    logBrickListForJenkins(projectBrickList);

    yPosition = UiTestUtils.getListItemYPositions(solo, 1);
    UiTestUtils.longClickAndDrag(solo, 10, yPosition.get(1), 10, yPosition.get(4) + 20, 20);
    assertEquals("Incorrect number of bricks.", 4, projectBrickList.size());
    assertTrue("Wrong Brick instance.", (projectBrickList.get(1) instanceof IfLogicBeginBrick));

    Log.e("info", "Befor drag item 2 to item 0");
    logBrickListForJenkins(projectBrickList);

    yPosition = UiTestUtils.getListItemYPositions(solo, 1);
    UiTestUtils.longClickAndDrag(solo, 10, yPosition.get(2), 10, yPosition.get(0), 20);
    assertEquals("Incorrect number of bricks.", 4, projectBrickList.size());
    assertTrue("Wrong Brick instance.", (projectBrickList.get(0) instanceof IfLogicBeginBrick));

    // just to get focus
    // seems to be a bug just with the Nexus S 2.3.6
    String spinnerScripts = solo.getString(R.string.scripts);
    solo.clickOnText(spinnerScripts);
    solo.clickOnText(spinnerScripts);

    Log.e("info", "Befor drag item 3 to item 0");
    logBrickListForJenkins(projectBrickList);

    yPosition = UiTestUtils.getListItemYPositions(solo, 1);
    UiTestUtils.longClickAndDrag(solo, 10, yPosition.get(3), 10, yPosition.get(0), 20);

    assertEquals("Incorrect number of bricks.", 4, projectBrickList.size());
    assertTrue(
        "Wrong Brick instance - expected IfElseBrick but was "
            + projectBrickList.get(1).getClass().getSimpleName(),
        projectBrickList.get(1) instanceof IfLogicElseBrick);

    assertTrue(
        "Wrong Brick instance - expected ChangeYByNBrick but was "
            + projectBrickList.get(2).getClass().getSimpleName(),
        projectBrickList.get(2) instanceof ChangeYByNBrick);

    Log.e("info", "Befor drag item 4 to item 0");
    logBrickListForJenkins(projectBrickList);

    yPosition = UiTestUtils.getListItemYPositions(solo, 1);
    UiTestUtils.longClickAndDrag(solo, 10, yPosition.get(4) - 10, 10, yPosition.get(0), 20);
    assertEquals("Incorrect number of bricks.", 4, projectBrickList.size());

    Log.e("info", "After drag item 4 to item 0");
    logBrickListForJenkins(projectBrickList);

    // TODO Test commented lines on local test-device in order to find strange jenkins error
    // junit.framework.AssertionFailedError: Wrong Brick instance, expected IfLogicEndBrick but was
    // ChangeYByNBrick
    // assert below!

    //
    //		assertTrue("Wrong Brick instance, expected IfLogicEndBrick but was "
    //				+ projectBrickList.get(2).getClass().getSimpleName(),
    //				projectBrickList.get(2) instanceof IfLogicEndBrick);
    //

    //		UiTestUtils.addNewBrick(solo, R.string.brick_broadcast_receive);
    //		yPosition = UiTestUtils.getListItemYPositions(solo, 1);
    //		int addedYPosition = UiTestUtils.getAddedListItemYPosition(solo);
    //
    //		Sprite sprite = ProjectManager.getInstance().getCurrentSprite();
    //		assertEquals("Incorrect number of Scripts.", 2, sprite.getNumberOfScripts());
    //
    //		solo.goBack();
    //
    //		yPosition = UiTestUtils.getListItemYPositions(solo, 1);
    //		solo.clickOnScreen(20, yPosition.get(3));
    //		clickOnDeleteInDialog();
    //
    //		assertEquals("Incorrect number of bricks.", 1, projectBrickList.size());
    //		assertTrue("Wrong Brick instance.", projectBrickList.get(0) instanceof ChangeYByNBrick);
    //
    //		yPosition = UiTestUtils.getListItemYPositions(solo, 1);
    //		UiTestUtils.longClickAndDrag(solo, 10, yPosition.get(1), 10, yPosition.get(2) + 20, 20);
    //		assertEquals("Incorrect number of bricks.", 0, projectBrickList.size());
    //		projectBrickList = project.getSpriteList().get(0).getScript(1).getBrickList();
    //		assertEquals("Incorrect number of bricks.", 1, projectBrickList.size());
    //		assertTrue("Wrong Brick instance.", projectBrickList.get(0) instanceof ChangeYByNBrick);
    //
    //		UiTestUtils.addNewBrick(solo, R.string.brick_if_begin);
    //		yPosition = UiTestUtils.getListItemYPositions(solo, 1);
    //		addedYPosition = UiTestUtils.getAddedListItemYPosition(solo);
    //		solo.drag(20, 20, addedYPosition, yPosition.get(3) + 20, 20);
    //
    //		UiTestUtils.addNewBrick(solo, R.string.brick_set_look);
    //		yPosition = UiTestUtils.getListItemYPositions(solo, 1);
    //		addedYPosition = UiTestUtils.getAddedListItemYPosition(solo);
    //		solo.drag(20, 20, addedYPosition, yPosition.get(5) + 20, 20);
    //
    //		yPosition = UiTestUtils.getListItemYPositions(solo, 1);
    //		UiTestUtils.longClickAndDrag(solo, 10, yPosition.get(4), 10, yPosition.get(5) + 20, 20);
    //		projectBrickList = project.getSpriteList().get(0).getScript(1).getBrickList();
    //
    //		assertTrue("Wrong Brick instance.", projectBrickList.get(0) instanceof ChangeYByNBrick);
    //		assertTrue("Wrong Brick instance.", projectBrickList.get(1) instanceof IfLogicBeginBrick);
    //		assertTrue("Wrong Brick instance.", projectBrickList.get(2) instanceof SetLookBrick);
    //		assertTrue("Wrong Brick instance.", projectBrickList.get(3) instanceof IfLogicElseBrick);
    //		assertTrue("Wrong Brick instance.", projectBrickList.get(4) instanceof IfLogicEndBrick);
  }