@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); } } }
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()); }
/** 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()); }
@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); }