示例#1
0
  public void home() {

    // Scroll listviews up
    final ArrayList<ListView> viewList = solo.getCurrentListViews();
    if (viewList.size() > 0) {
      getActivity()
          .runOnUiThread(
              new Runnable() {
                public void run() {
                  viewList.get(0).setSelection(0);
                }
              });
    }

    // Scroll scrollviews up
    final ArrayList<ScrollView> viewScroll = solo.getCurrentScrollViews();
    if (viewScroll.size() > 0) {
      getActivity()
          .runOnUiThread(
              new Runnable() {
                public void run() {
                  viewScroll.get(0).fullScroll(ScrollView.FOCUS_UP);
                }
              });
    }
    sync();
  }
示例#2
0
  public void retrieveWidgets() {
    home();
    clearWidgetList();
    ArrayList<View> viewList =
        (isInAndOutFocusEnabled()) ? solo.getViews() : solo.getCurrentViews();
    for (View w : viewList) {
      String text = (w instanceof TextView) ? ": " + ((TextView) w).getText().toString() : "";
      Log.d(
          "nofatclips",
          "Found widget: id="
              + w.getId()
              + " ("
              + w.toString()
              + ")"
              + text); // + " in window at [" + xy[0] + "," + xy[1] + "] on screen at [" + xy2[0] +
      // "," + xy2[1] +"]");

      //
      allViews.add(w);
      //

      if (w.getId() > 0) {
        theViews.put(w.getId(), w); // Add only if the widget has a valid ID
      }
      if (w instanceof TabHost) {
        setTabs((TabHost) w);
      }
    }
  }
 @MediumTest
 public void testShouldShowLightweightTag() throws Exception {
   startActivitySync(tagViewerIntentFor(gitdir, "lightweight-tag-of-2nd-commit"));
   solo.sleep(500);
   poseForScreenshot();
   assertTrue(solo.searchText("0d2489a0"));
 }
  public void testScreenElementAutoResizeWithChild() throws InterruptedException {
    int oldX = screenElement.getRightBottom().getX();
    solo.enterText((EditText) textElement.getTextView(), "newnewasdfasdadfadsfasdfnewnewll");

    solo.waitForView(textElement.getTextView()); // better check?
    assertTrue(screenElement.getRightBottom().getX() > oldX);
  }
  public void test02RejectFileTransferRequest() {
    checkThatTheFilesHaveNotBeenTransferred();

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

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

    openReceiveFileDialog(tina, 1);
    solo.sleep(500);

    checkThatTheDialogIsInFront();
    checkDialogMessage(
        "Tina 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 Tina");
    checkThatNoFileTransferNotificationsAreActive();
    checkThatTheFilesHaveNotBeenTransferred();
  }
示例#6
0
 public void enterEnquirerDetails(List<String> enquirerDetails) {
   TextField textField =
       (TextField) solo.getCurrentActivity().findViewById("enquirer_name".hashCode());
   EditText nameField = (EditText) textField.findViewById(R.id.value);
   solo.enterText(nameField, "");
   solo.enterText(nameField, enquirerDetails.get(0).toString());
 }
  private void longClickAndDrag(
      final float xFrom, final float yFrom, final float xTo, final float yTo, final int steps) {
    Handler handler = new Handler(getActivity().getMainLooper());

    handler.post(
        new Runnable() {

          public void run() {
            MotionEvent downEvent =
                MotionEvent.obtain(
                    SystemClock.uptimeMillis(),
                    SystemClock.uptimeMillis(),
                    MotionEvent.ACTION_DOWN,
                    xFrom,
                    yFrom,
                    0);
            getActivity().dispatchTouchEvent(downEvent);
          }
        });

    solo.sleep(ViewConfiguration.getLongPressTimeout() + 200);

    handler.post(
        new Runnable() {
          public void run() {

            for (int i = 0; i <= steps; i++) {
              float x = xFrom + (((xTo - xFrom) / steps) * i);
              float y = yFrom + (((yTo - yFrom) / steps) * i);
              MotionEvent moveEvent =
                  MotionEvent.obtain(
                      SystemClock.uptimeMillis(),
                      SystemClock.uptimeMillis(),
                      MotionEvent.ACTION_MOVE,
                      x,
                      y,
                      0);
              getActivity().dispatchTouchEvent(moveEvent);
              solo.sleep(20);
            }
          }
        });

    solo.sleep(steps * 20 + 200);
    handler.post(
        new Runnable() {
          public void run() {
            MotionEvent upEvent =
                MotionEvent.obtain(
                    SystemClock.uptimeMillis(),
                    SystemClock.uptimeMillis(),
                    MotionEvent.ACTION_UP,
                    xTo,
                    yTo,
                    0);
            getActivity().dispatchTouchEvent(upEvent);
          }
        });
    solo.sleep(1000);
  }
