public void testBoundaries() {
    Project project = new Project(getContext(), "testProject");
    Group parentGroup = new Group();

    Sprite firstSprite = new Sprite("firstSprite");
    parentGroup.addActor(firstSprite.look);
    project.addSprite(firstSprite);

    for (int i = 0; i < 10; i++) {
      Sprite sprite = new Sprite("testSprite" + i);
      parentGroup.addActor(sprite.look);
      sprite.look.setZIndex(Integer.MAX_VALUE);
      project.addSprite(sprite);
    }

    ProjectManager.getInstance().setProject(project);

    ComeToFrontAction action = ExtendedActions.comeToFront(firstSprite);
    firstSprite.look.addAction(action);
    action.act(1.0f);

    assertEquals(
        "An Integer overflow occured during ComeToFrontBrick Execution",
        getZMaxValue(firstSprite),
        firstSprite.look.getZIndex());
  }
Ejemplo n.º 2
0
  public void createTestProject(String projectName) {
    StorageHandler storageHandler = StorageHandler.getInstance();
    Project project = new Project(getActivity(), projectName);
    Sprite firstSprite = new Sprite("cat");
    Sprite secondSprite = new Sprite("dog");
    Sprite thirdSprite = new Sprite("horse");
    Sprite fourthSprite = new Sprite("pig");

    project.addSprite(firstSprite);
    project.addSprite(secondSprite);
    project.addSprite(thirdSprite);
    project.addSprite(fourthSprite);

    storageHandler.saveProject(project);
  }
Ejemplo n.º 3
0
  private void createTestProject(String projectName) {
    double size = 0.8;

    Project project = new Project(null, projectName);
    Sprite firstSprite = new Sprite("cat");

    Script testScript = new StartScript();

    brickListToCheck = new ArrayList<Brick>();
    brickListToCheck.add(new HideBrick());
    brickListToCheck.add(new ShowBrick());
    brickListToCheck.add(new SetSizeToBrick(size));

    for (Brick brick : brickListToCheck) {
      testScript.addBrick(brick);
    }

    firstSprite.addScript(testScript);

    project.addSprite(firstSprite);

    ProjectManager.getInstance().setProject(project);
    ProjectManager.getInstance().setCurrentSprite(firstSprite);
    ProjectManager.getInstance().setCurrentScript(testScript);
  }
Ejemplo n.º 4
0
  public void testBroadcastWait() {
    Sprite sprite = new Sprite("spriteOne");
    Script scriptWait = new StartScript(sprite);
    String message = "waitTest";
    BroadcastWaitBrick broadcastWaitBrick = new BroadcastWaitBrick(sprite, message);
    int testPosition = 100;
    SetXBrick setXBrick = new SetXBrick(sprite, testPosition);
    scriptWait.addBrick(broadcastWaitBrick);
    scriptWait.addBrick(setXBrick);
    sprite.addScript(scriptWait);

    BroadcastScript broadcastScript = new BroadcastScript(sprite, message);
    WaitBrick waitBrick = new WaitBrick(sprite, 500);
    int setTestPosition = 20;
    SetXBrick setXBrick2 = new SetXBrick(sprite, setTestPosition);
    broadcastScript.addBrick(waitBrick);
    broadcastScript.addBrick(setXBrick2);
    sprite.addScript(broadcastScript);

    Project project = new Project(getContext(), "testProject");
    project.addSprite(sprite);
    ProjectManager.getInstance().setProject(project);

    sprite.createStartScriptActionSequence();

    while (!sprite.look.getAllActionsAreFinished()) {
      sprite.look.act(1.0f);
    }

    assertEquals(
        "Broadcast and wait failed",
        testPosition,
        (int) sprite.look.getXInUserInterfaceDimensionUnit());
  }
