Example usage for android.test TouchUtils tapView

List of usage examples for android.test TouchUtils tapView

Introduction

In this page you can find the example usage for android.test TouchUtils tapView.

Prototype

public static void tapView(InstrumentationTestCase test, View v) 

Source Link

Document

Simulate touching the center of a view and releasing quickly (before the tap timeout).

Usage

From source file:com.chalmers.schmaps.test.GoogleMapSearchLocationTest.java

/**
 * Searches for a room that is known to exist in the database and tests
 * that what is drawn on the map has the same attributes as the one that
 * was queried.//from  www .j av  a 2s. c  o m
 */
public void testSearchForARoom() {
    TouchUtils.tapView(this, this.lectureEdit);
    super.sendKeys("R U N A N");
    super.getInstrumentation().waitForIdleSync();
    TouchUtils.clickView(this, this.editButton);
    super.getInstrumentation().waitForIdleSync();
    List<Overlay> overlays = mapview.getOverlays();

    //Test case for when u dont have a position from user
    //MapItemizedOverlay tempTestOverlay = (MapItemizedOverlay) overlays.get(0);

    //Test case for when u get a position for the user
    MapItemizedOverlay tempTestOverlay = (MapItemizedOverlay) overlays.get(2);

    GeoPoint roomGP = new GeoPoint(ARBITRARYLATPOS, ARBITRARYLONGPOS);

    assertEquals(roomGP, tempTestOverlay.getItem(0).getPoint());
    assertEquals("Sven Hultins gata 2", tempTestOverlay.getItem(0).getTitle());
    assertEquals("Floor 1", tempTestOverlay.getItem(0).getSnippet());
}

From source file:com.blogspot.ksoichiro.android.sample.transition.test.NormalTransitionTest.java

public void testNormalTransition() {
    // Activity?/* ww w  .  ja v a  2  s.c  o  m*/
    ActivityMonitor monitorMain = new ActivityMonitor(MainActivity.class.getCanonicalName(), null, false);
    ActivityMonitor monitorSecond = new ActivityMonitor(SecondActivity.class.getCanonicalName(), null, false);
    getInstrumentation().addMonitor(monitorMain);
    getInstrumentation().addMonitor(monitorSecond);

    // ??Fragment?BackStack??????
    FragmentActivity activity = (FragmentActivity) getActivity();
    FragmentManager fm = activity.getSupportFragmentManager();
    assertEquals(0, fm.getBackStackEntryCount());

    // ??Fragment?
    Fragment frag = fm.findFragmentByTag("tag");
    assertNotNull(frag);
    assertEquals(Fragment1.class, frag.getClass());

    // ??(Fragment)?
    TouchUtils.tapView(this, getActivity().findViewById(R.id.btnFrag1));
    getInstrumentation().waitForIdleSync();

    // BackStack?Fragment???(?)???
    assertEquals(1, fm.getBackStackEntryCount());

    // ??(Fragment)?????
    frag = fm.findFragmentByTag("tag");
    assertNotNull(frag);
    assertEquals(Fragment2.class, frag.getClass());

    // ??(Activity)?
    TouchUtils.tapView(this, getActivity().findViewById(R.id.btnFrag2));
    getInstrumentation().waitForMonitorWithTimeout(monitorSecond, 2000);

    // ?Activity???????
    assertEquals(1, monitorSecond.getHits());

    // ?
    sendKeys(KeyEvent.KEYCODE_BACK);
    getInstrumentation().waitForIdleSync();

    // ??(Activity)??????
    assertEquals(1, monitorMain.getHits());

    // ???Fragment?BackStack????????
    activity = (FragmentActivity) monitorMain.getLastActivity();
    fm = activity.getSupportFragmentManager();
    assertEquals(1, fm.getBackStackEntryCount());
    frag = fm.findFragmentByTag("tag");
    assertNotNull(frag);
    assertEquals(Fragment2.class, frag.getClass());

    // ?
    sendKeys(KeyEvent.KEYCODE_BACK);
    getInstrumentation().waitForIdleSync();

    // ???Fragment????BackStack?????????
    assertEquals(0, fm.getBackStackEntryCount());
    frag = fm.findFragmentByTag("tag");
    assertNotNull(frag);
    assertEquals(Fragment1.class, frag.getClass());
}

From source file:com.chalmers.schmaps.test.CheckInActivityTest.java

/**
 * Is testing that is testing that the regex is working
 * Only allowing letters and numbers//from w w  w  .  j  a  v a 2s.  co m
 */
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());

}

From source file:com.chalmers.schmaps.test.GoogleMapSearchLocationTest.java

/**
 * Tests that a dialog is shown if a room is not found by querying for
 * something that does not exist within the database and confirms that
 * a dialog is shown upon the query.//from   w  ww  .  ja  v  a 2 s  .c o  m
 */
public void testDialogRoomNotFound() {
    Dialog showingDialog = null;
    TouchUtils.tapView(this, this.lectureEdit);
    super.sendKeys(KeyEvent.KEYCODE_BACKSLASH);
    super.sendKeys("R O O M THATDOESNOTEXIST");
    super.sendKeys(KeyEvent.KEYCODE_POUND);
    super.getInstrumentation().waitForIdleSync();
    TouchUtils.clickView(this, this.editButton);
    super.getInstrumentation().waitForIdleSync();
    try {
        Field dialogRoomNotFound = activity.getClass().getDeclaredField("dialog");
        dialogRoomNotFound.setAccessible(true);
        showingDialog = (Dialog) dialogRoomNotFound.get(this.activity);
    } catch (Exception e) {
    }
    assertTrue(showingDialog.isShowing());
}

From source file:com.chalmers.schmaps.test.GoogleMapSearchLocationTest.java

/**
 * Makes sure that the regex function works as intended by 
 * inserting spaces and special characters into the query
 * and confirming that still the right input was queried.
 *//* w  ww  .  j  a v a2 s . c  o  m*/
public void testRegexForRoom() {
    TouchUtils.tapView(this, this.lectureEdit);
    super.sendKeys(KeyEvent.KEYCODE_BACKSLASH);
    super.sendKeys("R U N A N ");
    super.sendKeys(KeyEvent.KEYCODE_POUND);
    super.getInstrumentation().waitForIdleSync();
    TouchUtils.clickView(this, this.editButton);
    super.getInstrumentation().waitForIdleSync();
    assertEquals("runan", activity.getRoomToFind());
}

From source file:com.chalmers.schmaps.test.GoogleMapSearchLocationTest.java

/**
 * Tests that the database is connected and that a response from the google directions api is recieved
 * If the jsonobject is received the boolean running is set to true
 *//*ww w  .  j ava 2 s  .co  m*/
public void testConnectionToDirections() {
    TouchUtils.tapView(this, this.lectureEdit);
    super.sendKeys("R U N A N ");
    super.getInstrumentation().waitForIdleSync();
    TouchUtils.clickView(this, this.editButton);
    super.getInstrumentation().waitForIdleSync();

    activity.walkningDirections();

    assertEquals(true, activity.getIsAsyncTaskRunning());
}

From source file:com.chalmers.schmaps.test.GoogleMapSearchLocationTest.java

/**
 * Tests that the getdirectionsbutton is working, that the asynctask method has executed
 *///from  ww w . ja va 2s . c  om
public void testDirectionsButton() {
    TouchUtils.tapView(this, this.lectureEdit);
    super.sendKeys("R U N A N ");
    super.getInstrumentation().waitForIdleSync();
    TouchUtils.clickView(this, this.editButton);
    super.getInstrumentation().waitForIdleSync();

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

    assertEquals(true, activity.getIsAsyncTaskRunning());
}