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();
    }
  }
 public void selectFormSection(String formSectionName) {
   solo.waitForText("Save");
   solo.clickOnView(solo.getCurrentViews(Spinner.class).get(0));
   solo.waitForText(formSectionName);
   ListAdapter adapter = solo.getCurrentViews(ListView.class).get(0).getAdapter();
   for (int i = 0; i < adapter.getCount(); i++) {
     if (adapter.getItem(i).toString().equalsIgnoreCase(formSectionName)) {
       formPosition = i;
       break;
     }
   }
   solo.clickOnText(adapter.getItem(formPosition).toString());
   solo.waitForText(formSectionName);
   solo.sleep(3);
 }
Example #3
0
 public boolean waitForText(String text) {
   boolean rc = mSolo.waitForText(text);
   if (!rc) {
     // log out failed wait for diagnostic purposes only;
     // waitForText failures are sometimes expected/normal
     mAsserter.dumpLog("waitForText timeout on " + text);
   }
   return rc;
 }
 public List<String> getAllFormSections() {
   solo.clickOnText("Enquirer Details", 0);
   solo.waitForText("Tracing Information");
   ListAdapter adapter = solo.getCurrentViews(ListView.class).get(0).getAdapter();
   int totalCount = adapter.getCount();
   List<String> formSections = new ArrayList<String>();
   for (int i = 0; i < totalCount; i++) {
     formSections.add(adapter.getItem(i).toString());
   }
   return formSections;
 }
  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();
  }
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    if (!NetTest.weAreOnline()) {
      getActivity().finish();
      throw new AssertionFailedError(
          "Not online. Stopping this test since it depends on network connection.");
    }
    solo = new Solo(getInstrumentation(), getActivity());

    // click on "Select game" button which should bring up RepoList (is
    // tested in Start)
    solo.waitForText(
        Util.getRessourceString(
            edu.bonn.mobilegaming.geoquest.R.string.start_button_game_list_text));
    solo.clickOnText(
        Util.getRessourceString(
            edu.bonn.mobilegaming.geoquest.R.string.start_button_game_list_text));

    // click on "Demos" to bring up GameListActivity on Demos repo:
    solo.waitForText("Demos");
    solo.clickOnText("Demos");
  }
 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();
 }
 private void clickOnContextMenuItem(String lookName, String menuItemName) {
   solo.clickLongOnText(lookName);
   solo.waitForText(menuItemName);
   solo.clickOnText(menuItemName);
 }
  @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());
  }
Example #10
0
 public void navigateToCreatePage() {
   solo.clickOnText("Enquiry");
   solo.waitForText("Enquiry details");
 }