Ejemplo n.º 5
0
  public Project(Context context, String name, boolean landscape) {
    xmlHeader.setProgramName(name);
    xmlHeader.setDescription("");

    if (landscape) {
      ifPortraitSwitchWidthAndHeight();
    } else {
      ifLandscapeSwitchWidthAndHeight();
    }
    if (ScreenValues.SCREEN_HEIGHT == 0 || ScreenValues.SCREEN_WIDTH == 0) {
      Utils.updateScreenWidthAndHeight(context);
    }
    xmlHeader.virtualScreenWidth = ScreenValues.SCREEN_WIDTH;
    xmlHeader.virtualScreenHeight = ScreenValues.SCREEN_HEIGHT;
    setDeviceData(context);

    MessageContainer.clear();

    dataContainer = new DataContainer();

    if (context == null) {
      return;
    }

    Sprite background = new Sprite(context.getString(R.string.background));
    background.look.setZIndex(0);
    addSprite(background);
  }
  public void testComeToFront() {
    Project project = new Project(getContext(), "testProject");
    Group parentGroup = new Group();

    Sprite bottomSprite = new Sprite("catroid");
    parentGroup.addActor(bottomSprite.look);
    assertEquals("Unexpected initial z position of bottomSprite", 0, bottomSprite.look.getZIndex());

    Sprite middleSprite = new Sprite("catroid cat");
    parentGroup.addActor(middleSprite.look);
    assertEquals("Unexpected initial z position of middleSprite", 1, middleSprite.look.getZIndex());

    Sprite topSprite = new Sprite("scratch");
    parentGroup.addActor(topSprite.look);
    assertEquals("Unexpected initial z position of topSprite", 2, topSprite.look.getZIndex());

    project.addSprite(bottomSprite);
    project.addSprite(middleSprite);
    project.addSprite(topSprite);
    ProjectManager.getInstance().setProject(project);

    checkIfEveryZIndexUsedOnlyOnceFromZeroToNMinus1(project);

    ComeToFrontAction action = ExtendedActions.comeToFront(middleSprite);
    middleSprite.look.addAction(action);
    action.act(1.0f);
    assertEquals(
        "bottomSprite z position should now be 2",
        middleSprite.look.getZIndex(),
        getZMaxValue(middleSprite));

    Sprite nextSprite = new Sprite("dog");
    parentGroup.addActor(nextSprite.look);
    project.addSprite(nextSprite);

    assertEquals("Unexpected initial z position of topSprite", 3, nextSprite.look.getZIndex());

    ComeToFrontAction action2 = ExtendedActions.comeToFront(bottomSprite);
    bottomSprite.look.addAction(action);
    action2.act(1.0f);
    assertEquals(
        "bottomSprite z position should now be 3",
        bottomSprite.look.getZIndex(),
        getZMaxValue(bottomSprite));

    checkIfEveryZIndexUsedOnlyOnceFromZeroToNMinus1(project);
  }
Ejemplo n.º 7
0
  private void createProject() {
    Project project = new Project(null, UiTestUtils.PROJECTNAME1);

    Sprite spriteCat = new Sprite(backgroundName);
    Script startScriptCat = new StartScript();
    Script scriptTappedCat = new WhenScript();
    Brick setXBrick = new SetXBrick(50);
    Brick setYBrick = new SetYBrick(50);
    Brick changeXBrick = new ChangeXByNBrick(50);
    startScriptCat.addBrick(setYBrick);
    startScriptCat.addBrick(setXBrick);
    scriptTappedCat.addBrick(changeXBrick);

    spriteCat.addScript(startScriptCat);
    spriteCat.addScript(scriptTappedCat);
    project.addSprite(spriteCat);

    ProjectManager.getInstance().setProject(project);
    ProjectManager.getInstance().setCurrentSprite(spriteCat);
    ProjectManager.getInstance().setCurrentScript(startScriptCat);

    File imageFile =
        UiTestUtils.saveFileToProject(
            project.getName(),
            "catroid_sunglasses.png",
            org.catrobat.catroid.test.R.drawable.catroid_sunglasses,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);

    ProjectManager projectManager = ProjectManager.getInstance();
    List<LookData> lookDataList = projectManager.getCurrentSprite().getLookDataList();
    LookData lookData = new LookData();
    lookData.setLookFilename(imageFile.getName());
    lookData.setLookName("Catroid sun");
    lookDataList.add(lookData);
    projectManager
        .getFileChecksumContainer()
        .addChecksum(lookData.getChecksum(), lookData.getAbsolutePath());

    File soundFile =
        UiTestUtils.saveFileToProject(
            project.getName(),
            "longsound.mp3",
            org.catrobat.catroid.test.R.raw.longsound,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.SOUND);
    SoundInfo soundInfo = new SoundInfo();
    soundInfo.setSoundFileName(soundFile.getName());
    soundInfo.setTitle("longsound");

    List<SoundInfo> soundInfoList = ProjectManager.getInstance().getCurrentSprite().getSoundList();
    soundInfoList.add(soundInfo);
    ProjectManager.getInstance()
        .getFileChecksumContainer()
        .addChecksum(soundInfo.getChecksum(), soundInfo.getAbsolutePath());
  }
