当前位置: 首页>>代码示例>>Java>>正文


Java ShadowHandler.idleMainLooper方法代码示例

本文整理汇总了Java中org.robolectric.shadows.ShadowHandler.idleMainLooper方法的典型用法代码示例。如果您正苦于以下问题:Java ShadowHandler.idleMainLooper方法的具体用法?Java ShadowHandler.idleMainLooper怎么用?Java ShadowHandler.idleMainLooper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.robolectric.shadows.ShadowHandler的用法示例。


在下文中一共展示了ShadowHandler.idleMainLooper方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testThatIfAllDispensingItemsHaveQuantitiesNoToastIsMade

import org.robolectric.shadows.ShadowHandler; //导入方法依赖的package包/类
@Test
public void testThatIfAllDispensingItemsHaveQuantitiesNoToastIsMade() throws Exception {

    DispenseActivity dispenseActivity = getDispenseActivity();

    GridView mockGridView = mock(GridView.class);
    SelectedCommoditiesAdapter mockCommoditiesAdapter = mock(SelectedCommoditiesAdapter.class);
    View mockListItemView = mock(View.class);
    EditText mockEditText = new EditText(application);
    mockEditText.setText("12");

    when(mockListItemView.findViewById(R.id.editTextQuantity)).thenReturn(mockEditText);
    when(mockGridView.getChildAt(anyInt())).thenReturn(mockListItemView);
    when(mockGridView.getChildCount()).thenReturn(1);
    when(mockCommoditiesAdapter.getItem(anyInt())).thenReturn(new BaseCommodityViewModel(new Commodity("food")));
    when(mockGridView.getAdapter()).thenReturn(mockCommoditiesAdapter);

    dispenseActivity.gridViewSelectedCommodities = mockGridView;
    dispenseActivity.findViewById(R.id.buttonSubmitDispense).performClick();
    ShadowHandler.idleMainLooper();

    assertThat(ShadowToast.getTextOfLatestToast(), is(Matchers.nullValue()));


}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:26,代码来源:DispenseActivityTest.java

示例2: testThatIfAnyOfTheDispensingItemsHaveErrorsAToastIsMade

import org.robolectric.shadows.ShadowHandler; //导入方法依赖的package包/类
@Test
public void testThatIfAnyOfTheDispensingItemsHaveErrorsAToastIsMade() throws Exception {
    DispenseActivity dispenseActivity = getDispenseActivity();

    GridView mockGridView = mock(GridView.class);
    View mockListItemView = mock(View.class);
    EditText mockEditText = new EditText(application);

    mockEditText.setText("12");
    mockEditText.setError("error");
    SelectedCommoditiesAdapter mockSelectedCommoditiesAdapter = mock(SelectedCommoditiesAdapter.class);

    when(mockListItemView.findViewById(R.id.editTextQuantity)).thenReturn(mockEditText);
    when(mockSelectedCommoditiesAdapter.getItem(anyInt())).thenReturn(new BaseCommodityViewModel(new Commodity("food")));
    when(mockSelectedCommoditiesAdapter.getCount()).thenReturn(1);
    when(mockSelectedCommoditiesAdapter.getView(anyInt(), org.mockito.Matchers.any(View.class), org.mockito.Matchers.any(ViewGroup.class))).thenReturn(mockListItemView);
    when(mockGridView.getAdapter()).thenReturn(mockSelectedCommoditiesAdapter);
    when(mockGridView.getChildAt(anyInt())).thenReturn(mockListItemView);
    when(mockGridView.getChildCount()).thenReturn(1);

    dispenseActivity.gridViewSelectedCommodities = mockGridView;
    dispenseActivity.findViewById(R.id.buttonSubmitDispense).performClick();
    ShadowHandler.idleMainLooper();

    assertThat(ShadowToast.getTextOfLatestToast(), equalTo(application.getString(R.string.dispense_submit_validation_message_errors)));
}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:27,代码来源:DispenseActivityTest.java

示例3: testThatIfAllDispensingItemsHaveNoQuantitiesAToastIsMade

import org.robolectric.shadows.ShadowHandler; //导入方法依赖的package包/类
@Test
public void testThatIfAllDispensingItemsHaveNoQuantitiesAToastIsMade() throws Exception {
    DispenseActivity dispenseActivity = getDispenseActivity();

    GridView mockGridView = mock(GridView.class);
    View mockListItemView = mock(View.class);
    EditText mockEditText = new EditText(application);
    SelectedCommoditiesAdapter mockSelectedCommoditiesAdapter = mock(SelectedCommoditiesAdapter.class);

    when(mockListItemView.findViewById(R.id.editTextQuantity)).thenReturn(mockEditText);
    when(mockGridView.getAdapter()).thenReturn(mockSelectedCommoditiesAdapter);
    when(mockSelectedCommoditiesAdapter.getItem(anyInt())).thenReturn(new BaseCommodityViewModel(new Commodity("food")));
    when(mockSelectedCommoditiesAdapter.getCount()).thenReturn(1);
    when(mockSelectedCommoditiesAdapter.getView(anyInt(), org.mockito.Matchers.any(View.class), org.mockito.Matchers.any(ViewGroup.class))).thenReturn(mockListItemView);
    when(mockGridView.getChildAt(anyInt())).thenReturn(mockListItemView);
    when(mockGridView.getChildCount()).thenReturn(1);

    dispenseActivity.gridViewSelectedCommodities = mockGridView;
    dispenseActivity.findViewById(R.id.buttonSubmitDispense).performClick();
    ShadowHandler.idleMainLooper();
    assertThat(ShadowToast.getTextOfLatestToast(), equalTo(application.getString(R.string.dispense_submit_validation_message_filled)));
}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:23,代码来源:DispenseActivityTest.java

