本文整理匯總了Java中org.robolectric.util.ActivityController.create方法的典型用法代碼示例。如果您正苦於以下問題:Java ActivityController.create方法的具體用法?Java ActivityController.create怎麽用?Java ActivityController.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.robolectric.util.ActivityController
的用法示例。
在下文中一共展示了ActivityController.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
);
}
示例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();
}
示例3: 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
);
}
示例4: 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();
}
示例5: 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;
}
}
示例6: onLoadLoginView_withNoRedirectUrl_shouldReturnError
import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Test
public void onLoadLoginView_withNoRedirectUrl_shouldReturnError() {
SessionConfiguration config = new SessionConfiguration.Builder().setClientId("clientId").build();
Intent intent = new Intent();
intent.putExtra(LoginActivity.EXTRA_SESSION_CONFIGURATION, config);
final ActivityController<LoginActivity> controller = Robolectric.buildActivity(LoginActivity.class)
.withIntent(intent);
final ShadowActivity shadowActivity = Shadows.shadowOf(controller.get());
controller.create();
assertThat(shadowActivity.isFinishing()).isTrue();
assertThat(shadowActivity.getResultCode()).isEqualTo(Activity.RESULT_CANCELED);
assertThat(shadowActivity.getResultIntent()).isNotNull();
assertThat(shadowActivity.getResultIntent().getStringExtra(LoginManager.EXTRA_ERROR)).isNotEmpty();
}
示例7: 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);
}
示例8: 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();
}
示例9: 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);
}
示例10: 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);
}
示例11: 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();
}
示例12: startFragment
import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
private ActivityController<FragmentActivity> startFragment(Fragment fragment) {
ActivityController<FragmentActivity> controller = Robolectric.buildActivity(FragmentActivity.class);
controller.create();
controller.get().getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content, fragment)
.commitNow();
return controller;
}
示例13: 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();
}
示例14: shouldFinishLoginActivityWhenCompleted
import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Test
public void shouldFinishLoginActivityWhenCompleted() {
Activity context = Robolectric
.buildActivity(Activity.class)
.create()
.get();
AuthenticationRequest request = new AuthenticationRequest.Builder("test", AuthenticationResponse.Type.TOKEN, "test://test").build();
AuthenticationResponse response = new AuthenticationResponse.Builder()
.setType(AuthenticationResponse.Type.TOKEN)
.setAccessToken("test_token")
.setExpiresIn(3600)
.build();
Bundle bundle = new Bundle();
bundle.putParcelable(LoginActivity.REQUEST_KEY, request);
Intent intent = new Intent(context, LoginActivity.class);
intent.putExtra(LoginActivity.EXTRA_AUTH_REQUEST, bundle);
ActivityController<LoginActivity> loginActivityActivityController = buildActivity(LoginActivity.class)
.withIntent(intent);
final LoginActivity loginActivity = loginActivityActivityController.get();
final ShadowActivity shadowLoginActivity = shadowOf(loginActivity);
shadowLoginActivity.setCallingActivity(context.getComponentName());
loginActivityActivityController.create();
assertFalse(loginActivity.isFinishing());
loginActivity.onClientComplete(response);
assertTrue(loginActivity.isFinishing());
assertEquals(Activity.RESULT_OK, shadowLoginActivity.getResultCode());
assertEquals(response, shadowLoginActivity.getResultIntent().getBundleExtra(LoginActivity.EXTRA_AUTH_RESPONSE).get(LoginActivity.RESPONSE_KEY));
}
示例15: onLoginLoad_withEmptySessionConfiguration_shouldReturnErrorResultIntent
import org.robolectric.util.ActivityController; //導入方法依賴的package包/類
@Test
public void onLoginLoad_withEmptySessionConfiguration_shouldReturnErrorResultIntent() {
ActivityController<LoginActivity> controller = Robolectric.buildActivity(LoginActivity.class);
controller.create();
ShadowActivity shadowActivity = shadowOf(controller.get());
assertThat(shadowActivity.getResultCode()).isEqualTo(Activity.RESULT_CANCELED);
assertThat(shadowActivity.getResultIntent()).isNotNull();
assertThat(getScopeFromIntent(shadowActivity.getResultIntent()))
.isEqualTo(AuthenticationError.UNAVAILABLE);
assertThat(shadowActivity.isFinishing()).isTrue();
}