當前位置: 首頁>>代碼示例>>Java>>正文


Java ActivityController.setup方法代碼示例

本文整理匯總了Java中org.robolectric.util.ActivityController.setup方法的典型用法代碼示例。如果您正苦於以下問題:Java ActivityController.setup方法的具體用法?Java ActivityController.setup怎麽用?Java ActivityController.setup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.robolectric.util.ActivityController的用法示例。


在下文中一共展示了ActivityController.setup方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testPresenterReceivesPermissionWhenRequestedFromActivity

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Test
public void testPresenterReceivesPermissionWhenRequestedFromActivity() {

    TodayWeatherPresenterBuilder builder = new TodayWeatherPresenterBuilder(
            new TodayWeatherFragmentController(new TodayWeatherFragment(), MainActivity.class), provider)
            .in(R.id.container);

    TodayWeatherPresenterBuilder.BindingResult bindingResult = configurePresenter(builder, ViewType.REAL, PresenterType.MOCK);
    TodayWeatherPresenter presenter = bindingResult.presenter();

    ActivityController<MainActivity> controller = Robolectric.buildActivity(MainActivity.class);
    controller.setup();

    String[] permissions = {Manifest.permission.ACCESS_COARSE_LOCATION};
    int[] grantResults = {PackageManager.PERMISSION_GRANTED};
    MainActivity mainActivity = controller.get();
    mainActivity.onRequestPermissionsResult(1, permissions, grantResults);

    verify(presenter).onEventPermissionsResult(eq(new PermissionEvent(1, permissions, grantResults)));
}
 
開發者ID:aschattney,項目名稱:annotated-mvp,代碼行數:21,代碼來源:PermissionTest.java

示例2: mainActivityReceivesErrorIfLoadingWeatherFails

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Test
public void mainActivityReceivesErrorIfLoadingWeatherFails() throws IOException
{
    WeatherService weatherService = mock(WeatherService.class);
    when(weatherService.getCurrentWeather(anyDouble(), anyDouble(), anyString()))
        .thenThrow(new IOException("Loading weather failed: with some internal exception message..."));

    LocationProvider locationProvider = mock(LocationProvider.class);
    when(locationProvider.lastLocation()).thenReturn(createLocation(1.0, 1.0));

    ActivityController<MainActivity> controller = Robolectric.buildActivity(MainActivity.class);
    controller.setup();

    TodayWeatherPresenterBuilder builder = new TodayWeatherPresenterBuilder(
            new TodayWeatherFragmentController(new TodayWeatherFragment(), MainActivity.class), provider)
            .parameter(weatherService)
            .parameter(locationProvider)
            .in(R.id.container);

    WeatherView mockView = mock(WeatherView.class);
    doReturn(true).when(mockView).isPermissionGranted(anyString());
    TodayWeatherPresenterBuilder.BindingResult bindingResult = configurePresenter(builder, mockView, PresenterType.REAL);
    when(bindingResult.view().isPermissionGranted(anyString())).thenReturn(true);

    assertTrue(ShadowToast.getTextOfLatestToast().startsWith("Loading weather failed:"));

}
 
開發者ID:aschattney,項目名稱:annotated-mvp,代碼行數:28,代碼來源:PermissionTest.java

示例3: startActivity

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
protected void startActivity(@NonNull final Intent intent) {
    final ActivityController<ActivityT> controller = Robolectric.buildActivity(getActivityType()).withIntent(intent);
    this.activity = controller.get();
    this.presenter = mock(getPresenterType());
    activity.presenter = presenter;
    controller.setup();
    this.view = activity.view;
}
 
開發者ID:edx,項目名稱:edx-app-android,代碼行數:9,代碼來源:PresenterActivityTest.java


注:本文中的org.robolectric.util.ActivityController.setup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。