Ejemplo n.º 8
0
  public void testAliasesAndXmlHeader() {

    String projectName = "myProject";

    File projectFile = new File(Constants.DEFAULT_ROOT + "/" + projectName);
    if (projectFile.exists()) {
      UtilFile.deleteDirectory(projectFile);
    }

    Project project = new Project(getContext(), projectName);
    Sprite sprite = new Sprite("testSprite");
    Script startScript = new StartScript(sprite);
    Script whenScript = new WhenScript(sprite);
    sprite.addScript(startScript);
    sprite.addScript(whenScript);
    project.addSprite(sprite);

    ArrayList<Brick> startScriptBrickList = new ArrayList<Brick>();
    ArrayList<Brick> whenScriptBrickList = new ArrayList<Brick>();
    startScriptBrickList.add(new ChangeXByNBrick(sprite, 4));
    startScriptBrickList.add(new ChangeYByNBrick(sprite, 5));
    startScriptBrickList.add(new ComeToFrontBrick(sprite));
    startScriptBrickList.add(new GoNStepsBackBrick(sprite, 5));
    startScriptBrickList.add(new HideBrick(sprite));
    startScriptBrickList.add(new WhenStartedBrick(sprite, startScript));

    whenScriptBrickList.add(new PlaySoundBrick(sprite));
    whenScriptBrickList.add(new SetSizeToBrick(sprite, 50));
    whenScriptBrickList.add(new SetCostumeBrick(sprite));
    whenScriptBrickList.add(new SetXBrick(sprite, 50));
    whenScriptBrickList.add(new SetYBrick(sprite, 50));
    whenScriptBrickList.add(new ShowBrick(sprite));
    whenScriptBrickList.add(new WaitBrick(sprite, 1000));

    for (Brick b : startScriptBrickList) {
      startScript.addBrick(b);
    }
    for (Brick b : whenScriptBrickList) {
      whenScript.addBrick(b);
    }

    storageHandler.saveProject(project);
    String projectString = TestUtils.getProjectfileAsString(projectName);
    assertFalse("project contains package information", projectString.contains("org.catrobat"));

    String xmlHeader = (String) TestUtils.getPrivateField("XML_HEADER", new XmlSerializer(), false);
    assertTrue(
        "Project file did not contain correct XML header.", projectString.startsWith(xmlHeader));

    projectFile = new File(Constants.DEFAULT_ROOT + "/" + projectName);
    if (projectFile.exists()) {
      UtilFile.deleteDirectory(projectFile);
    }
  }
Ejemplo n.º 9
0
  private void createProject() {
    project = new Project(null, UiTestUtils.DEFAULT_TEST_PROJECT_NAME);
    Sprite sprite = new Sprite("cat");
    Script script = new StartScript(sprite);
    script.addBrick(new StopAllSoundsBrick(sprite));

    sprite.addScript(script);
    project.addSprite(sprite);

    ProjectManager.getInstance().setProject(project);
    ProjectManager.getInstance().setCurrentSprite(sprite);
    ProjectManager.getInstance().setCurrentScript(script);
  }
  private void createProject() {
    project = new Project(null, UiTestUtils.DEFAULT_TEST_PROJECT_NAME);
    sprite = new Sprite("cat");
    Script script = new StartScript(sprite);
    placeAtBrick = new PlaceAtBrick(sprite, INITIAL_X, INITIAL_Y);
    script.addBrick(placeAtBrick);

    sprite.addScript(script);
    project.addSprite(sprite);

    ProjectManager.getInstance().setProject(project);
    ProjectManager.getInstance().setCurrentSprite(sprite);
    ProjectManager.getInstance().setCurrentScript(script);
  }
