Exemple #1
0
  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());
  }
  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);
    }
  }
Exemple #3
0
  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);
  }
Exemple #4
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);
 }
  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 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());
  }
Exemple #7
0
  public void test02_SetTest() {
    Activity testActivity = mSolo.getCurrentActivity();
    mSolo.assertCurrentActivity("Not SspDebugModeActivity Class", SspDebugModeActivity.class);

    mSolo.sleep(EmOperate.TIME_LONG);
    if (!mSolo.isCheckBoxChecked(0)) {
      mSolo.clickOnCheckBox(0);
      mSolo.sleep(EmOperate.TIME_LONG);
      mSolo.clickOnButton(0);

      mSolo.sleep(EmOperate.TIME_SUPER_LONG);

      BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
      // BluetoothAdapterEx adapterEx = BluetoothAdapterEx.getDefaultAdapterEx();
      // adapterEx.setSSPDebugMode(false);
      mSolo.sleep(EmOperate.TIME_SUPER_LONG);
      mSolo.sleep(EmOperate.TIME_SUPER_LONG);
      mSolo.sleep(EmOperate.TIME_SUPER_LONG);
      if (BluetoothAdapter.STATE_OFF != adapter.getState()) {
        adapter.disable();
        int jumpCount = 0;
        while ((BluetoothAdapter.STATE_OFF != adapter.getState()) && (jumpCount++ < 15)) {
          EmOperate.waitSomeTime(EmOperate.TIME_SUPER_LONG);
        }
      }
    } else {

      mSolo.sleep(EmOperate.TIME_SUPER_LONG);
      mSolo.clickOnCheckBox(0);
      mSolo.sleep(EmOperate.TIME_LONG);

      mSolo.goBack();
    }
  }
Exemple #8
0
 public void testAddNote() throws Exception {
   solo.clickOnMenuItem("Add note");
   solo.assertCurrentActivity("Expected NoteEditor activity", "NoteEditor");
   solo.enterText(0, "1");
   solo.goBack();
   solo.clickOnMenuItem("Add note");
   solo.enterText(0, "Note2");
   solo.goBackToActivity("NotesList");
   solo.takeScreenshot();
 }
Exemple #9
0
  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());
    }
  }
 public void testEmptyCourseListClick() {
   ListView listView = (ListView) solo.getView(R.id.courses_list);
   View emptyview = listView.getEmptyView();
   assertEquals("EmptyView shoudl not be visible", View.GONE, emptyview.getVisibility());
   deleteAllCourses();
   assertEquals(0, listView.getCount());
   assertEquals("Empty view should be visible", View.VISIBLE, emptyview.getVisibility());
   solo.clickOnView(emptyview);
   solo.assertCurrentActivity(
       "Current activity shoudl Be the AddCourse Activity", AddCourseActivity.class);
   solo.goBack();
 }
Exemple #11
0
  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);
  }
 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));
 }
 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();
 }
