コード例 #1
0
 @Override
 public void tearDown() throws Exception {
   UiTestUtils.goBackToHome(getInstrumentation());
   solo.finishOpenedActivities();
   UiTestUtils.clearAllUtilTestProjects();
   super.tearDown();
 }
コード例 #2
0
  public void testSelectCostumeAndPlay() {
    solo.clickOnText(getActivity().getString(R.string.broadcast_nothing_selected));
    solo.clickOnText(costumeName);
    assertTrue(costumeName + " is not selected in Spinner", solo.searchText(costumeName));

    UiTestUtils.clickOnActionBar(solo, R.id.menu_start);
    solo.sleep(7000);

    solo.waitForActivity(StageActivity.class.getSimpleName());
    solo.sleep(2000);
    Costume costume =
        ProjectManager.getInstance().getCurrentProject().getSpriteList().get(0).costume;
    assertEquals(
        "costume not set", costume.getImagePath(), costumeDataList.get(0).getAbsolutePath());
    solo.goBack();
    solo.goBack();
    solo.waitForActivity(ScriptTabActivity.class.getSimpleName());

    solo.clickOnText(costumeName);
    solo.clickOnText(costumeName2);
    assertTrue(costumeName2 + " is not selected in Spinner", solo.searchText(costumeName2));
    UiTestUtils.clickOnActionBar(solo, R.id.menu_start);
    solo.waitForActivity(StageActivity.class.getSimpleName());
    solo.sleep(2000);
    costume = ProjectManager.getInstance().getCurrentProject().getSpriteList().get(0).costume;
    assertEquals(
        "costume not set", costume.getImagePath(), costumeDataList.get(1).getAbsolutePath());
  }
コード例 #3
0
ファイル: StageDialogTest.java プロジェクト: crayons/Catroid
  public void testRestartButtonActivityChain() throws NameNotFoundException, IOException {
    createAndSaveTestProject(testProject);
    solo.clickOnButton(getActivity().getString(R.string.my_projects));
    solo.waitForActivity(MyProjectsActivity.class.getSimpleName());
    solo.waitForFragmentById(R.id.fr_projects_list);
    assertTrue("Cannot click project.", UiTestUtils.clickOnTextInList(solo, testProject));
    solo.waitForActivity(ProjectActivity.class.getSimpleName());

    Activity currentActivity = solo.getCurrentActivity();

    UiTestUtils.clickOnActionBar(solo, R.id.menu_start);
    solo.waitForActivity(StageActivity.class.getSimpleName());
    solo.goBack();
    solo.sleep(100);
    solo.clickOnButton(getActivity().getString(R.string.restart_current_project));
    solo.waitForActivity(StageActivity.class.getSimpleName());
    solo.assertCurrentActivity("Program is not in stage activity", StageActivity.class);

    solo.sleep(500);
    solo.goBack();
    solo.sleep(100);
    solo.clickOnButton(getActivity().getString(R.string.back));
    solo.waitForActivity(ProjectActivity.class.getSimpleName());
    assertEquals("Returned to wrong Activity", currentActivity, solo.getCurrentActivity());
  }
コード例 #4
0
  /**
   * For some unknown reason the brick stays hovering and invisible after MotionEvent.ACTION_DOWN.
   * This behavior appears only in a test, not in the application itself.
   */
  @Smoke
  public void testMoveBrickAcrossScript() {
    //		ScriptTabActivity activity = (ScriptTabActivity) solo.getCurrentActivity();
    //		ScriptFragment fragment = (ScriptFragment)
    // activity.getTabFragment(ScriptTabActivity.INDEX_TAB_SCRIPTS);
    //		BrickAdapter adapter = fragment.getAdapter();

    ArrayList<Integer> yPositionList = UiTestUtils.getListItemYPositions(solo);
    assertTrue("Test project brick list smaller than expected", yPositionList.size() >= 6);

    int numberOfBricks = ProjectManager.getInstance().getCurrentScript().getBrickList().size();
    UiTestUtils.longClickAndDrag(solo, 10, yPositionList.get(7), 10, yPositionList.get(2), 20);
    assertTrue(
        "Number of Bricks inside Script hasn't changed",
        (numberOfBricks + 1)
            == ProjectManager.getInstance().getCurrentScript().getBrickList().size());
    longClickAndDrag(10, yPositionList.get(7), 10, yPositionList.get(2), 20);
    //		assertTrue("Number of Bricks inside Script hasn't changed", (numberOfBricks - 1) ==
    // ProjectManager
    //				.getInstance().getCurrentSprite().getScript(0).getBrickList().size());
    //
    //		assertEquals("Incorrect Brick after dragging over Script", (Brick) adapter.getItem(7)
    // instanceof WaitBrick,
    //				true);
  }