Ejemplo n.º 11
0
  private void createProject() {
    ProjectManager projectManager = ProjectManager.getInstance();
    Project project = new Project(null, UiTestUtils.DEFAULT_TEST_PROJECT_NAME);
    Sprite firstSprite = new Sprite("cat");
    Script testScript = new StartScript(firstSprite);

    SetLookBrick setLookBrick = new SetLookBrick(firstSprite);
    testScript.addBrick(setLookBrick);

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

    projectManager.setProject(project);
    projectManager.setCurrentSprite(firstSprite);
    projectManager.setCurrentScript(testScript);
    lookDataList = projectManager.getCurrentSprite().getLookDataList();

    lookFile =
        UiTestUtils.saveFileToProject(
            UiTestUtils.DEFAULT_TEST_PROJECT_NAME,
            "image.png",
            RESOURCE_LOOK,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);
    LookData lookData = new LookData();
    lookData.setLookFilename(lookFile.getName());
    lookData.setLookName(lookName);

    lookFile2 =
        UiTestUtils.saveFileToProject(
            UiTestUtils.DEFAULT_TEST_PROJECT_NAME,
            "image2.png",
            RESOURCE_LOOK2,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);
    LookData lookData2 = new LookData();
    lookData2.setLookFilename(lookFile2.getName());
    lookData2.setLookName(lookName2);

    lookDataList.add(lookData);
    lookDataList.add(lookData2);
    ProjectManager.getInstance()
        .getFileChecksumContainer()
        .addChecksum(lookData.getChecksum(), lookData.getAbsolutePath());
    ProjectManager.getInstance()
        .getFileChecksumContainer()
        .addChecksum(lookData2.getChecksum(), lookData2.getAbsolutePath());
  }
Ejemplo n.º 12
0
  private void createProject() {
    project = new Project(null, UiTestUtils.DEFAULT_TEST_PROJECT_NAME);
    Sprite sprite = new Sprite("cat");
    Script script = new StartScript();

    motorBrick =
        new LegoNxtMotorMoveBrick(LegoNxtMotorMoveBrick.Motor.MOTOR_A, SET_SPEED_INITIALLY);

    script.addBrick(motorBrick);

    sprite.addScript(script);
    project.addSprite(sprite);

    ProjectManager.getInstance().setProject(project);
    ProjectManager.getInstance().setCurrentSprite(sprite);
    ProjectManager.getInstance().setCurrentScript(script);
  }
Ejemplo n.º 13
0
  public void testGetProjectNames() {
    Project project = new Project(null, projectName);
    ProjectManager.getInstance().setProject(project);
    Sprite sprite = new Sprite("new sprite");
    project.addSprite(sprite);
    StorageHandler.getInstance().saveProject(project);

    File catroidDirectoryFile = new File(CATROID_DIRECTORY);
    File project1Directory = new File(catroidDirectoryFile + "/" + projectName);

    List<String> projectList = UtilFile.getProjectNames(catroidDirectoryFile);

    assertTrue(
        "project1 should be in Projectlist - is a valid Catroid project",
        projectList.contains(project1Directory.getName()));
    assertFalse(
        "testDirectory should not be in Projectlist - not a Catroid project",
        projectList.contains(testDirectory.getName()));
  }
Ejemplo n.º 14
0
  private void createProject() {
    project = new Project(null, UiTestUtils.DEFAULT_TEST_PROJECT_NAME);
    sprite = new Sprite("cat");
    Script script = new StartScript(sprite);
    ProjectManager.getInstance().setProject(project);
    ProjectManager.getInstance().setCurrentSprite(sprite);
    ProjectManager.getInstance().setCurrentScript(script);

    userVariablesContainer = project.getUserVariables();
    userVariablesContainer.addProjectUserVariable("p1");
    userVariablesContainer.addProjectUserVariable("p2");
    userVariablesContainer.addSpriteUserVariable("sprite_var1");
    userVariablesContainer.addSpriteUserVariable("sprite_var2");

    setVariableBrick = new SetVariableBrick(sprite, 0.0);
    script.addBrick(setVariableBrick);
    changeVariableBrick = new ChangeVariableBrick(sprite, 1.1);
    script.addBrick(changeVariableBrick);

    sprite.addScript(script);
    project.addSprite(sprite);
  }
