Search in sources :

Example 1 with TestOnClickListener

use of org.robolectric.android.TestOnClickListener in project robolectric by robolectric.

the class ShadowViewTest method checkedClick_shouldClickOnView.

@Test
public void checkedClick_shouldClickOnView() throws Exception {
    TestOnClickListener clickListener = new TestOnClickListener();
    shadowOf(view).setMyParent(ReflectionHelpers.createNullProxy(ViewParent.class));
    view.setOnClickListener(clickListener);
    shadowOf(view).checkedPerformClick();
    assertTrue(clickListener.clicked);
}
Also used : TestOnClickListener(org.robolectric.android.TestOnClickListener) Test(org.junit.Test)

Example 2 with TestOnClickListener

use of org.robolectric.android.TestOnClickListener in project robolectric by robolectric.

the class RobolectricTest method clickOn_shouldCallClickListener.

@Test
public void clickOn_shouldCallClickListener() throws Exception {
    View view = new View(RuntimeEnvironment.application);
    shadowOf(view).setMyParent(ReflectionHelpers.createNullProxy(ViewParent.class));
    TestOnClickListener testOnClickListener = new TestOnClickListener();
    view.setOnClickListener(testOnClickListener);
    ShadowView.clickOn(view);
    assertTrue(testOnClickListener.clicked);
}
Also used : ViewParent(android.view.ViewParent) TestOnClickListener(org.robolectric.android.TestOnClickListener) View(android.view.View) ShadowView(org.robolectric.shadows.ShadowView) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 TestOnClickListener (org.robolectric.android.TestOnClickListener)2 View (android.view.View)1 ViewParent (android.view.ViewParent)1 ShadowView (org.robolectric.shadows.ShadowView)1