示例#8
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());
   }
 }
示例#9
0
  /* Tap the "star" (bookmark) button to bookmark or un-bookmark the current page */
  public void toggleBookmark() {
    mActions.sendSpecialKey(Actions.SpecialKey.MENU);
    waitForText("Settings");

    // On ICS+ phones, there is no button labeled "Bookmarks"
    // instead we have to just dig through every button on the screen
    ArrayList<View> images = mSolo.getCurrentViews();
    for (int i = 0; i < images.size(); i++) {
      final View view = images.get(i);
      boolean found = false;
      found = "Bookmark".equals(view.getContentDescription());

      // on older android versions, try looking at the button's text
      if (!found) {
        if (view instanceof TextView) {
          found = "Bookmark".equals(((TextView) view).getText());
        }
      }

      if (found) {
        int[] xy = new int[2];
        view.getLocationOnScreen(xy);

        final int viewWidth = view.getWidth();
        final int viewHeight = view.getHeight();
        final float x = xy[0] + (viewWidth / 2.0f);
        float y = xy[1] + (viewHeight / 2.0f);

        mSolo.clickOnScreen(x, y);
      }
    }
  }
示例#10
0
  @When("^I start the program$")
  public void I_start_the_program() throws InterruptedException {
    programWaitLock = new Semaphore(programWaitLockPermits);
    addScriptEndCallbacks();

    Solo solo = (Solo) Cucumber.get(Cucumber.KEY_SOLO);
    assertEquals(
        "I am in the wrong Activity.",
        MainMenuActivity.class,
        solo.getCurrentActivity().getClass());
    solo.clickOnView(solo.getView(org.catrobat.catroid.R.id.main_menu_button_continue));
    solo.waitForActivity(ProjectActivity.class.getSimpleName(), 3000);
    assertEquals(
        "I am in the wrong Activity.", ProjectActivity.class, solo.getCurrentActivity().getClass());
    solo.clickOnView(solo.getView(org.catrobat.catroid.R.id.button_play));
    solo.waitForActivity(StageActivity.class.getSimpleName(), 3000);
    assertEquals(
        "I am in the wrong Activity.", StageActivity.class, solo.getCurrentActivity().getClass());

    synchronized (programStartWaitLock) {
      if (!programHasStarted) {
        programStartWaitLock.wait(10000);
      }
    }
  }
示例#11
0
 private void selectListItem(final ListView l, int num, boolean longClick) {
   final int n = Math.min(l.getCount(), Math.max(1, num)) - 1;
   requestFocus(l);
   Log.i("nofatclips", "Swapping to listview item " + num);
   solo.sendKey(Solo.DOWN);
   getActivity()
       .runOnUiThread(
           new Runnable() {
             public void run() {
               l.setSelection(n);
             }
           });
   sync();
   if (n < l.getCount() / 2) {
     solo.sendKey(Solo.DOWN);
     solo.sendKey(Solo.UP);
   } else {
     solo.sendKey(Solo.UP);
     solo.sendKey(Solo.DOWN);
   }
   sync();
   if (longClick) {
     longClick(l.getSelectedView());
   } else {
     click(l.getSelectedView());
   }
 }
