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


Java ActivityController.get方法代碼示例

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


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

示例1: testLifecycle

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
private void testLifecycle(ActivityController<? extends LifecycleProvider<ActivityEvent>> controller) {
    LifecycleProvider<ActivityEvent> activity = controller.get();

    TestObserver<ActivityEvent> testObserver = activity.lifecycle().test();

    controller.create();
    controller.start();
    controller.resume();
    controller.pause();
    controller.stop();
    controller.destroy();

    testObserver.assertValues(
        ActivityEvent.CREATE,
        ActivityEvent.START,
        ActivityEvent.RESUME,
        ActivityEvent.PAUSE,
        ActivityEvent.STOP,
        ActivityEvent.DESTROY
    );
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:22,代碼來源:RxActivityLifecycleTest.java

示例2: testBindUntilEvent

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
private void testBindUntilEvent(ActivityController<? extends LifecycleProvider<ActivityEvent>> controller) {
    LifecycleProvider<ActivityEvent> activity = controller.get();

    TestObserver<Object> testObserver = observable.compose(activity.bindUntilEvent(STOP)).test();

    controller.create();
    testObserver.assertNotComplete();
    controller.start();
    testObserver.assertNotComplete();
    controller.resume();
    testObserver.assertNotComplete();
    controller.pause();
    testObserver.assertNotComplete();
    controller.stop();
    testObserver.assertComplete();
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:17,代碼來源:RxActivityLifecycleTest.java

示例3: LoadReceipt

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Test
public void LoadReceipt()
{
    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    bundle.putString("receipt", "receipt");
    intent.putExtras(bundle);

    ActivityController activityController =  Robolectric.buildActivity(
        ReceiptViewActivity.class).withIntent(intent).create();
    activityController.start();
    activityController.resume();

    Activity activity = (Activity)activityController.get();
    WebView receiptView = (WebView)activity.findViewById(R.id.imageView);

    ShadowWebView.LoadDataWithBaseURL loadedData = shadowOf(receiptView).getLastLoadDataWithBaseURL();
    assertEquals("", loadedData.baseUrl);
    assertEquals("text/html", loadedData.mimeType);
    assertEquals("utf-8", loadedData.encoding);
    assertNull(loadedData.historyUrl);
    assertTrue(loadedData.data.contains("src=\"file://receipt\""));
}
 
開發者ID:brarcher,項目名稱:gift-card-guard,代碼行數:24,代碼來源:ReceiptViewActivityTest.java

示例4: 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

示例5: setUp

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    htmlInterstitialWebView = TestHtmlInterstitialWebViewFactory.getSingletonMock();
    resetMockedView(htmlInterstitialWebView);

    Context context = Robolectric.buildActivity(Activity.class).create().get();
    Intent moPubActivityIntent = MoPubActivity.createIntent(context,
            EXPECTED_HTML_DATA, mockAdReport, EXPECTED_IS_SCROLLABLE,
            EXPECTED_REDIRECT_URL,
            EXPECTED_CLICKTHROUGH_URL, EXPECTED_ORIENTATION, testBroadcastIdentifier);

    final ActivityController<MoPubActivity> subjectController = Robolectric.buildActivity(MoPubActivity.class).withIntent(moPubActivityIntent);
    subject = subjectController.get();
    ShadowLocalBroadcastManager.getInstance(subject).registerReceiver(broadcastReceiver, getHtmlInterstitialIntentFilter());
    subjectController.create();

    customEventInterstitialListener = mock(CustomEventInterstitialListener.class);
}
 
開發者ID:JSafaiyeh,項目名稱:Fabric-Example-App-Android,代碼行數:19,代碼來源:MoPubActivityTest.java

示例6: initializeTest

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
/**
 * Testing initialization
 */
@Test
@SuppressLint("RtlHardcoded")
public void initializeTest() {
    ActivityController<? extends CourseBaseActivity> controller =
            Robolectric.buildActivity(getActivityClass()).withIntent(getIntent());
    CourseBaseActivity activity = controller.get();

    controller.create();
    assertNotNull(activity.findViewById(R.id.last_accessed_bar));
    DrawerLayout drawerLayout = (DrawerLayout)
            activity.findViewById(R.id.drawer_layout);
    if (drawerLayout != null) {
        assertEquals(DrawerLayout.LOCK_MODE_LOCKED_CLOSED,
                drawerLayout.getDrawerLockMode(Gravity.LEFT));
        assertEquals(DrawerLayout.LOCK_MODE_LOCKED_CLOSED,
                drawerLayout.getDrawerLockMode(Gravity.RIGHT));
    }

    controller.postCreate(null).resume().postResume().visible();
}
 
開發者ID:edx,項目名稱:edx-app-android,代碼行數:24,代碼來源:CourseBaseActivityTest.java

示例7: processLifecycleTest

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
/**
 * Testing process start and finish method functionality
 */
@Test
public void processLifecycleTest() {
    // We need to retrieve the progressWheel view before calling visible(), since that
    // initializes fragment views as well, which might add other views with the same id
    ActivityController<? extends CourseBaseActivity> controller =
            Robolectric.buildActivity(getActivityClass()).withIntent(getIntent())
                    .create().start().postCreate(null).resume();
    CourseBaseActivity activity = controller.get();
    ProgressBar progressWheel = (ProgressBar)
            activity.findViewById(R.id.loading_indicator);
    controller.visible();
    if (progressWheel == null) {
        activity.startProcess();
        activity.finishProcess();
    } else {
        assertThat(progressWheel).isNotVisible();
        activity.startProcess();
        assertThat(progressWheel).isVisible();
        activity.finishProcess();
        assertThat(progressWheel).isNotVisible();
    }
}
 
開發者ID:edx,項目名稱:edx-app-android,代碼行數:26,代碼來源:CourseBaseActivityTest.java

示例8: test_00_MainActivity_FullLifecycle

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Test
public void test_00_MainActivity_FullLifecycle() {
  final ActivityController<MainActivity> controller = Robolectric.buildActivity(MainActivity.class);
  final MainActivity activity = controller.get();

  assertThat(activity, notNullValue());

  fullLifecycle(controller, new Runnable() {
    @Override
    public void run() {
      // binding manager instance should be available
      assertThat(activity.getBindingsManager(), notNullValue());

      // main activity does not have any bindings
      assertThat(activity.getBindingsManager().getBindings(), hasSize(0));
    }
  });
}
 
開發者ID:OleksandrKucherenko,項目名稱:binding-tc,代碼行數:19,代碼來源:LoginFillRobolectricTest.java

示例9: test_00_FullLifeCycle_WithIntent

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Test
public void test_00_FullLifeCycle_WithIntent() {
  final Intent intent = MainActivity.showPin(RuntimeEnvironment.application);
  final ActivityController<MainActivity> controller = Robolectric.buildActivity(MainActivity.class).withIntent(intent);
  final MainActivity activity = controller.get();

  assertThat(activity, notNullValue());

  fullLifecycle(controller, new Runnable() {
    @Override
    public void run() {
      final TextView tv = (TextView) activity.findViewById(R.id.tv_feedback);

      // tv_feedback is available only on PinFragment
      assertThat(tv, notNullValue());

      trace("PinFragment found");
    }
  });
}
 
開發者ID:OleksandrKucherenko,項目名稱:binding-tc,代碼行數:21,代碼來源:PinRobolectricTest.java

示例10: prepare

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Before
public void prepare() {
    MockitoAnnotations.initMocks(this);

    ActivityController<MainActivity_> activityController = Robolectric.buildActivity(MainActivity_.class);
    activityController.create();
    activity = activityController.get();

    activity.service = oauthService;
    activity.networkHelper = networkHelper;

    TestUtil.mockBackgroundExecutor();
    TestUtil.mockValidUser(activity.prefs);

    AQUtility.setExceptionHandler(exceptionHandler);
}
 
開發者ID:KoljaTM,項目名稱:Yarrn,代碼行數:17,代碼來源:AbstractRavelryActivityUnitTest.java

示例11: prepare

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Before
public void prepare() {
    MockitoAnnotations.initMocks(this);
    TestUtil.mockBackgroundExecutor();

    projectFragment = new ProjectFragment_();
    projectFragment.spiceManager = this.spiceManager;
    ActivityController<MainActivity_> activityController = Robolectric.buildActivity(MainActivity_.class).create();
    MainActivity activity = activityController.get();
    TestUtil.mockValidUser(activity.prefs);
    activity.fragmentFactory = this.fragmentFactory;
    given(fragmentFactory.getProjectsFragment()).willReturn(projectsFragment);
    given(fragmentFactory.getProjectFragment()).willReturn(projectFragment);
    activityController.start().resume();

    activity.onProjectSelected(PROJECT_ID, USERNAME);
}
 
開發者ID:KoljaTM,項目名稱:Yarrn,代碼行數:18,代碼來源:ProjectFragmentUnitTest.java

示例12: prepare

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Before
public void prepare() {
    MockitoAnnotations.initMocks(this);
    TestUtil.mockBackgroundExecutor();
    favoritesFragment = new FavoritesFragment_();
    favoritesFragment.spiceManager = this.spiceManager;
    ActivityController<MainActivity_> activityController = Robolectric.buildActivity(MainActivity_.class).create();
    activity = activityController.get();
    favoritesFragment.prefs = activity.prefs;
    TestUtil.mockValidUser(activity.prefs);
    activity.fragmentFactory = this.fragmentFactory;
    given(fragmentFactory.getProjectsFragment()).willReturn(projectsFragment);
    given(fragmentFactory.getFavoritesFragment()).willReturn(favoritesFragment);
    activityController.start().resume();
    activity.menuMyFavoritesClicked();
}
 
開發者ID:KoljaTM,項目名稱:Yarrn,代碼行數:17,代碼來源:FavoritesFragmentUnitTest.java

示例13: setUp

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Before
public void setUp() {
	MockitoAnnotations.initMocks(this);

	ActivityController<PreferencesActivity_> activityController = Robolectric.buildActivity(PreferencesActivity_.class);
	activityController.create();
	activity = activityController.get();

	prefs = activity.prefs;

	doAutoUpdate = (CheckBox) activity.findViewById(R.id.doAutoUpdate);
	doAutoUpdateWifiOnly = (CheckBox) activity
			.findViewById(R.id.doAutoUpdateWifiOnly);
	accountList = (ListView) activity.findViewById(R.id.accountList);
	addAccount = (Button) activity.findViewById(R.id.addAccount);
}
 
開發者ID:KoljaTM,項目名稱:HoebApp,代碼行數:17,代碼來源:PreferencesActivityTest.java

示例14: init

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Before
public void init() {
    ActivityController<Activity> activityController = Robolectric.buildActivity(Activity.class).create().start().resume()
            .visible();

    mActivity = activityController.get();

    mView = new CoachmarkView(mActivity);
}
 
開發者ID:Kaufland,項目名稱:andcoachmark,代碼行數:10,代碼來源:CoachmarkViewTest.java

示例15: testBindToLifecycle

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
private void testBindToLifecycle(ActivityController<? extends LifecycleProvider<ActivityEvent>> controller) {
    LifecycleProvider<ActivityEvent> activity = controller.get();

    controller.create();
    TestObserver<Object> createObserver = observable.compose(activity.bindToLifecycle()).test();

    controller.start();
    createObserver.assertNotComplete();
    TestObserver<Object> startObserver = observable.compose(activity.bindToLifecycle()).test();

    controller.resume();
    createObserver.assertNotComplete();
    startObserver.assertNotComplete();
    TestObserver<Object> resumeObserver = observable.compose(activity.bindToLifecycle()).test();

    controller.pause();
    createObserver.assertNotComplete();
    startObserver.assertNotComplete();
    resumeObserver.assertComplete();
    TestObserver<Object> pauseObserver = observable.compose(activity.bindToLifecycle()).test();

    controller.stop();
    createObserver.assertNotComplete();
    startObserver.assertComplete();
    pauseObserver.assertComplete();
    TestObserver<Object> stopObserver = observable.compose(activity.bindToLifecycle()).test();

    controller.destroy();
    createObserver.assertComplete();
    stopObserver.assertComplete();
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:32,代碼來源:RxActivityLifecycleTest.java


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