Ejemplo n.º 15
0
  private void createProject() {
    project = new Project(null, UiTestUtils.DEFAULT_TEST_PROJECT_NAME);
    Sprite sprite = new Sprite("cat");
    Script script = new StartScript(sprite);
    ifBrick = new IfLogicBeginBrick(sprite, 0);
    IfLogicElseBrick ifElseBrick = new IfLogicElseBrick(sprite, ifBrick);
    IfLogicEndBrick ifEndBrick = new IfLogicEndBrick(sprite, ifElseBrick, ifBrick);
    ifBrick.setElseBrick(ifElseBrick);
    ifBrick.setEndBrick(ifEndBrick);

    script.addBrick(ifBrick);
    script.addBrick(new ChangeYByNBrick(sprite, -10));
    script.addBrick(ifElseBrick);
    script.addBrick(ifEndBrick);

    sprite.addScript(script);
    sprite.addScript(new StartScript(sprite));
    project.addSprite(sprite);

    ProjectManager.getInstance().setProject(project);
    ProjectManager.getInstance().setCurrentSprite(sprite);
    ProjectManager.getInstance().setCurrentScript(script);
  }
Ejemplo n.º 16
0
  @Override
  protected void setUp() {
    this.project = new Project(null, "testProject");
    firstSprite = new Sprite("firstSprite");
    startScript = new StartScript();
    changeBrick = new ChangeSizeByNBrick(10);
    firstSprite.addScript(startScript);
    startScript.addBrick(changeBrick);
    project.addSprite(firstSprite);
    ProjectManager.getInstance().setProject(project);
    ProjectManager.getInstance().setCurrentSprite(firstSprite);

    UserVariablesContainer userVariableContainer =
        ProjectManager.getInstance().getCurrentProject().getUserVariables();
    userVariableContainer
        .addProjectUserVariable(PROJECT_USER_VARIABLE)
        .setValue(USER_VARIABLE_1_VALUE_TYPE_DOUBLE);
    userVariableContainer
        .addSpriteUserVariableToSprite(firstSprite, SPRITE_USER_VARIABLE)
        .setValue(USER_VARIABLE_2_VALUE_TYPE_DOUBLE);
    userVariableContainer
        .addProjectUserVariable(PROJECT_USER_VARIABLE_2)
        .setValue(USER_VARIABLE_3_VALUE_TYPE_STRING);
  }