示例#12
0
 public void fireEvent(
     int widgetIndex, String widgetName, String widgetType, String eventType, String value) {
   View v = null;
   if (eventType.equals(BACK) || eventType.equals(SCROLL_DOWN)) {
     fireEventOnView(null, eventType, null);
     return;
   } else if (eventType.equals(CLICK_ON_TEXT)) {
     Log.d("nofatclips", "Firing event: type= " + eventType + " value= " + value);
     fireEventOnView(null, eventType, value);
   }
   if (widgetType.equals(BUTTON)) {
     v = solo.getButton(widgetName);
   } else if (widgetType.equals(MENU_ITEM)) {
     v = solo.getText(widgetName);
   } else if (widgetType.equals(LIST_VIEW)) {
     v = solo.getCurrentListViews().get(0);
   }
   if (v == null) {
     for (View w : getAllWidgets()) {
       if (w instanceof Button) {
         Button candidate = (Button) w;
         if (candidate.getText().equals(widgetName)) {
           v = candidate;
         }
       }
       if (v != null) break;
     }
   }
   fireEventOnView(v, eventType, value);
 }
示例#13
0
 // Scroll until the view is on the screen if IN_AND_OUT_OF_FOCUS is enabled or if the force
 // parameter is true
 protected void requestView(final View v, boolean force) {
   if (force || isInAndOutFocusEnabled()) {
     home();
     solo.sendKey(Solo.UP); // Solo.waitForView() requires a widget to be focused
     solo.waitForView(v, 1000, true);
   }
   requestFocus(v);
 }
 @MediumTest
 public void testShouldShowAnnotatedTag() throws Exception {
   startActivitySync(tagViewerIntentFor(gitdir, "annotated-tag-of-2nd-commit"));
   solo.sleep(500);
   poseForScreenshot();
   assertTrue(solo.searchText("I even like the 2nd commit, I am tagging it"));
   assertTrue(solo.searchText("Adding my happy folder with it's tags"));
 }
 private void deleteAllCourses() {
   for (int i = 0; i < 4; i++) {
     solo.clickOnCheckBox(i);
   }
   solo.clickOnView(getActivity().findViewById(R.id.delete));
   for (int i = 0; i < 5; i++) {
     solo.clickOnCheckBox(i);
   }
   solo.clickOnView(getActivity().findViewById(R.id.delete));
 }
示例#16
0
 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;
 }
示例#17
0
  /** Upon adding a new podcast to the DAO, it should be displayed in the podcast list. */
  public void testAddPodcast() {
    Podcast p = insertPodcast();

    while (solo.scrollDown()) ;

    assertTrue(
        String.format("New podcast %s should be displayed in list", uuid), solo.searchText(uuid));
    assertTrue(
        String.format("New podcast %s should be in DAO", uuid),
        dao.getPodcastById(p.getId()) != null);
  }
 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();
 }
示例#19
0
  /**
   * Enhanced view finder. First tries to find it from Activity, then from all Views under ViewRoot.
   */
  protected final View findViewById(int id) {
    View view = solo.getView(id);
    if (view != null) return view;

    ArrayList<View> views = solo.getViews();
    for (View v : views) {
      if (v.getId() == id) {
        return v;
      }
    }
    return null;
  }
示例#20
0
  public void afterRestart() {
    solo.setActivityOrientation(Solo.PORTRAIT);
    solo.sleep(SLEEP_AFTER_RESTART);
    waitOnThrobber();
    if (PRECRAWLING.length > 0) {
      refreshCurrentActivity();
      retrieveWidgets();
      processPrecrawling();
    }

    Log.d("nofatclips", "Ready to operate after restarting...");
  }
示例#21
0
  public void testRotation() {
    Podcast p = insertPodcast();

    solo.setActivityOrientation(Solo.LANDSCAPE);
    while (solo.scrollDown()) ;

    assertTrue(
        String.format("New podcast %s should be displayed in list", uuid), solo.searchText(uuid));
    assertTrue(
        String.format("New podcast %s should be in DAO", uuid),
        dao.getPodcastById(p.getId()) != null);
  }