示例4: testThatIfAllDispensingItemsHaveZeroQuantitiesAToastIsMade

import org.robolectric.shadows.ShadowHandler; //导入方法依赖的package包/类
@Test
public void testThatIfAllDispensingItemsHaveZeroQuantitiesAToastIsMade() throws Exception {
    DispenseActivity dispenseActivity = getDispenseActivity();

    GridView mockGridView = mock(GridView.class);
    View mockListItemView = mock(View.class);
    SelectedCommoditiesAdapter mockSelectedCommoditiesAdapter = mock(SelectedCommoditiesAdapter.class);
    EditText mockEditText = new EditText(application);

    mockEditText.setText("0");

    when(mockListItemView.findViewById(R.id.editTextQuantity)).thenReturn(mockEditText);
    when(mockListItemView.findViewById(R.id.editTextQuantity)).thenReturn(mockEditText);
    when(mockGridView.getAdapter()).thenReturn(mockSelectedCommoditiesAdapter);
    when(mockSelectedCommoditiesAdapter.getItem(anyInt())).thenReturn(new BaseCommodityViewModel(new Commodity("food")));
    when(mockSelectedCommoditiesAdapter.getCount()).thenReturn(1);
    when(mockSelectedCommoditiesAdapter.getView(anyInt(), org.mockito.Matchers.any(View.class), org.mockito.Matchers.any(ViewGroup.class))).thenReturn(mockListItemView);
    when(mockGridView.getChildAt(anyInt())).thenReturn(mockListItemView);
    when(mockGridView.getChildCount()).thenReturn(1);

    dispenseActivity.gridViewSelectedCommodities = mockGridView;
    dispenseActivity.findViewById(R.id.buttonSubmitDispense).performClick();
    ShadowHandler.idleMainLooper();
    assertThat(ShadowToast.getTextOfLatestToast(), equalTo(application.getString(R.string.dispense_submit_validation_message_zero)));
}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:26,代码来源:DispenseActivityTest.java

示例5: shouldShowErrorToastIfNotAVaccine

import org.robolectric.shadows.ShadowHandler; //导入方法依赖的package包/类
@Ignore("WIP-JOB")
public void shouldShowErrorToastIfNotAVaccine() throws Exception {
    ArrayList<AdjustmentsViewModel> commodities = new ArrayList<>();

    Commodity commodity = mock(Commodity.class);
    when(commodity.isVaccine()).thenReturn(false);
    when(commodity.getName()).thenReturn("Panadol");

    AdjustmentsViewModel adjustmentsViewModel = new AdjustmentsViewModel(commodity, 12, false);
    adjustmentsViewModel.setAdjustmentReason(AdjustmentReason.RETURNED_TO_LGA);
    commodities.add(adjustmentsViewModel);

    AdjustmentsActivity activity = getAdjustmentsActivity();
    EventBus.getDefault().post(new CommodityToggledEvent(adjustmentsViewModel));
    activity.spinnerAdjustmentReason.setSelection(4);

    Button submitButton = activity.getSubmitButton();
    submitButton.performClick();
    ShadowHandler.idleMainLooper();
    assertThat(ShadowToast.getTextOfLatestToast(), is(application.getResources().getString(R.string.not_related_to_vaccine)));
}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:22,代码来源:AdjustmentsActivityTest.java

示例6: onSearchButtonClicked_shouldDisplayToastIfEditTextsAreEmpty

import org.robolectric.shadows.ShadowHandler; //导入方法依赖的package包/类
@Test
public void onSearchButtonClicked_shouldDisplayToastIfEditTextsAreEmpty() {
    Button searchButton = (Button) mMainActivity.findViewById(R.id.search_button);
    searchButton.performClick();
    ShadowHandler.idleMainLooper();
    assertThat(ShadowToast.getTextOfLatestToast()).isEqualTo("Please fill in both fields!");
}
 
开发者ID:christhetree,项目名称:Android_Yellow_Pages_App_TDD,代码行数:8,代码来源:MainActivityTest.java

示例7: shouldShowMessageAboutOutstandingAlertsIfAny