Ejemplo n.º 17
0
  public void testSerializeProject() {

    int xPosition = 457;
    int yPosition = 598;
    double size = 0.8;

    Project project = new Project(getContext(), "testProject");
    Sprite firstSprite = new Sprite("first");
    Sprite secondSprite = new Sprite("second");
    Sprite thirdSprite = new Sprite("third");
    Sprite fourthSprite = new Sprite("fourth");
    Script testScript = new StartScript(firstSprite);
    Script otherScript = new StartScript(secondSprite);
    HideBrick hideBrick = new HideBrick(firstSprite);
    ShowBrick showBrick = new ShowBrick(firstSprite);
    SetSizeToBrick setSizeToBrick = new SetSizeToBrick(secondSprite, size);
    ComeToFrontBrick comeToFrontBrick = new ComeToFrontBrick(firstSprite);
    PlaceAtBrick placeAtBrick = new PlaceAtBrick(secondSprite, xPosition, yPosition);

    // adding Bricks: ----------------
    testScript.addBrick(hideBrick);
    testScript.addBrick(showBrick);
    testScript.addBrick(setSizeToBrick);
    testScript.addBrick(comeToFrontBrick);

    otherScript.addBrick(placeAtBrick); // secondSprite
    otherScript.setPaused(true);
    // -------------------------------

    firstSprite.addScript(testScript);
    secondSprite.addScript(otherScript);

    project.addSprite(firstSprite);
    project.addSprite(secondSprite);
    project.addSprite(thirdSprite);
    project.addSprite(fourthSprite);

    storageHandler.saveProject(project);

    Project loadedProject = storageHandler.loadProject("testProject");

    ArrayList<Sprite> preSpriteList = (ArrayList<Sprite>) project.getSpriteList();
    ArrayList<Sprite> postSpriteList = (ArrayList<Sprite>) loadedProject.getSpriteList();

    // Test sprite names:
    assertEquals(
        "First sprite does not match after deserialization",
        preSpriteList.get(0).getName(),
        postSpriteList.get(0).getName());
    assertEquals(
        "Second sprite does not match after deserialization",
        preSpriteList.get(1).getName(),
        postSpriteList.get(1).getName());
    assertEquals(
        "Third sprite does not match after deserialization",
        preSpriteList.get(2).getName(),
        postSpriteList.get(2).getName());
    assertEquals(
        "Fourth sprite does not match after deserialization",
        preSpriteList.get(3).getName(),
        postSpriteList.get(3).getName());
    assertEquals(
        "Fifth sprite does not match after deserialization",
        preSpriteList.get(4).getName(),
        postSpriteList.get(4).getName());

    // Test project name:
    assertEquals(
        "Title missmatch after deserialization", project.getName(), loadedProject.getName());

    // Test random brick values
    int actualXPosition =
        (Integer)
            TestUtils.getPrivateField(
                "xPosition", (postSpriteList.get(2).getScript(0).getBrickList().get(0)), false);
    int actualYPosition =
        (Integer)
            TestUtils.getPrivateField(
                "yPosition", (postSpriteList.get(2).getScript(0).getBrickList().get(0)), false);

    double actualSize =
        (Double)
            TestUtils.getPrivateField(
                "size", (postSpriteList.get(1).getScript(0).getBrickList().get(2)), false);

    assertEquals("Size was not deserialized right", size, actualSize);
    assertEquals("XPosition was not deserialized right", xPosition, actualXPosition);
    assertEquals("YPosition was not deserialized right", yPosition, actualYPosition);

    assertFalse("paused should not be set in script", preSpriteList.get(1).getScript(0).isPaused());

    // Test version codes and names
    //		final int preVersionCode = (Integer) TestUtils.getPrivateField("catroidVersionCode",
    // project, false);
    //		final int postVersionCode = (Integer) TestUtils.getPrivateField("catroidVersionCode",
    // loadedProject, false);
    //		assertEquals("Version codes are not equal", preVersionCode, postVersionCode);
    //
    //		final String preVersionName = (String) TestUtils.getPrivateField("catroidVersionName",
    // project, false);
    //		final String postVersionName = (String) TestUtils.getPrivateField("catroidVersionName",
    // loadedProject, false);
    //		assertEquals("Version names are not equal", preVersionName, postVersionName);
  }