示例#22
0
  protected final void enterUrl(String url) {
    final EditText urlEditView = (EditText) mSolo.getView(R.id.url_edit_text);

    focusUrlBar();

    // Send the keys for the URL we want to enter
    mSolo.clearEditText(urlEditView);
    mSolo.enterText(urlEditView, url);

    // Get the URL text from the URL bar EditText view
    final String urlBarText = urlEditView.getText().toString();
    mAsserter.is(url, urlBarText, "URL typed properly");
  }
  public void test01ShouldShowMissingFileDialogIfNoFileTransferRequestAvailable() {
    openReceiveFileDialog();

    solo.sleep(500);
    checkDialogMessage("Unable to find the specified file transfer request");
    checkThatTheDialogIsInFront();

    solo.clickOnText("OK"); // Close dialog

    solo.sleep(500);
    checkThatTheMainChatIsInFront();
    checkThatNoFileTransferNotificationsAreActive();
  }
 public void testDeleteCourses() {
   solo.clickOnCheckBox(1);
   solo.clickOnCheckBox(3);
   solo.clickOnCheckBox(5);
   solo.clickOnCheckBox(7);
   solo.clickOnView(getActivity().findViewById(R.id.delete));
   ListView listView = (ListView) solo.getView(R.id.courses_list);
   assertEquals("Listview should only contain 6 courses", 5, listView.getCount());
   for (int i = 0; i < 9; i++) {
     if (i % 2 == 0) {
       assertTrue(solo.searchText("Course #" + i));
     }
   }
 }
示例#25
0
  // Generated from trace 753
  public void testTrace00001() {

    // Testing base activity
    retrieveWidgets();
    // Testing current activity: should be a1
    solo.assertCurrentActivity("Testing base activity", "Dashboard");

    // Testing transition
    // Firing event: e757
    fireEvent(0, "", "null", "openMenu");

    // This event leads to fail
    solo.sleep(SLEEP_AFTER_TASK);
  }
示例#26
0
  /**
   * After deleting the newly added podcast, it should not be displayed in the podcast list, and
   * should not be contained in the podcast DAO.
   */
  public void testRemovePodcast() {
    Podcast p = insertPodcast();

    while (solo.scrollDown()) ;

    solo.clickLongOnText(uuid);
    solo.clickOnText(getActivity().getString(at.ac.tuwien.detlef.R.string.delete_feed));

    assertFalse(
        String.format("Deleted podcast %s should not be displayed in list", uuid),
        solo.searchText(uuid));
    assertFalse(
        String.format("Deleted podcast %s should not be in DAO", uuid),
        dao.getPodcastById(p.getId()) != null);
  }
示例#27
0
 private CommandResponse waitForActivity(String[] params) {
   String command = "the command wait for activity: ";
   CommandResponse result = new CommandResponse();
   try {
     if (params.length == 2) {
       result.setSucceeded(solo.waitForActivity(params[0], Integer.parseInt(params[1])));
     } else if (params.length == 1) {
       result.setSucceeded(solo.waitForActivity(params[0]));
     }
     result.setResponse(command + "Wait for activity ended with status " + result.isSucceeded());
   } catch (Throwable e) {
     result = handleException(command, e);
   }
   return result;
 }
示例#28
0
 /** Traverses the items in listItems in order in the menu. */
 public void selectMenuItemByPath(String[] listItems) {
   int listLength = listItems.length;
   if (listLength > 0) {
     selectMenuItem(listItems[0]);
   }
   if (listLength > 1) {
     for (int i = 1; i < listLength; i++) {
       String itemName = "^" + listItems[i] + "$";
       if (!waitForEnabledText(itemName)) {
         mSolo.scrollDown();
       }
       mSolo.clickOnText(itemName);
     }
   }
 }
示例#29
0
 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();
  }