import org.robolectric.shadows.ShadowHandler; //导入方法依赖的package包/类
@Test    
public void shouldShowMessageAboutOutstandingAlertsIfAny() throws Exception {
    Intent intent = new Intent();
    when(alertsService.getNumberOfRoutineOrderAlerts()).thenReturn(2);
    intent.putExtra(AlertClickListener.ORDER_TYPE, OrderType.ROUTINE);
    orderActivity = Robolectric.buildActivity(OrderActivity.class).withIntent(intent).create().start().resume().visible().get();
    ShadowHandler.idleMainLooper();
    assertThat(ShadowToast.getTextOfLatestToast(), is(application.getString(R.string.outstanding_routine_order_alerts_message)));
}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:10,代码来源:OrderActivityTest.java

示例8: shouldNotShowMessageAboutOutstandingAlertsIfItIsOnlyOne

import org.robolectric.shadows.ShadowHandler; //导入方法依赖的package包/类
@Test    
public void shouldNotShowMessageAboutOutstandingAlertsIfItIsOnlyOne() throws Exception {
    Intent intent = new Intent();
    when(alertsService.getNumberOfRoutineOrderAlerts()).thenReturn(1);
    intent.putExtra(AlertClickListener.ORDER_TYPE, OrderType.ROUTINE);
    orderActivity = Robolectric.buildActivity(OrderActivity.class).withIntent(intent).create().start().resume().visible().get();
    ShadowHandler.idleMainLooper();
    assertThat(ShadowToast.getTextOfLatestToast(), is(nullValue()));
}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:10,代码来源:OrderActivityTest.java

示例9: testMessageShouldBeShownIfRegistrationIsSuccessful

import org.robolectric.shadows.ShadowHandler; //导入方法依赖的package包/类
@Test
public void testMessageShouldBeShownIfRegistrationIsSuccessful() {
    performSuccessfulRegistration();

    ShadowHandler.idleMainLooper();
    assertThat(getTextOfLatestToast(), equalTo(registerActivity.getString(R.string.registration_successful_message)));
}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:8,代码来源:RegisterActivityTest.java

示例10: testErrorShouldBeShownIfRegistrationFailed

import org.robolectric.shadows.ShadowHandler; //导入方法依赖的package包/类
@Test
public void testErrorShouldBeShownIfRegistrationFailed() {
    String errorMessage = "Some failure message";
    when(mockUserService.register(anyString(), anyString())).thenThrow(new LmisException(errorMessage));
    fillTextField(id.textUsername, "adminsdsd");
    fillTextField(id.textPassword, "districtsds");
    getRegisterButton().performClick();

    ShadowHandler.idleMainLooper();
    assertThat(getTextOfLatestToast(), equalTo(errorMessage));

}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:13,代码来源:RegisterActivityTest.java

示例11: shouldNotLetUserSubmitFormWhenAllocationIdHasError

import org.robolectric.shadows.ShadowHandler; //导入方法依赖的package包/类
@Test
public void shouldNotLetUserSubmitFormWhenAllocationIdHasError() throws Exception {
    ReceiveActivity receiveActivity = getReceiveActivity();
    setSource(receiveActivity, application.getString(R.string.lga_for_receive));
    receiveActivity.textViewAllocationId.setText("aoiiouads");
    receiveActivity.buttonSubmitReceive.performClick();

    ShadowHandler.idleMainLooper();
    assertThat(ShadowToast.getTextOfLatestToast(), equalTo(application.getString(R.string.receive_submit_validation_message_allocation_id)));
}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:11,代码来源:ReceiveActivityTest.java

示例12: shouldNotRequireAllocationIdWhenNotRecievingFromLGA

import org.robolectric.shadows.ShadowHandler; //导入方法依赖的package包/类
@Test
public void shouldNotRequireAllocationIdWhenNotRecievingFromLGA() throws Exception {
    ReceiveActivity receiveActivity = getReceiveActivity();
    setSource(receiveActivity, application.getString(R.string.zonal_store_for_receive));
    ANDROID.assertThat(receiveActivity.textViewAllocationId).isDisabled();
    setupValidCommodity(receiveActivity);
    receiveActivity.getSubmitButton().performClick();
    ShadowHandler.idleMainLooper();
    assertThat(ShadowToast.getTextOfLatestToast(), is(nullValue()));
}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:11,代码来源:ReceiveActivityTest.java

示例13: shouldLetUserSubmitFormWhenAllocationIdAndQuantitiesAreValid

import org.robolectric.shadows.ShadowHandler; //导入方法依赖的package包/类
@Test
public void shouldLetUserSubmitFormWhenAllocationIdAndQuantitiesAreValid() throws Exception {
    performSubmitWithValidFields();
    ShadowHandler.idleMainLooper();
    assertThat(ShadowToast.getTextOfLatestToast(), is(nullValue()));
}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:7,代码来源:ReceiveActivityTest.java


注:本文中的org.robolectric.shadows.ShadowHandler.idleMainLooper方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。