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


Java ActivityController.start方法代碼示例

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


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

示例1: testLifecycle

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

    TestObserver<Lifecycle.Event> testObserver = provider.lifecycle().test();

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

    testObserver.assertValues(
            Lifecycle.Event.ON_CREATE,
            Lifecycle.Event.ON_START,
            Lifecycle.Event.ON_RESUME,
            Lifecycle.Event.ON_PAUSE,
            Lifecycle.Event.ON_STOP,
            Lifecycle.Event.ON_DESTROY
    );
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:22,代碼來源:AndroidLifecycleActivityTest.java

示例2: testBindUntilEvent

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

    TestObserver<Object> testObserver = observable.compose(activity.bindUntilEvent(Lifecycle.Event.ON_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,代碼來源:AndroidLifecycleActivityTest.java

示例3: testLifecycle

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
private void testLifecycle(LifecycleOwner owner) {
    Fragment fragment = (Fragment) owner;
    ActivityController<?> controller = startFragment(fragment);

    TestObserver<Lifecycle.Event> testObserver = AndroidLifecycle.createLifecycleProvider(owner).lifecycle().test();

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

    testObserver.assertValues(
            Lifecycle.Event.ON_CREATE,
            Lifecycle.Event.ON_START,
            Lifecycle.Event.ON_RESUME,
            Lifecycle.Event.ON_PAUSE,
            Lifecycle.Event.ON_STOP,
            Lifecycle.Event.ON_DESTROY
    );
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:22,代碼來源:AndroidLifecycleFragmentTest.java

示例4: testBindUntilEvent

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
private void testBindUntilEvent(LifecycleOwner owner) {
    Fragment fragment = (Fragment) owner;
    ActivityController<?> controller = startFragment(fragment);

    TestObserver<Object> testObserver = observable.compose(AndroidLifecycle.createLifecycleProvider(owner).bindUntilEvent(Lifecycle.Event.ON_STOP)).test();

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

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

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

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

示例8: applyState

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
private void applyState(ActivityState state,
                        ActivityController controller) {
    switch (state) {
        case STARTED:
            controller.start();
            break;
        case RESUMED:
            controller.resume();
            break;
        case PAUSED:
            controller.pause();
            break;
        case STOPPED:
            controller.stop();
            break;
        case DESTROYED:
            controller.destroy();
            break;
        case CREATED:
        default:
            controller.create();
            break;
    }
}
 
開發者ID:florent37,項目名稱:AndroidUnitTest,代碼行數:25,代碼來源:ControllerActivity.java

示例9: testBindToLifecycle

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

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

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

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

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

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

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

示例10: testBindToLifecycle

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
private void testBindToLifecycle(LifecycleOwner owner) {
    Fragment fragment = (Fragment) owner;
    LifecycleProvider<Lifecycle.Event> provider = AndroidLifecycle.createLifecycleProvider(owner);
    ActivityController<?> controller = startFragment(fragment);

    TestObserver<Object> createObserver = observable.compose(provider.bindToLifecycle()).test();

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

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

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

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

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

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

示例12: addOneGiftCard

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Test
public void addOneGiftCard()
{
    ActivityController activityController = Robolectric.buildActivity(MainActivity.class).create();

    Activity mainActivity = (Activity)activityController.get();
    activityController.start();
    activityController.resume();

    TextView helpText = (TextView)mainActivity.findViewById(R.id.helpText);
    ListView list = (ListView)mainActivity.findViewById(R.id.list);

    assertEquals(0, list.getCount());

    DBHelper db = new DBHelper(mainActivity);
    db.insertGiftCard("store", "cardId", "value", "receipt");

    assertEquals(View.VISIBLE, helpText.getVisibility());
    assertEquals(View.GONE, list.getVisibility());

    activityController.pause();
    activityController.resume();

    assertEquals(View.GONE, helpText.getVisibility());
    assertEquals(View.VISIBLE, list.getVisibility());

    assertEquals(1, list.getAdapter().getCount());
    Cursor cursor = (Cursor)list.getAdapter().getItem(0);
    assertNotNull(cursor);
}
 
開發者ID:brarcher,項目名稱:gift-card-guard,代碼行數:31,代碼來源:MainActivityTest.java

示例13: onStartingActivity_presentsDataFromDelegate

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Test
public void onStartingActivity_presentsDataFromDelegate() throws Exception {
    doReturn("testing!").when(mAndroidBootDelegate).doSomething(anyString());

    final ActivityController<AndroidBootActivity> activityController = Robolectric.buildActivity(AndroidBootActivity.class).create();

    verifyZeroInteractions(mAndroidBootDelegate);

    activityController.start();

    verify(mAndroidBootDelegate).doSomething("what am i doing?");

    final AndroidBootActivity activity = activityController.get();

    final TextView view = (TextView) activity.findViewById(R.id.text);
    assertThat(view).hasText("testing!");
}
 
開發者ID:anthony-tarantini,項目名稱:android-labs-boot,代碼行數:18,代碼來源:AndroidBootActivityTest.java

示例14: fullLifecycle

import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
/**
 * Perform full lifecycle emulation for activity. When Activity is in visible state
 * is possible to execute some additional actions.
 */
public <T extends Activity> void fullLifecycle(@NonNull final ActivityController<T> controller,
                                               @Nullable final Runnable onRestart,
                                               @Nullable final Runnable onResume,
                                               @Nullable final Runnable onVisible) {
  final Bundle savedInstanceState = new Bundle();

  trace("state - onCreate");
  controller.create();

  // CYCLE #1: emulate activity restart
  int lifeLoops = 1;
  do {
    trace("state - onStart : " + lifeLoops);
    controller.start();

    controller.restoreInstanceState(savedInstanceState);

    controller.postCreate(savedInstanceState);

    // CYCLE #1.1: emulate show/hide
    int loops = 1;
    do {
      trace("state - onResume : " + loops);
      if (null != onResume) onResume.run();

      controller.resume(); // --> onPostResume()

      controller.visible(); // --> onUserInteraction()

      if (null != onVisible) onVisible.run();

      controller.userLeaving();

      controller.pause();

      loops--;
    } while (loops >= 0);

    controller.saveInstanceState(savedInstanceState);

    controller.stop();

    // go-to onRestart() state
    if (lifeLoops > 0) {
      if (null != onRestart) onRestart.run();

      trace("state - onRestart");
      controller.restart();
    }

    lifeLoops--;
  } while (lifeLoops >= 0);

  trace("state - onDestroy");
  controller.destroy();
}
 
開發者ID:OleksandrKucherenko,項目名稱:binding-tc,代碼行數:61,代碼來源:RobolectricTestHolder.java


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