Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
  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);
  }