@Test public void shouldUnregisteredLongClickListenerWhenContextMenuUnregisteredOnView() { //given TextView view = new TextView(RuntimeEnvironment.application.getBaseContext()); activityWithContextMenu.registerForContextMenu(view); ShadowView shadowView = shadowOf(view); //expected assertThat(shadowView.getOnLongClickListener()).isNotNull(); //when activityWithContextMenu.unregisterForContextMenu(view); //then assertThat(shadowView.getOnLongClickListener()).isNull(); }
@Test // @Values(shadows = TemporaryShadowView.class) public void overridingShadowBindingsShouldNotAffectBindingsInLaterTestsAgain() throws Exception { // todo test this properly assertThat(shadowOf(new View(Robolectric.application)).getClass().getSimpleName()).isEqualTo(ShadowView.class.getSimpleName()); // assertThat(Robolectric.shadowOf_(new View(Robolectric.application)).getClass().getSimpleName()).isEqualTo(TemporaryShadowView.class.getSimpleName()); }
@Test public void shouldLoadDefaultsFromPropertiesFile() throws Exception { Properties properties = properties( "emulateSdk: 432\n" + "manifest: --none\n" + "qualifiers: from-properties-file\n" + "resourceDir: from/properties/file/res\n" + "reportSdk: 234\n" + "shadows: org.robolectric.shadows.ShadowView, org.robolectric.shadows.ShadowViewGroup\n"); assertConfig(configFor(Test2.class, "withoutAnnotation", properties), 432, "--none", "from-properties-file", "from/properties/file/res", 234, new Class[] {ShadowView.class, ShadowViewGroup.class}); }
@Test public void cardDeckCreatorReturnsList() throws Exception { Activity cardDecCreActivity = Robolectric.buildActivity(CardCreatorActivity.class) .create().resume().get(); createCardButton = cardDecCreActivity.findViewById(R.id.button_save); final ShadowView shadowView = Robolectric.shadowOf(createCardButton); View.OnClickListener listener = shadowView.getOnClickListener(); assertNotNull(listener); }
@Test public void settersInvalidateView() { TooltipView view = createView(); ShadowView shadow = shadowOf(view); shadow.clearWasInvalidated(); view.setAnchoredViewId(sampleId); assertThat(shadow).wasInvalidated(); shadow.clearWasInvalidated(); view.setArrowHeight(123); assertThat(shadow).wasInvalidated(); shadow.clearWasInvalidated(); view.setArrowHeightResource(R.dimen.tooltip_default_arrow_height); assertThat(shadow).wasInvalidated(); shadow.clearWasInvalidated(); view.setArrowWidth(123); assertThat(shadow).wasInvalidated(); shadow.clearWasInvalidated(); view.setArrowWidthResource(R.dimen.tooltip_default_arrow_width); assertThat(shadow).wasInvalidated(); shadow.clearWasInvalidated(); view.setCornerRadius(123); assertThat(shadow).wasInvalidated(); shadow.clearWasInvalidated(); view.setCornerRadiusResource(R.dimen.tooltip_default_corner_radius); assertThat(shadow).wasInvalidated(); shadow.clearWasInvalidated(); view.setTooltipColor(123); assertThat(shadow).wasInvalidated(); shadow.clearWasInvalidated(); }
private void simulateTwoFingerDrag() { MotionEvent e = mock(MotionEvent.class); Mockito.when(e.getPointerCount()).thenReturn(2); Mockito.when(e.getAction()).thenReturn(MotionEvent.ACTION_MOVE); ShadowView view = shadowOf(act.findViewById(R.id.map)); view.getOnTouchListener().onTouch(null, e); }
private void clickOnOpenButton() { AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog(); Button openButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); ShadowView.clickOn(openButton); }
public static ShadowView shadowOf(View instance) { return (ShadowView) shadowOf_(instance); }
public ShadowViewAssert(ShadowView actual) { super(actual, ShadowViewAssert.class); }
public static ShadowViewAssert assertThat(ShadowView actual) { return new ShadowViewAssert(actual); }
private void simulateUserDrag() { MotionEvent e = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_MOVE, 120f, 100f, 0); ShadowView view = shadowOf(act.findViewById(R.id.map)); fragment.setCurrentXCor(3.0f); view.getOnTouchListener().onTouch(null, e); }