@MediumTest
  public void testClick() {

    for (int i = 0; i < 999999999; i++) {
      int index = new Random().nextInt(5);
      Log.d("radom number", Integer.toString(index));

      switch (index) {
        case 0:
          TouchUtils.clickView(this, bespin);
          break;
        case 1:
          TouchUtils.clickView(this, dagoban);
          break;
        case 2:
          TouchUtils.clickView(this, tatooine);
          break;
        case 3:
          TouchUtils.clickView(this, endor);
          break;
        case 4:
          TouchUtils.clickView(this, hoth);
      }
    }
  }
Ejemplo n.º 2
0
  /** Is testing that is testing that the regex is working Only allowing letters and numbers */
  public void testAddNameRegex() {
    TouchUtils.tapView(this, this.nameEdit);

    super.sendKeys("R U N E ");
    super.getInstrumentation().waitForIdleSync();
    super.sendKeys(KeyEvent.KEYCODE_APOSTROPHE);

    super.getInstrumentation().waitForIdleSync();
    TouchUtils.clickView(this, this.checkInButton);
    super.getInstrumentation().waitForIdleSync();

    activity.getInputName();
    assertEquals("rune", activity.getInputName());
  }
Ejemplo n.º 3
0
  public void testRemoveOnTouchModeChangeListener() {
    final Button b = (Button) mActivity.findViewById(R.id.button1);
    // let the button be touch mode.
    TouchUtils.tapView(this, b);

    mViewTreeObserver = b.getViewTreeObserver();

    MockOnTouchModeChangeListener listener = new MockOnTouchModeChangeListener();
    mViewTreeObserver.addOnTouchModeChangeListener(listener);
    assertFalse(listener.hasCalledOnTouchModeChanged());
    mInstrumentation.runOnMainSync(
        new Runnable() {
          @Override
          public void run() {
            b.requestFocusFromTouch();
          }
        });
    mInstrumentation.waitForIdleSync();

    assertTrue(listener.hasCalledOnTouchModeChanged());

    listener = new MockOnTouchModeChangeListener();
    assertFalse(listener.hasCalledOnTouchModeChanged());
    mInstrumentation.runOnMainSync(
        new Runnable() {
          @Override
          public void run() {
            b.requestFocusFromTouch();
          }
        });
    mInstrumentation.waitForIdleSync();

    assertFalse(listener.hasCalledOnTouchModeChanged());
  }
 private boolean tap(int id) {
   View view = mActivity.findViewById(id);
   if (view != null) {
     TouchUtils.clickView(this, view);
     return true;
   }
   return false;
 }
 @FlakyTest(tolerance = 2)
 @LargeTest
 public void testClickingHeaderKeepsFocus() {
   TouchUtils.clickView(this, mListView.getChildAt(0));
   assertTrue("header does not have focus", mListView.getChildAt(0).isFocused());
   assertEquals(
       "something is selected", AbsListView.INVALID_POSITION, mListView.getSelectedItemPosition());
 }
 @LargeTest
 public void testClickingHeaderWhenOtherItemHasFocusGivesHeaderFocus() {
   sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
   assertEquals("selected position", 1, mListView.getSelectedItemPosition());
   TouchUtils.clickView(this, mListView.getChildAt(0));
   assertTrue("header does not have focus", mListView.getChildAt(0).isFocused());
   assertEquals(
       "something is selected", AbsListView.INVALID_POSITION, mListView.getSelectedItemPosition());
 }
  @LargeTest
  public void testScrollToTop() {
    View firstChild;
    TouchUtils.scrollToTop(this, mGridView);

    // Nothing should be selected
    assertEquals("Selection still available after touch", -1, mGridView.getSelectedItemPosition());

    firstChild = mGridView.getChildAt(0);

    assertEquals("Item zero not the first child in the grid", 0, firstChild.getId());

    assertEquals(
        "Item zero not at the top of the grid", mGridView.getListPaddingTop(), firstChild.getTop());
  }
  @LargeTest
  public void testScrollToBottom() {
    TouchUtils.scrollToBottom(this, mGridView);

    // Nothing should be selected
    assertEquals("Selection still available after touch", -1, mGridView.getSelectedItemPosition());

    View lastChild = mGridView.getChildAt(mGridView.getChildCount() - 1);

    assertEquals(
        "Grid is not scrolled to the bottom",
        mGridView.getAdapter().getCount() - 1,
        lastChild.getId());

    assertEquals(
        "Last item is not touching the bottom edge",
        mGridView.getHeight() - mGridView.getListPaddingBottom(),
        lastChild.getBottom());
  }
  @MediumTest
  public void testSendMessageToReceiverActivity3() {
    final ImageButton sendToReceiverButton =
        (ImageButton) getActivity().findViewById(R.id.imageButton);
    final EditText et = (EditText) getActivity().findViewById(R.id.First_Name);
    getInstrumentation()
        .runOnMainSync(
            new Runnable() {
              @Override
              public void run() {
                et.setText("hello");
              }
            });

    Instrumentation.ActivityMonitor receiverActivityMonitor =
        getInstrumentation().addMonitor(FullNameActivity.class.getName(), null, false);
    TouchUtils.clickView(this, sendToReceiverButton);
    FullNameActivity receiverActivity =
        (FullNameActivity) receiverActivityMonitor.waitForActivityWithTimeout(2000);

    assertNull("ReceiverActivity is null", receiverActivity);

    getInstrumentation().removeMonitor(receiverActivityMonitor);
  }
Ejemplo n.º 10
0
 public void testTouchEvents() {
   TouchUtils.scrollToBottom(this, getActivity(), list);
   getInstrumentation().waitForIdleSync();
   assertEquals(list.getLastVisiblePosition(), 24);
 }