Ejemplo n.º 18
0
  private void createProject() {
    ScreenValues.SCREEN_HEIGHT = SCREEN_HEIGHT;
    ScreenValues.SCREEN_WIDTH = SCREEN_WIDTH;

    project = new Project(null, UiTestUtils.DEFAULT_TEST_PROJECT_NAME);

    // yellow Sprite
    Sprite yellowSprite = new Sprite("yellowSprite");
    StartScript yellowStartScript = new StartScript();
    LookData yellowLookData = new LookData();
    String yellowImageName = "yellow_image.bmp";

    yellowLookData.setLookName(yellowImageName);

    yellowSprite.getLookDataList().add(yellowLookData);

    yellowStartScript.addBrick(new PlaceAtBrick(-21, 21));

    yellowSprite.addScript(yellowStartScript);

    WhenScript yellowWhenScript = new WhenScript();
    SetGhostEffectBrick yellowSetGhostEffectBrick = new SetGhostEffectBrick(100d);
    yellowWhenScript.addBrick(yellowSetGhostEffectBrick);

    yellowSprite.addScript(yellowWhenScript);

    // blue Sprite
    Sprite blueSprite = new Sprite("blueSprite");
    StartScript blueStartScript = new StartScript();
    LookData blueLookData = new LookData();
    String blueImageName = "blue_image.bmp";

    blueLookData.setLookName(blueImageName);

    blueSprite.getLookDataList().add(blueLookData);

    blueStartScript.addBrick(new PlaceAtBrick(21, 21));

    blueSprite.addScript(blueStartScript);

    WhenScript blueWhenScript = new WhenScript();
    SetSizeToBrick blueSetSizeToBrick = new SetSizeToBrick(200d);
    blueWhenScript.addBrick(blueSetSizeToBrick);

    blueSprite.addScript(blueWhenScript);

    // green Sprite
    Sprite greenSprite = new Sprite("greenSprite");
    StartScript greenStartScript = new StartScript();
    LookData greenLookData = new LookData();
    String greenImageName = "green_image.bmp";

    greenLookData.setLookName(greenImageName);

    greenSprite.getLookDataList().add(greenLookData);

    greenStartScript.addBrick(new PlaceAtBrick(21, -21));

    greenSprite.addScript(greenStartScript);

    WhenScript greenWhenScript = new WhenScript();
    ComeToFrontBrick greenComeToFrontBrick = new ComeToFrontBrick();
    greenWhenScript.addBrick(greenComeToFrontBrick);

    greenSprite.addScript(greenWhenScript);

    // red Sprite
    Sprite redSprite = new Sprite("redSprite");
    StartScript redStartScript = new StartScript();
    LookData redLookData = new LookData();
    String redImageName = "red_image.bmp";

    redLookData.setLookName(redImageName);

    redSprite.getLookDataList().add(redLookData);

    redStartScript.addBrick(new PlaceAtBrick(-21, -21));

    redSprite.addScript(redStartScript);

    WhenScript redWhenScript = new WhenScript();
    ComeToFrontBrick redComeToFrontBrick = new ComeToFrontBrick();
    SetBrightnessBrick redSetBrightnessBrick = new SetBrightnessBrick(50d);
    TurnLeftBrick redTurnLeftBrick = new TurnLeftBrick(45d);
    redWhenScript.addBrick(redComeToFrontBrick);
    redWhenScript.addBrick(redSetBrightnessBrick);
    redWhenScript.addBrick(redTurnLeftBrick);

    redSprite.addScript(redWhenScript);

    // black Sprite
    Sprite blackSprite = new Sprite("blackSprite");
    StartScript blackStartScript = new StartScript();
    LookData blackLookData = new LookData();
    String blackImageName = "black_image.bmp";

    blackLookData.setLookName(blackImageName);

    blackSprite.getLookDataList().add(blackLookData);

    blackStartScript.addBrick(new PlaceAtBrick(-50, 50));

    blackSprite.addScript(blackStartScript);

    WhenScript blackWhenScript = new WhenScript();
    ComeToFrontBrick blackComeToFrontBrick = new ComeToFrontBrick();
    SetBrightnessBrick blackSetBrightnessBrick = new SetBrightnessBrick(150d);
    blackWhenScript.addBrick(blackComeToFrontBrick);
    blackWhenScript.addBrick(blackSetBrightnessBrick);

    blackSprite.addScript(blackWhenScript);

    project.addSprite(blackSprite);
    project.addSprite(yellowSprite);
    project.addSprite(redSprite);
    project.addSprite(greenSprite);
    project.addSprite(blueSprite);

    StorageHandler.getInstance().saveProject(project);

    File yellowImageFile =
        UiTestUtils.saveFileToProject(
            project.getName(),
            yellowImageName,
            org.catrobat.catroid.test.R.raw.yellow_image,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);
    File greenImageFile =
        UiTestUtils.saveFileToProject(
            project.getName(),
            greenImageName,
            org.catrobat.catroid.test.R.raw.green_image,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);
    File blueImageFile =
        UiTestUtils.saveFileToProject(
            project.getName(),
            blueImageName,
            org.catrobat.catroid.test.R.raw.blue_image,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);
    File redImageFile =
        UiTestUtils.saveFileToProject(
            project.getName(),
            redImageName,
            org.catrobat.catroid.test.R.raw.red_image,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);
    File blackImageFile =
        UiTestUtils.saveFileToProject(
            project.getName(),
            blackImageName,
            org.catrobat.catroid.test.R.raw.black_image,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);
    yellowLookData.setLookFilename(yellowImageFile.getName());
    greenLookData.setLookFilename(greenImageFile.getName());
    blueLookData.setLookFilename(blueImageFile.getName());
    redLookData.setLookFilename(redImageFile.getName());
    blackLookData.setLookFilename(blackImageFile.getName());

    StorageHandler.getInstance().saveProject(project);
    ProjectManager.getInstance().setProject(project);
  }