Exemple #14
0
	public void testDebug() {
		assertFalse(solo.searchText("Debug"));

		solo.sendKey(Solo.MENU);
		solo.clickOnText("Einstellungen");
		solo.clickOnText("Debug-Modus");
		solo.goBack();

		assertTrue(solo.searchText("Debug"));
		solo.clickOnText("Debug");

		assertTrue(solo.searchText("Debug SQLite"));

		solo.clickOnText("syncs");
		solo.clickOnText("cafeterias");
		solo.clickOnText("cafeterias_menus");
		solo.clickOnText("feeds");
		solo.clickOnText("feeds_items");
		solo.clickOnText("lectures");
		solo.clickOnText("lectures_items");
		solo.clickOnText("links");
		solo.clickOnText("events");
		solo.clickOnText("news");
		solo.clickOnText("time");
		solo.clickOnText("locations");
		solo.clickOnText("master");

		solo.goBack();
		assertTrue(solo.searchText("Hello World"));

		solo.sendKey(Solo.MENU);
		solo.clickOnText("Einstellungen");
		solo.clickOnText("Debug-Modus");
		solo.goBack();

		assertFalse(solo.searchText("Debug"));
	}
 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();
 }
 public void selectLook(String newLook, String oldName, String lookImagePath) {
   solo.clickOnText(oldName);
   solo.clickOnText(newLook);
   UiTestUtils.clickOnBottomBar(solo, R.id.button_play);
   solo.sleep(5000);
   solo.waitForActivity(StageActivity.class.getSimpleName());
   solo.sleep(2000);
   String lookPath = ProjectManager.getInstance().getCurrentSprite().look.getImagePath();
   assertEquals(
       "Wrong image shown in stage --> Problem with Adapter update in Script",
       lookImagePath,
       lookPath);
   solo.goBack();
   solo.goBack();
 }
  public void testCourseDetails() {
    Course course = CourseContainer.instance().get(0);
    course.exams = SimpleMockCrawler.createExams(course);

    solo.clickOnText("Course #0");

    assertEquals(course.name, ((TextView) solo.getView(R.id.course_name, 0)).getText());

    View exam_view;

    exam_view = solo.getView(R.id.exam_item, 0);
    assertEquals("Course #0", ((TextView) exam_view.findViewById(R.id.course_text)).getText());

    solo.goBack();
  }
  public void test07CloseAndReopenDialog() {
    checkThatTheFilesHaveNotBeenTransferred();

    albert.changeNickName("Alban");
    solo.sleep(500);

    albert.sendFile(me, image.getFile());
    solo.sleep(500);

    checkMainChatMessage("*** Alban is trying to send the file kouchat-1600x1600.png");
    checkActiveFileTransferNotifications(6);
    solo.sleep(500);

    // First try
    openReceiveFileDialog(albert, 6);
    solo.sleep(500);

    checkThatTheDialogIsInFront();
    checkDialogMessage(
        "Alban is trying to send you the file ‘kouchat-1600x1600.png’ (67.16KB). "
            + "Do you want to accept the file transfer?");
    solo.sleep(500);

    // Close dialog without accepting or rejecting
    solo.goBack();
    solo.sleep(500);

    checkThatTheMainChatIsInFront();
    checkActiveFileTransferNotifications(6); // The notification should still be there

    // Second try
    openReceiveFileDialog(albert, 6);
    solo.sleep(500);

    checkThatTheDialogIsInFront();
    checkDialogMessage(
        "Alban is trying to send you the file ‘kouchat-1600x1600.png’ (67.16KB). "
            + "Do you want to accept the file transfer?");
    solo.sleep(500);

    rejectFileTransfer();
    solo.sleep(500);

    checkThatTheMainChatIsInFront();
    checkMainChatMessage("*** You declined to receive kouchat-1600x1600.png from Alban");
    checkThatNoFileTransferNotificationsAreActive();
    checkThatTheFilesHaveNotBeenTransferred();
  }
Exemple #19
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();
  }
Exemple #20
0
  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());
  }
  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));
  }
 public void testAddCourseScreenOriantationChange() {
   ListView listView;
   solo.clickOnView(getActivity().findViewById(R.id.add));
   solo.enterText(0, "Course");
   solo.clickOnEditText(0);
   solo.sendKey(Solo.ENTER);
   solo.waitForText("THE COURSE #2", 1, 5);
   listView = (ListView) solo.getView(android.R.id.list);
   assertEquals("List view should contain 2 items before doing anything", 2, listView.getCount());
   solo.setActivityOrientation(Solo.LANDSCAPE);
   solo.sleep(500);
   listView = (ListView) solo.getView(android.R.id.list);
   solo.sleep(3000);
   assertEquals("List view should't change size after oriantation change", 2, listView.getCount());
   assertEquals(
       "SearchView should not reset.", "Course", solo.getEditText(0).getText().toString());
   solo.goBack();
   solo.goBack();
 }