コード例 #5
0
ファイル: StageDialogTest.java プロジェクト: crayons/Catroid
 @Override
 protected void tearDown() throws Exception {
   UiTestUtils.goBackToHome(getInstrumentation());
   solo.finishOpenedActivities();
   ProjectManager.getInstance().deleteCurrentProject();
   UiTestUtils.clearAllUtilTestProjects();
   super.tearDown();
 }
コード例 #6
0
  @Override
  public void setUp() throws Exception {
    super.setUp();
    UiTestUtils.clearAllUtilTestProjects();

    ProjectManager projectManager = ProjectManager.getInstance();
    Project project = new Project(null, UiTestUtils.DEFAULT_TEST_PROJECT_NAME);
    Sprite firstSprite = new Sprite("cat");
    Script testScript = new StartScript(firstSprite);

    SetCostumeBrick setCostumeBrick = new SetCostumeBrick(firstSprite);
    testScript.addBrick(setCostumeBrick);

    firstSprite.addScript(testScript);
    project.addSprite(firstSprite);

    projectManager.setProject(project);
    projectManager.setCurrentSprite(firstSprite);
    projectManager.setCurrentScript(testScript);
    costumeDataList = projectManager.getCurrentSprite().getCostumeDataList();

    costumeFile =
        UiTestUtils.saveFileToProject(
            UiTestUtils.DEFAULT_TEST_PROJECT_NAME,
            "image.png",
            RESOURCE_COSTUME,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);
    CostumeData costumeData = new CostumeData();
    costumeData.setCostumeFilename(costumeFile.getName());
    costumeData.setCostumeName(costumeName);

    costumeFile2 =
        UiTestUtils.saveFileToProject(
            UiTestUtils.DEFAULT_TEST_PROJECT_NAME,
            "image2.png",
            RESOURCE_COSTUME2,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);
    CostumeData costumeData2 = new CostumeData();
    costumeData2.setCostumeFilename(costumeFile2.getName());
    costumeData2.setCostumeName(costumeName2);

    costumeDataList.add(costumeData);
    costumeDataList.add(costumeData2);
    ProjectManager.getInstance()
        .getFileChecksumContainer()
        .addChecksum(costumeData.getChecksum(), costumeData.getAbsolutePath());
    ProjectManager.getInstance()
        .getFileChecksumContainer()
        .addChecksum(costumeData2.getChecksum(), costumeData2.getAbsolutePath());

    solo = new Solo(getInstrumentation(), getActivity());

    Intent intent = new Intent(getActivity(), ScriptTabActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    getActivity().startActivity(intent);
  }
コード例 #7
0
ファイル: StageDialogTest.java プロジェクト: crayons/Catroid
  public void testRestartProjectWithSound() {
    String projectName = UiTestUtils.PROJECTNAME1;
    // creating sprites for project:
    Sprite firstSprite = new Sprite("sprite1");
    Script startScript = new StartScript(firstSprite);

    PlaySoundBrick playSoundBrick = new PlaySoundBrick(firstSprite);

    startScript.addBrick(playSoundBrick);

    firstSprite.addScript(startScript);

    ArrayList<Sprite> spriteList = new ArrayList<Sprite>();
    spriteList.add(firstSprite);
    Project project = UiTestUtils.createProject(projectName, spriteList, getActivity());

    File soundFile =
        UiTestUtils.saveFileToProject(
            projectName,
            "soundfile.mp3",
            at.tugraz.ist.catroid.uitest.R.raw.longsound,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.SOUND);

    SoundInfo soundInfo = new SoundInfo();
    soundInfo.setSoundFileName(soundFile.getName());
    soundInfo.setTitle(soundFile.getName());
    playSoundBrick.setSoundInfo(soundInfo);

    firstSprite.getSoundList().add(soundInfo);

    storageHandler.saveProject(project);

    MediaPlayer mediaPlayer = SoundManager.getInstance().getMediaPlayer();
    UiTestUtils.clickOnActionBar(solo, R.id.menu_start);
    solo.waitForActivity(StageActivity.class.getSimpleName());
    solo.sleep(1000);
    assertTrue("Sound not playing.", mediaPlayer.isPlaying());
    int positionBeforeRestart = mediaPlayer.getCurrentPosition();
    solo.goBack();
    solo.sleep(500);
    assertFalse("Sound playing but should be paused.", mediaPlayer.isPlaying());
    solo.clickOnButton(getActivity().getString(R.string.restart_current_project));
    solo.sleep(300);
    @SuppressWarnings("unchecked")
    ArrayList<MediaPlayer> mediaPlayerArrayList =
        (ArrayList<MediaPlayer>)
            UiTestUtils.getPrivateField("mediaPlayers", SoundManager.getInstance());
    int positionAfterRestart = mediaPlayerArrayList.get(0).getCurrentPosition();
    assertTrue("Sound not playing after stage restart.", mediaPlayerArrayList.get(0).isPlaying());
    assertTrue("Sound did not play from start!", positionBeforeRestart > positionAfterRestart);
  }
コード例 #8
0
 @Override
 public void tearDown() throws Exception {
   UiTestUtils.goBackToHome(getInstrumentation());
   solo.finishOpenedActivities();
   UiTestUtils.clearAllUtilTestProjects();
   if (costumeFile.exists()) {
     costumeFile.delete();
   }
   if (costumeFile2.exists()) {
     costumeFile2.delete();
   }
   super.tearDown();
 }
コード例 #9
0
  public void testAdapterUpdateInScriptActivity() {
    String costume1ImagePath = costumeDataList.get(0).getAbsolutePath();
    String costume2ImagePath = costumeDataList.get(1).getAbsolutePath();
    solo.clickOnText(getActivity().getString(R.string.broadcast_nothing_selected));
    solo.clickOnText(costumeName);

    UiTestUtils.clickOnActionBar(solo, R.id.menu_start);
    solo.waitForActivity(StageActivity.class.getSimpleName());
    String costumePath =
        ProjectManager.getInstance()
            .getCurrentSprite()
            .getCostumeDataList()
            .get(0)
            .getAbsolutePath();
    assertEquals(
        "Wrong image shown in stage --> Problem with Adapter update in Script",
        costume1ImagePath,
        costumePath);
    solo.goBack();
    solo.sleep(500);
    solo.goBack();
    for (int i = 0; i < 5; i++) {
      selectCostume(costumeName2, costumeName, costume2ImagePath);
      selectCostume(costumeName, costumeName2, costume1ImagePath);
    }
  }
コード例 #10
0
ファイル: StageDialogTest.java プロジェクト: crayons/Catroid
  public void testPauseOnBackButton() {
    double scale = 100.0;

    Project project = new Project(getActivity(), testProject);
    Sprite sprite = new Sprite("testSprite");
    Script script = new StartScript(sprite);
    WaitBrick waitBrick = new WaitBrick(sprite, 5000);
    SetSizeToBrick scaleCostumeBrick = new SetSizeToBrick(sprite, scale);

    script.addBrick(waitBrick);
    script.addBrick(scaleCostumeBrick);
    sprite.addScript(script);
    project.addSprite(sprite);

    storageHandler.saveProject(project);
    ProjectManager.getInstance().setProject(project);

    UiTestUtils.clickOnActionBar(solo, R.id.menu_start);

    //		assertEquals("Unexpected sprite size", 100.0, sprite.getSize());
    //		solo.goBack();
    //		solo.sleep(6000);
    //		solo.goBack();
    //		assertEquals("Unexpected sprite size", 100.0, sprite.getSize());
    //		solo.sleep(4000);
    //		assertEquals("Unexpected sprite size", scale, sprite.getSize());
  }
コード例 #11
0
ファイル: StageDialogTest.java プロジェクト: crayons/Catroid
  public void testBackToPreviousActivity() throws NameNotFoundException, IOException {
    createAndSaveTestProject(testProject);
    solo.clickOnButton(getActivity().getString(R.string.my_projects));
    solo.waitForActivity(MyProjectsActivity.class.getSimpleName());
    solo.waitForFragmentById(R.id.fr_projects_list);
    assertTrue("Cannot click project.", UiTestUtils.clickOnTextInList(solo, testProject));
    solo.waitForActivity(ProjectActivity.class.getSimpleName());

    Activity previousActivity = getActivity();
    UiTestUtils.clickOnActionBar(solo, R.id.menu_start);
    solo.waitForActivity(StageActivity.class.getSimpleName());

    solo.goBack();
    solo.clickOnButton(getActivity().getString(R.string.back));

    solo.waitForActivity(ProjectActivity.class.getSimpleName());
    assertEquals("Not equal Activities", previousActivity, getActivity());
  }
コード例 #12
0
ファイル: StageDialogTest.java プロジェクト: crayons/Catroid
  public void testRestartButtonScriptPosition() {
    ArrayList<Integer> scriptPositionsStart = new ArrayList<Integer>();
    ArrayList<Integer> scriptPositionsRestart = new ArrayList<Integer>();
    scriptPositionsStart.clear();
    scriptPositionsRestart.clear();

    UiTestUtils.clickOnActionBar(solo, R.id.menu_start);
    solo.waitForActivity(StageActivity.class.getSimpleName());
    solo.sleep(1000);

    ProjectManager projectManager = ProjectManager.getInstance();
    Project projectStart = projectManager.getCurrentProject();

    String projectNameStart = projectStart.getName();

    // scriptPositions at start
    List<Sprite> spriteList = projectStart.getSpriteList();
    for (int i = 0; i < spriteList.size(); i++) {
      Sprite sprite = spriteList.get(i);
      int size = sprite.getNumberOfScripts();
      for (int j = 0; j < size; j++) {
        scriptPositionsRestart.add(sprite.getScript(j).getExecutingBrickIndex());
      }
    }
    spriteList.clear();

    solo.clickOnScreen(Values.SCREEN_WIDTH / 2, Values.SCREEN_HEIGHT / 2);
    solo.sleep(200);
    solo.goBack();
    solo.sleep(100);
    solo.clickOnButton(getActivity().getString(R.string.restart_current_project));
    solo.sleep(300);

    // scriptPositions in between
    Project projectRestart = ProjectManager.getInstance().getCurrentProject();
    String projectNameRestart = projectRestart.getName();

    assertEquals("Wrong project after restart", projectNameStart, projectNameRestart);

    spriteList = projectRestart.getSpriteList();
    for (int i = 0; i < spriteList.size(); i++) {
      Sprite sprite = spriteList.get(i);
      int size = sprite.getNumberOfScripts();
      for (int j = 0; j < size; j++) {
        scriptPositionsRestart.add(sprite.getScript(j).getExecutingBrickIndex());
      }
    }

    for (int i = 0; i < scriptPositionsStart.size(); i++) {
      assertEquals(
          "Script is not at starting position!",
          scriptPositionsStart.get(i).intValue(),
          scriptPositionsRestart.get(i).intValue());
    }
  }
コード例 #13
0
ファイル: StageDialogTest.java プロジェクト: crayons/Catroid
  public void testBackButtonPressedTwice() throws NameNotFoundException, IOException {
    Project project = createTestProject(testProject);
    ProjectManager.getInstance().setProject(project);

    UiTestUtils.clickOnActionBar(solo, R.id.menu_start);
    solo.waitForActivity(StageActivity.class.getSimpleName());
    solo.sleep(1000);
    solo.goBack();

    solo.goBack();
    solo.waitForActivity(MainMenuActivity.class.getSimpleName());
    solo.assertCurrentActivity("Program is not in stage activity", MainMenuActivity.class);
  }
コード例 #14
0
 public void selectCostume(String newCostume, String oldName, String costumeImagePath) {
   solo.clickOnText(oldName);
   solo.clickOnText(newCostume);
   UiTestUtils.clickOnActionBar(solo, R.id.menu_start);
   solo.sleep(5000);
   solo.waitForActivity(StageActivity.class.getSimpleName());
   solo.sleep(2000);
   String costumePath = ProjectManager.getInstance().getCurrentSprite().costume.getImagePath();
   assertEquals(
       "Wrong image shown in stage --> Problem with Adapter update in Script",
       costumeImagePath,
       costumePath);
   solo.goBack();
   solo.goBack();
 }
コード例 #15
0
ファイル: StageDialogTest.java プロジェクト: crayons/Catroid
 @Override
 public void setUp() throws Exception {
   super.setUp();
   UiTestUtils.clearAllUtilTestProjects();
   solo = new Solo(getInstrumentation(), getActivity());
 }
コード例 #16
0
ファイル: StageDialogTest.java プロジェクト: crayons/Catroid
  public void testMaximizeStretch() throws NameNotFoundException, IOException {
    Project project = createTestProject(testProject);
    project.virtualScreenWidth = 480;
    project.virtualScreenHeight = 700;
    project.setDeviceData(getActivity());
    storageHandler.saveProject(project);
    solo.clickOnButton(getActivity().getString(R.string.my_projects));
    solo.waitForActivity(MyProjectsActivity.class.getSimpleName());
    solo.waitForFragmentById(R.id.fr_projects_list);
    assertTrue("Cannot click project.", UiTestUtils.clickOnTextInList(solo, testProject));
    solo.waitForActivity(ProjectActivity.class.getSimpleName());

    Utils.updateScreenWidthAndHeight(getActivity());
    UiTestUtils.clickOnActionBar(solo, R.id.menu_start);
    solo.waitForActivity(StageActivity.class.getSimpleName());
    assertTrue(
        "Stage not resizeable.", ((StageActivity) solo.getCurrentActivity()).getResizePossible());
    byte[] whitePixel = {(byte) 255, (byte) 255, (byte) 255, (byte) 255};
    byte[] screenPixel = StageActivity.stageListener.getPixels(0, 0, 1, 1);
    UiTestUtils.compareByteArrays(whitePixel, screenPixel);
    screenPixel =
        StageActivity.stageListener.getPixels(
            Values.SCREEN_WIDTH - 1, Values.SCREEN_HEIGHT - 1, 1, 1);
    UiTestUtils.compareByteArrays(whitePixel, screenPixel);
    screenPixel = StageActivity.stageListener.getPixels(Values.SCREEN_WIDTH - 1, 0, 1, 1);
    UiTestUtils.compareByteArrays(whitePixel, screenPixel);
    screenPixel = StageActivity.stageListener.getPixels(0, Values.SCREEN_HEIGHT - 1, 1, 1);
    UiTestUtils.compareByteArrays(whitePixel, screenPixel);
    solo.goBack();
    solo.clickOnButton(getActivity().getString(R.string.stagemenu_screen_size));
    solo.clickOnButton(getActivity().getString(R.string.resume_current_project));
    solo.sleep(100);
    byte[] blackPixel = {0, 0, 0, (byte) 255};
    screenPixel = StageActivity.stageListener.getPixels(0, 0, 1, 1);
    UiTestUtils.compareByteArrays(blackPixel, screenPixel);
    screenPixel =
        StageActivity.stageListener.getPixels(
            Values.SCREEN_WIDTH - 1, Values.SCREEN_HEIGHT - 1, 1, 1);
    UiTestUtils.compareByteArrays(blackPixel, screenPixel);
    screenPixel = StageActivity.stageListener.getPixels(Values.SCREEN_WIDTH - 1, 0, 1, 1);
    UiTestUtils.compareByteArrays(blackPixel, screenPixel);
    screenPixel = StageActivity.stageListener.getPixels(0, Values.SCREEN_HEIGHT - 1, 1, 1);
    UiTestUtils.compareByteArrays(blackPixel, screenPixel);

    screenPixel =
        StageActivity.stageListener.getPixels(Values.SCREEN_WIDTH, Values.SCREEN_HEIGHT, 1, 1);
    UiTestUtils.compareByteArrays(whitePixel, screenPixel);

    solo.goBack();
    solo.clickOnButton(getActivity().getString(R.string.stagemenu_screen_size));
    solo.clickOnButton(getActivity().getString(R.string.resume_current_project));
    solo.sleep(100);
    screenPixel = StageActivity.stageListener.getPixels(0, 0, 1, 1);
    UiTestUtils.compareByteArrays(whitePixel, screenPixel);
    screenPixel =
        StageActivity.stageListener.getPixels(
            Values.SCREEN_WIDTH - 1, Values.SCREEN_HEIGHT - 1, 1, 1);
    UiTestUtils.compareByteArrays(whitePixel, screenPixel);
    screenPixel = StageActivity.stageListener.getPixels(Values.SCREEN_WIDTH - 1, 0, 1, 1);
    UiTestUtils.compareByteArrays(whitePixel, screenPixel);
    screenPixel = StageActivity.stageListener.getPixels(0, Values.SCREEN_HEIGHT - 1, 1, 1);
    UiTestUtils.compareByteArrays(whitePixel, screenPixel);
  }
コード例 #17
0
ファイル: StageDialogTest.java プロジェクト: crayons/Catroid
 public void testAxesOnOff() throws NameNotFoundException, IOException {
   createAndSaveTestProject(testProject);
   solo.clickOnButton(getActivity().getString(R.string.my_projects));
   solo.waitForActivity(MyProjectsActivity.class.getSimpleName());
   solo.waitForFragmentById(R.id.fr_projects_list);
   assertTrue("Cannot click project.", UiTestUtils.clickOnTextInList(solo, testProject));
   solo.waitForActivity(ProjectActivity.class.getSimpleName());
   UiTestUtils.clickOnActionBar(solo, R.id.menu_start);
   solo.waitForActivity(StageActivity.class.getSimpleName());
   solo.goBack();
   solo.clickOnButton(getActivity().getString(R.string.stagemenu_axes_on));
   solo.clickOnButton(getActivity().getString(R.string.resume_current_project));
   solo.sleep(100);
   byte[] redPixel = {(byte) 255, 0, 0, (byte) 255};
   byte[] stagePixel =
       StageActivity.stageListener.getPixels(
           Values.SCREEN_WIDTH / 2, Values.SCREEN_HEIGHT / 2, 1, 1);
   UiTestUtils.compareByteArrays(redPixel, stagePixel);
   stagePixel = StageActivity.stageListener.getPixels(Values.SCREEN_WIDTH / 2, 0, 1, 1);
   UiTestUtils.compareByteArrays(redPixel, stagePixel);
   stagePixel =
       StageActivity.stageListener.getPixels(
           Values.SCREEN_WIDTH - 1, Values.SCREEN_HEIGHT / 2, 1, 1);
   UiTestUtils.compareByteArrays(redPixel, stagePixel);
   stagePixel = StageActivity.stageListener.getPixels(0, Values.SCREEN_HEIGHT / 2, 1, 1);
   UiTestUtils.compareByteArrays(redPixel, stagePixel);
   stagePixel =
       StageActivity.stageListener.getPixels(Values.SCREEN_WIDTH / 2, Values.SCREEN_HEIGHT, 1, 1);
   UiTestUtils.compareByteArrays(redPixel, stagePixel);
   solo.goBack();
   solo.clickOnButton(getActivity().getString(R.string.stagemenu_axes_off));
   solo.clickOnButton(getActivity().getString(R.string.resume_current_project));
   solo.sleep(100);
   byte[] whitePixel = {(byte) 255, (byte) 255, (byte) 255, (byte) 255};
   stagePixel =
       StageActivity.stageListener.getPixels(
           Values.SCREEN_WIDTH / 2, Values.SCREEN_HEIGHT / 2, 1, 1);
   UiTestUtils.compareByteArrays(whitePixel, stagePixel);
   stagePixel = StageActivity.stageListener.getPixels(Values.SCREEN_WIDTH / 2, 0, 1, 1);
   UiTestUtils.compareByteArrays(whitePixel, stagePixel);
   stagePixel =
       StageActivity.stageListener.getPixels(
           Values.SCREEN_WIDTH - 1, Values.SCREEN_HEIGHT / 2, 1, 1);
   UiTestUtils.compareByteArrays(whitePixel, stagePixel);
   stagePixel = StageActivity.stageListener.getPixels(0, Values.SCREEN_HEIGHT / 2, 1, 1);
   UiTestUtils.compareByteArrays(whitePixel, stagePixel);
   stagePixel =
       StageActivity.stageListener.getPixels(Values.SCREEN_WIDTH / 2, Values.SCREEN_HEIGHT, 1, 1);
   UiTestUtils.compareByteArrays(whitePixel, stagePixel);
 }
コード例 #18
0
  @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());
  }
コード例 #19
0
 @Override
 public void setUp() throws Exception {
   createProject(UiTestUtils.DEFAULT_TEST_PROJECT_NAME);
   solo = new Solo(getInstrumentation(), getActivity());
   UiTestUtils.getIntoScriptTabActivityFromMainMenu(solo);
 }