예제 #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());
  }
예제 #2
0
파일: Test2.java 프로젝트: linoor/saper
 public void testGraRozpoczeta() {
   for (int i = 0; i < 10; i++) {
     int rows = 9, columns = 9, mines = 10;
     Random rand = new Random();
     int nr = rand.nextInt(3);
     if (nr == 0) {
       rows = 9;
       columns = 9;
       mines = 10;
     }
     if (nr == 1) {
       rows = 16;
       columns = 16;
       mines = 40;
     }
     if (nr == 2) {
       rows = 30;
       columns = 16;
       mines = 99;
     }
     // tu blad wyskakuje - moze jednak zwykle klikanie
     // getActivity().ustaw(columns,rows,mines);
     // getActivity().startNewGame();
     solo.clickOnImage(0);
     solo.clickOnButton(nr);
     // po kliknieciu klawisza - czy zegar chodzi i czy miny ustawione?
     nr = rand.nextInt(columns * rows);
     solo.clickOnButton(nr);
     Assert.assertEquals(true, getActivity().isTimerstarted());
     Assert.assertEquals(true, getActivity().isAreMinesSet());
   }
 }
예제 #3
0
 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));
 }
예제 #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);
 }
예제 #5
0
  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));
  }
예제 #6
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();
    }
  }
예제 #7
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());
  }
예제 #8
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 testBrowseHouseTest() {
    try {
      Report.setTCNameLog(testName);
      // 如果打开应用后弹出“是否打开定位功能”的提示,选择“取消”
      if (solo.searchText("提示")) {
        solo.clickOnButton(1);
      }
      if (solo.searchText("刷新")) {
        solo.clickOnText("刷新");
      }

      //			Action.wait(solo, R.id.view_list_item_tv_title, count, "等待详细房源类表加载成功");
      //			Report.writeHTMLLog("安居客浏览房源用例", "附近页房源列表显示完全",Report.DONE,"");

      // 如果当前城市不是上海,就切换至上海
      Action.switchCity(solo, "上海");
      solo.clickOnText("搜索");
      Action.scroolUpPage(solo, "浏览房源");
      solo.clickOnText(bureau);
      solo.clickOnText(area);
      Report.writeHTMLLog("安居客浏览房源用例", "选中区域".concat(bureau).concat(area), Report.DONE, "");

      Action.wait(solo, R.id.view_list_item_tv_title, count, "等待房源列表信息显示成功");
      solo.clickOnView(solo.getView(R.id.view_list_item_tv_title));
      solo.waitForText("收藏");
      String houseTitle =
          (String) ((TextView) solo.getCurrentActivity().findViewById(R.id.prop_title)).getText();
      Report.writeHTMLLog(
          "安居客浏览房源用例", "房源列表第一套房源标题为:" + houseTitle, "Done", Action.screenShot(solo));

      // 点击返回按钮
      Action.clickById(solo, R.id.detail_back_button, "点击返回按钮");

      // 点击”更多"tab
      solo.clickOnText("我的");
      solo.clickOnText("浏览记录");
      solo.waitForText("清空");
      solo.clickOnView(solo.getView(R.id.view_for_house_history_item_tv_title));
      Report.writeHTMLLog("安居客浏览房源用例", "选中最近浏览的第一套房源", Report.DONE, "");
      String browseHouseTitle =
          (String) ((TextView) solo.getCurrentActivity().findViewById(R.id.prop_title)).getText();
      Report.writeHTMLLog("安居客浏览房源用例", "最近浏览的第一套房源标题为:" + browseHouseTitle, Report.DONE, "");
      Boolean flag = Action.assertString(solo, "比较收藏房源标题是否匹配", houseTitle, browseHouseTitle);
      if (flag) {
        Report.writeHTMLLog("安居客浏览房源用例", "匹配成功", Report.PASS, "");
      } else {
        Report.writeHTMLLog("安居客浏览房源用例", "匹配不成功用例失败", Report.FAIL, Action.screenShot(solo));
      }
      //			Report.seleniumReport();
    } catch (Exception e) {
      String ps = Action.screenShot(solo);
      Report.writeHTMLLog("出现异常:" + e.getMessage(), "脚本停止", Report.FAIL, ps);
      //			Report.seleniumReport();
    }
  }