Exemple #23
0
 private void injectInteraction(View v, String interactionType, String value) {
   if (v != null) {
     requestView(v);
   }
   if (interactionType.equals(CLICK)) {
     click(v);
   } else if (interactionType.equals(LONG_CLICK)) {
     longClick(v);
   } else if (interactionType.equals(BACK)) {
     solo.goBack();
   } else if (interactionType.equals(CHANGE_ORIENTATION)) {
     changeOrientation();
   } else if (interactionType.equals(CLICK_ON_TEXT)) {
     clickOnText(value);
   } else if (interactionType.equals(PRESS_KEY)) {
     pressKey(value);
   } else if (interactionType.equals(OPEN_MENU)) {
     solo.sendKey(Solo.MENU);
   } else if (interactionType.equals(SCROLL_DOWN)) {
     solo.scrollDown();
   } else if (interactionType.equals(SWAP_TAB) && (value != null)) {
     if (v instanceof TabHost) {
       swapTab((TabHost) v, value);
     } else {
       swapTab(this.tabs, value);
     }
   } else if (interactionType.equals(LIST_SELECT)) {
     selectListItem((ListView) v, value);
   } else if (interactionType.equals(LIST_LONG_SELECT)) {
     selectListItem((ListView) v, value, true);
   } else if (interactionType.equals(SPINNER_SELECT)) {
     selectSpinnerItem((Spinner) v, value);
   } else if (interactionType.equals(TYPE_TEXT)) {
     typeText((EditText) v, value);
   } else if (interactionType.equals(WRITE_TEXT)) {
     writeText((EditText) v, value);
   } else if (interactionType.equals(SET_BAR)) {
     solo.setProgressBar((ProgressBar) v, Integer.parseInt(value));
   } else {
     return;
   }
 }
  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 testAdapterUpdateInScriptActivity() {
    String look1ImagePath = lookDataList.get(0).getAbsolutePath();
    String look2ImagePath = lookDataList.get(1).getAbsolutePath();
    assertTrue(lookName + " is not selected in Spinner", solo.isSpinnerTextSelected(lookName));

    UiTestUtils.clickOnBottomBar(solo, R.id.button_play);
    solo.waitForActivity(StageActivity.class.getSimpleName());
    String lookPath =
        ProjectManager.getInstance().getCurrentSprite().getLookDataList().get(0).getAbsolutePath();
    assertEquals(
        "Wrong image shown in stage --> Problem with Adapter update in Script",
        look1ImagePath,
        lookPath);
    solo.goBack();
    solo.goBack();

    for (int i = 0; i < 5; ++i) {
      selectLook(lookName2, lookName, look2ImagePath);
      selectLook(lookName, lookName2, look1ImagePath);
    }
  }
  public void testAddCourse() {
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      PreferenceManager.getDefaultSharedPreferences(getActivity())
          .edit()
          .putBoolean("pref_use_android_calendar", true)
          .putString("pref_android_calendar_to_use", "1")
          .commit();
    }
    UpdateService.setCrawlerToUse(SimpleMockCrawler.class);
    solo.clickOnView(getActivity().findViewById(R.id.add));
    int oldsize = CourseContainer.instance().size();
    solo.clickOnEditText(0);
    solo.enterText(0, "Course");
    solo.clickOnEditText(0);
    solo.sendKey(Solo.ENTER);
    solo.waitForText("THE COURSE #2", 1, 5);
    solo.clickOnText("THE COURSE #2");
    solo.waitForText("Courses", 1, 5);
    assertEquals(oldsize + 1, CourseContainer.instance().size());
    assertTrue(solo.searchText("THE COURSE #2", 1, true));
    Exam exam = CourseContainer.instance().get(CourseContainer.instance().size() - 1).exams.first();
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      assertFalse("Exam of added course should have a created event", exam.event_id == -1);
    }

    oldsize = CourseContainer.instance().size();
    solo.clickOnView(getActivity().findViewById(R.id.add));
    solo.enterText(0, "Course");
    solo.clickOnEditText(0);
    solo.sendKey(Solo.ENTER);
    solo.waitForText("THE COURSE #2", 1, 5);
    solo.clickOnText("THE COURSE #2");
    assertEquals(
        "You should not be able to add the same course twice",
        oldsize,
        CourseContainer.instance().size());

    solo.goBack();
    solo.goBack();
  }
  public void testSelectLookAndPlay() {
    assertTrue(lookName + " is not selected in Spinner", solo.isSpinnerTextSelected(lookName));

    UiTestUtils.clickOnBottomBar(solo, R.id.button_play);

    solo.waitForActivity(StageActivity.class.getSimpleName());
    solo.sleep(1000);
    Look look = ProjectManager.getInstance().getCurrentProject().getSpriteList().get(0).look;
    assertEquals("look not set", look.getImagePath(), lookDataList.get(0).getAbsolutePath());
    solo.goBack();
    solo.goBack();
    solo.waitForActivity(ScriptActivity.class.getSimpleName());

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

    UiTestUtils.clickOnBottomBar(solo, R.id.button_play);

    solo.waitForActivity(StageActivity.class.getSimpleName());
    solo.sleep(1000);
    look = ProjectManager.getInstance().getCurrentProject().getSpriteList().get(0).look;
    assertEquals("look not set", look.getImagePath(), lookDataList.get(1).getAbsolutePath());
  }
  public void testIteration() throws InterruptedException {

    if (Build.VERSION.SDK_INT < 11) {

      QuestionGameScreen screen =
          QuestionGameScreen.screenForAcceptanceTest(getInstrumentation(), solo);
      assertTrue(screen.hasDefaultQuestionValue());
      assertFalse(screen.isAnswerVisible());

      screen.clickOnShowAnswerButton();
      assertTrue(screen.isAnswerVisible());
      assertTrue(screen.hasDefaultAnswerValue());

      screen.clickOnNextQuestionButton();
      assertFalse(screen.isAnswerVisible());
      assertTrue(screen.hasDefaultQuestionValue());

      screen.selectManageQuestionsMenu();

      QuestionListScreen listScreen =
          QuestionListScreen.screenForAcceptanceTests(getInstrumentation(), solo);
      assertTrue(listScreen.isEmpty());

      addQuestionWithValueAndAnswer("Question 01", "Answer 01");
      listScreen = QuestionListScreen.screenForAcceptanceTests(getInstrumentation(), solo);
      assertEquals(1, listScreen.getListSize());
      assertEquals("Question 01", listScreen.getTextAtLine(0));

      addQuestionWithValueAndAnswer("Question 02", "");
      listScreen = QuestionListScreen.screenForAcceptanceTests(getInstrumentation(), solo);
      assertEquals(2, listScreen.getListSize());
      assertEquals("Question 02", listScreen.getTextAtLine(1));

      solo.clickOnText("Question 02");
      QuestionEditScreen editScreen =
          QuestionEditScreen.screenForAcceptanceTests(getInstrumentation(), solo);
      editScreen.fillQuestionAndAnswer("Question 03", editScreen.getAnswerText());
      editScreen.selectSaveMenuItem();

      listScreen = QuestionListScreen.screenForAcceptanceTests(getInstrumentation(), solo);
      assertEquals(2, listScreen.getListSize());
      assertEquals("Question 03", listScreen.getTextAtLine(1));

      solo.goBack();
      screen = QuestionGameScreen.screenForAcceptanceTest(getInstrumentation(), solo);
      String firstText = screen.getValueText();
      assertTrue(firstText.equals("Question 01") || firstText.equals("Question 03"));
      assertFalse(screen.isAnswerVisible());
      screen.clickOnShowAnswerButton();
      if (firstText.equals("Question 01")) {
        assertEquals("Answer 01", screen.getAnswerText());
      } else {
        assertEquals("", screen.getAnswerText());
      }
      screen.clickOnNextQuestionButton();
      String secondText = screen.getValueText();
      assertTrue(secondText.equals("Question 01") || secondText.equals("Question 03"));
      assertFalse(screen.isAnswerVisible());

      screen.selectManageQuestionsMenu();
      removeQuestion("Question 01");
      listScreen = QuestionListScreen.screenForAcceptanceTests(getInstrumentation(), solo);
      assertEquals(1, listScreen.getListSize());
      assertEquals("Question 03", listScreen.getTextAtLine(0));

      removeQuestion("Question 03");
      listScreen = QuestionListScreen.screenForAcceptanceTests(getInstrumentation(), solo);
      assertTrue(listScreen.isEmpty());

      solo.goBack();
      screen = QuestionGameScreen.screenForAcceptanceTest(getInstrumentation(), solo);
      assertTrue(screen.hasDefaultQuestionValue());
    }
  }
Exemple #29
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);
  }