示例#1
0
  public void testBehaviourWithoutBricks() {
    Project project = ProjectManager.getInstance().getCurrentProject();
    assertNotNull("current project was null", project);

    Sprite blueSprite = project.getSpriteList().get(4);
    while (blueSprite.getNumberOfScripts() > 0) {
      blueSprite.removeScript(blueSprite.getScript(0));
    }

    assertEquals("there shouldn't be any script left", 0, blueSprite.getNumberOfScripts());
    assertEquals("there shouldn't be any script left", 0, blueSprite.getNumberOfBricks());
    StorageHandler.getInstance().loadProject(project.getName());

    solo.waitForActivity(StageActivity.class.getSimpleName());
    solo.sleep(1400);

    byte[] screenArray = StageActivity.stageListener.getPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        BLUE_PIXEL, screenArray, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        BLUE_PIXEL, screenArray, -19, -19, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        BLUE_PIXEL, screenArray, -19, 19, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        BLUE_PIXEL, screenArray, 19, -19, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        BLUE_PIXEL, screenArray, 19, 19, SCREEN_WIDTH, SCREEN_HEIGHT);

    solo.sleep(2000);
  }
示例#2
0
  @Device
  public void testShowTexture() {
    solo.waitForActivity(StageActivity.class.getSimpleName());
    solo.sleep(1400);
    byte[] screenArray = StageActivity.stageListener.getPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);

    UiTestUtils.comparePixelArrayWithPixelScreenArrayWithTolerance(
        WHITE_PIXEL, screenArray, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);

    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        RED_PIXEL, screenArray, -41, -41, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        RED_PIXEL, screenArray, -41, -2, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        RED_PIXEL, screenArray, -2, -41, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        RED_PIXEL, screenArray, -2, -2, SCREEN_WIDTH, SCREEN_HEIGHT);

    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        GREEN_PIXEL, screenArray, 1, -2, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        GREEN_PIXEL, screenArray, 40, -2, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        GREEN_PIXEL, screenArray, 1, -41, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        GREEN_PIXEL, screenArray, 40, -41, SCREEN_WIDTH, SCREEN_HEIGHT);

    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        YELLOW_PIXEL, screenArray, -21, 21, SCREEN_WIDTH, SCREEN_HEIGHT);

    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        WHITE_PIXEL, screenArray, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);

    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        BLACK_PIXEL, screenArray, -54, 55, SCREEN_WIDTH, SCREEN_HEIGHT);

    solo.clickOnScreen((SCREEN_WIDTH / 2) + 21, (SCREEN_HEIGHT / 2) - 21);
    solo.sleep(300);
    screenArray = StageActivity.stageListener.getPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        BLUE_PIXEL, screenArray, 21, 21, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        BLUE_PIXEL, screenArray, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        BLUE_PIXEL, screenArray, 21 - 40, 21 - 40, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        RED_PIXEL, screenArray, 21 - 41, 21 - 41, SCREEN_WIDTH, SCREEN_HEIGHT);

    solo.clickOnScreen((SCREEN_WIDTH / 2) - 21, (SCREEN_HEIGHT / 2) - 21);
    solo.sleep(300);
    screenArray = StageActivity.stageListener.getPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        WHITE_PIXEL, screenArray, -31, 21, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        BLUE_PIXEL, screenArray, 21, 21, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        RED_PIXEL, screenArray, -41, -41, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        GREEN_PIXEL, screenArray, 40, -41, SCREEN_WIDTH, SCREEN_HEIGHT);

    solo.clickOnScreen((SCREEN_WIDTH / 2) + 21, (SCREEN_HEIGHT / 2) + 21);
    solo.sleep(300);
    screenArray = StageActivity.stageListener.getPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        GREEN_PIXEL, screenArray, 1, -2, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        GREEN_PIXEL, screenArray, 40, -2, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        GREEN_PIXEL, screenArray, 1, -41, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        GREEN_PIXEL, screenArray, 40, -41, SCREEN_WIDTH, SCREEN_HEIGHT);

    solo.clickOnScreen((SCREEN_WIDTH / 2) - 21, (SCREEN_HEIGHT / 2) + 21);
    solo.sleep(300);
    screenArray = StageActivity.stageListener.getPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        RED_BRIGHTNESS_PIXEL, screenArray, -21, -21, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        RED_BRIGHTNESS_PIXEL, screenArray, -21, -21 + 27, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        GREEN_PIXEL, screenArray, 1, -2, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        GREEN_PIXEL, screenArray, 40, -2, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        GREEN_PIXEL, screenArray, 1, -41, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        GREEN_PIXEL, screenArray, 40, -41, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        BLUE_PIXEL, screenArray, 21, 21, SCREEN_WIDTH, SCREEN_HEIGHT);

    solo.clickOnScreen((SCREEN_WIDTH / 2) - 50, (SCREEN_HEIGHT / 2) - 50);
    solo.sleep(300);
    screenArray = StageActivity.stageListener.getPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    UiTestUtils.comparePixelArrayWithPixelScreenArray(
        BLACK_BRIGHTNESS_PIXEL, screenArray, -54, 55, SCREEN_WIDTH, SCREEN_HEIGHT);
  }