예제 #10
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 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();
 }
예제 #12
0
  /**
   * The first walkthrough. Documented on the wiki. Starts on the login, ends up navigating to a
   * lesson after logging in.
   */
  @Test
  public void testWalkthroughLoginToDashboardToCoursesToCourseToLesson() {
    // Login first
    EditText user = solo.getEditText(0);
    EditText pass = solo.getEditText(1);
    solo.typeText(user, "*****@*****.**");
    solo.typeText(pass, "password");
    solo.clickOnButton(solo.getString(com.huskysoft.eduki.R.string.login));
    // Need to sleep to allow the activity to finish
    solo.sleep(8000);
    solo.assertCurrentActivity("Wrong activity", MainActivity.class);

    // Click on the all courses button
    solo.clickOnActionBarItem(com.huskysoft.eduki.R.id.action_courses);
    solo.sleep(1000);
    solo.assertCurrentActivity("Did not start the Course list Activity", CoursesListActivity.class);

    // Wait for the courses list to appear
    solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.courseListView));
    solo.sleep(1000);
    List<Course> courseList = ((CoursesListActivity) solo.getCurrentActivity()).getCourseList();
    assertNotSame(courseList.size(), 0);
    solo.clickOnText("INTRODUCTION");
    solo.assertCurrentActivity("Wrong activity", CourseActivity.class);

    // Wait for the course page to appear
    solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.course_activity));
    solo.sleep(1000);

    // Click a lesson, wait for it to appear
    List<Lesson> lessonList = ((CourseActivity) solo.getCurrentActivity()).getLessonList();
    assertNotSame(lessonList.size(), 0);
    solo.clickOnText(lessonList.get(0).toString());

    solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.lessonViewLayoutText));
    solo.sleep(1000);
    String content =
        ((TextView)
                solo.getCurrentActivity()
                    .findViewById(com.huskysoft.eduki.R.id.lessonViewLayoutText))
            .getText()
            .toString();
    assertFalse(content.equals(""));
  }
예제 #13
0
  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));
  }
예제 #14
0
  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));
  }
예제 #15
0
  /**
   * The second test, documented on the wiki. Starts on login. Does not login, instead navigates to
   * a course list and ends up at a quiz.
   */
  @Test
  public void testWalkthroughLoginToCoursesListToCourseToQuiz() {
    // Need to sleep to allow the activity to finish
    solo.clickOnActionBarItem(com.huskysoft.eduki.R.id.action_courses);
    solo.sleep(1000);
    solo.assertCurrentActivity("Did not start the Course list Activity", CoursesListActivity.class);

    // Wait for the courses list to appear
    solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.courseListView));
    solo.sleep(1000);
    List<Course> courseList = ((CoursesListActivity) solo.getCurrentActivity()).getCourseList();
    assertNotSame(courseList.size(), 0);
    solo.clickOnText("INTRODUCTION");
    solo.assertCurrentActivity("Wrong activity", CourseActivity.class);

    // Wait for the course page to appear
    solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.course_activity));
    solo.sleep(1000);

    // Click a quiz, wait for it to appear
    List<Quiz> quizList = ((CourseActivity) solo.getCurrentActivity()).getQuizList();
    assertNotSame(quizList.size(), 0);
    solo.clickOnText(quizList.get(0).toString());

    solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.quizScrollView));
    solo.sleep(2000); // Sleep to wait for the answers to populate
    List<RadioGroup> answersGroupList =
        ((QuizzesViewActivity) solo.getCurrentActivity()).getAnswerGroup();
    for (int i = 0; i < answersGroupList.size(); i++) {
      RadioGroup current_rg = answersGroupList.get(i);
      List<RadioButton> list_rb = getRadioButtons(current_rg);
      assertTrue(list_rb.size() != 0);
      solo.clickOnView(list_rb.get(0)); // Answer "A" for everything
      solo.sleep(500);
    }
    solo.sleep(1000);
    solo.clickOnButton("SUBMIT");
    solo.waitForActivity(QuizzesResultsActivity.class);
    solo.assertCurrentActivity("Wrong activity", QuizzesResultsActivity.class);
  }
예제 #16
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);
  }
예제 #17
0
 public void save() {
   solo.clickOnButton("Save");
 }
예제 #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());
  }