Class Robolectric
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Activity>
ActivityController<T> buildActivity(Class<T> activityClass) Creates a ActivityController for the given activity class.static <T extends Activity>
ActivityController<T> buildActivity(Class<T> activityClass, Intent intent) Creates a ActivityController for the given activity class with the intent.static <T extends Activity>
ActivityController<T> buildActivity(Class<T> activityClass, Intent intent, Bundle activityOptions) Creates a ActivityController for the given activity class with the intent and activity options.static AttributeSetBuilderDeprecated.usegetAttributeSetFromXml(int)insteadstatic <T extends BackupAgent>
BackupAgentController<T> buildBackupAgent(Class<T> backupAgentClass) static <T extends ContentProvider>
ContentProviderController<T> buildContentProvider(Class<T> contentProviderClass) static <T extends Fragment>
FragmentController<T> buildFragment(Class<T> fragmentClass) Deprecated.Native Fragments have been deprecated in Android P.static <T extends Fragment>
FragmentController<T> buildFragment(Class<T> fragmentClass, Intent intent) Deprecated.Native Fragments have been deprecated in Android P.static <T extends Fragment>
FragmentController<T> buildFragment(Class<T> fragmentClass, Intent intent, Bundle arguments) Deprecated.Native Fragments have been deprecated in Android P.static <T extends Fragment>
FragmentController<T> buildFragment(Class<T> fragmentClass, Bundle arguments) Deprecated.Native Fragments have been deprecated in Android P.static <T extends Fragment>
FragmentController<T> buildFragment(Class<T> fragmentClass, Class<? extends Activity> activityClass) Deprecated.Native Fragments have been deprecated in Android P.static <T extends Fragment>
FragmentController<T> buildFragment(Class<T> fragmentClass, Class<? extends Activity> activityClass, Intent intent) Deprecated.Native Fragments have been deprecated in Android P.static <T extends Fragment>
FragmentController<T> buildFragment(Class<T> fragmentClass, Class<? extends Activity> activityClass, Intent intent, Bundle arguments) Deprecated.Native Fragments have been deprecated in Android P.static <T extends Fragment>
FragmentController<T> buildFragment(Class<T> fragmentClass, Class<? extends Activity> activityClass, Bundle arguments) Deprecated.Native Fragments have been deprecated in Android P.static <T extends IntentService>
IntentServiceController<T> buildIntentService(Class<T> serviceClass) static <T extends IntentService>
IntentServiceController<T> buildIntentService(Class<T> serviceClass, Intent intent) static <T extends Service>
ServiceController<T> buildService(Class<T> serviceClass) static <T extends Service>
ServiceController<T> buildService(Class<T> serviceClass, Intent intent) static voidDeprecated.TheSchedulerAPIs are designed for LEGACY Looper mode.static voidDeprecated.TheSchedulerAPIs are designed for LEGACY Looper mode.static AttributeSetgetAttributeSetFromXml(int xmlResId) Helper method for obtaining anAttributeSetfrom an xml resource idstatic SchedulerDeprecated.TheSchedulerAPIs are designed for LEGACY Looper mode.static SchedulerDeprecated.TheSchedulerAPIs are designed for LEGACY Looper mode.static <T extends Activity>
TsetupActivity(Class<T> activityClass) Deprecated.useinvalid reference
androidx.test.core.app.ActivityScenariostatic <T extends BackupAgent>
TsetupBackupAgent(Class<T> backupAgentClass) static <T extends ContentProvider>
TsetupContentProvider(Class<T> contentProviderClass) static <T extends ContentProvider>
TsetupContentProvider(Class<T> contentProviderClass, String authority) static <T extends IntentService>
TsetupIntentService(Class<T> serviceClass) static <T extends Service>
TsetupService(Class<T> serviceClass)
-
Constructor Details
-
Robolectric
public Robolectric()
-
-
Method Details
-
buildService
-
buildService
public static <T extends Service> ServiceController<T> buildService(Class<T> serviceClass, Intent intent) -
setupService
-
buildIntentService
public static <T extends IntentService> IntentServiceController<T> buildIntentService(Class<T> serviceClass) -
buildIntentService
public static <T extends IntentService> IntentServiceController<T> buildIntentService(Class<T> serviceClass, Intent intent) -
setupIntentService
-
buildContentProvider
public static <T extends ContentProvider> ContentProviderController<T> buildContentProvider(Class<T> contentProviderClass) -
setupContentProvider
-
setupContentProvider
public static <T extends ContentProvider> T setupContentProvider(Class<T> contentProviderClass, String authority) -
buildActivity
Creates a ActivityController for the given activity class.Consider using
instead, which provides higher-level, streamlined APIs to control the lifecycle and it works with instrumentation tests too.invalid reference
androidx.test.core.app.ActivityScenario -
buildActivity
public static <T extends Activity> ActivityController<T> buildActivity(Class<T> activityClass, Intent intent) Creates a ActivityController for the given activity class with the intent.Note: the activity class is not determined by the intent.
Consider using
instead, which provides higher-level, streamlined APIs to control the lifecycle and it works with instrumentation tests too.invalid reference
androidx.test.core.app.ActivityScenario -
buildActivity
public static <T extends Activity> ActivityController<T> buildActivity(Class<T> activityClass, Intent intent, @Nullable Bundle activityOptions) Creates a ActivityController for the given activity class with the intent and activity options.Note: the activity class is not determined by the intent.
Note: Display ID is the only option currently supported in the options bundle. Other options are ignored.
Consider using
instead, which provides higher-level, streamlined APIs to control the lifecycle and it works with instrumentation tests too.invalid reference
androidx.test.core.app.ActivityScenario -
setupActivity
Deprecated.useinvalid reference
androidx.test.core.app.ActivityScenarioSimulates starting activity with the given class type and returns its reference.Use
instead, which works with instrumentation tests too.invalid reference
androidx.test.core.app.ActivityScenario -
buildFragment
@Deprecated public static <T extends Fragment> FragmentController<T> buildFragment(Class<T> fragmentClass) Deprecated.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Creates a FragmentController for the given fragment class.FragmentController provides low-level APIs to control its lifecycle. Please consider using
instead, which provides higher level APIs and works with instrumentation tests too.invalid reference
androidx.fragment.app.testing.FragmentScenario -
buildFragment
@Deprecated public static <T extends Fragment> FragmentController<T> buildFragment(Class<T> fragmentClass, Bundle arguments) Deprecated.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Creates a FragmentController for the given fragment class with the arguments.FragmentController provides low-level APIs to control its lifecycle. Please consider using
instead, which provides higher level APIs and works with instrumentation tests too.invalid reference
androidx.fragment.app.testing.FragmentScenario -
buildFragment
@Deprecated public static <T extends Fragment> FragmentController<T> buildFragment(Class<T> fragmentClass, Class<? extends Activity> activityClass) Deprecated.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Creates a FragmentController for the given fragment class in the specified host activity.In general, it's a bad practice to design a fragment having dependency to a specific activity. Consider removing the dependency and use other
buildFragment(java.lang.Class<T>)method or.invalid reference
androidx.fragment.app.testing.FragmentScenarioFragmentController provides low-level APIs to control its lifecycle. Please consider using
instead, which provides higher level APIs and works with instrumentation tests too.invalid reference
androidx.fragment.app.testing.FragmentScenario -
buildFragment
@Deprecated public static <T extends Fragment> FragmentController<T> buildFragment(Class<T> fragmentClass, Intent intent) Deprecated.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Creates a FragmentController for the given fragment class. The given intent is set to the host activity.Note: the host activity class is not determined by the intent.
FragmentController provides low-level APIs to control its lifecycle. Please consider using
instead, which provides higher level APIs and works with instrumentation tests too.invalid reference
androidx.fragment.app.testing.FragmentScenario -
buildFragment
@Deprecated public static <T extends Fragment> FragmentController<T> buildFragment(Class<T> fragmentClass, Intent intent, Bundle arguments) Deprecated.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Creates a FragmentController for the given fragment class with the arguments. The given intent is set to the host activity.Note: the host activity class is not determined by the intent.
FragmentController provides low-level APIs to control its lifecycle. Please consider using
instead, which provides higher level APIs and works with instrumentation tests too.invalid reference
androidx.fragment.app.testing.FragmentScenario -
buildFragment
@Deprecated public static <T extends Fragment> FragmentController<T> buildFragment(Class<T> fragmentClass, Class<? extends Activity> activityClass, Intent intent) Deprecated.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Creates a FragmentController for the given fragment class in the specified host activity. The given intent is set to the host activity.Note: the host activity class is not determined by the intent.
In general, it's a bad practice to design a fragment having dependency to a specific activity. Consider removing the dependency and use other
buildFragment(java.lang.Class<T>)method or.invalid reference
androidx.fragment.app.testing.FragmentScenarioFragmentController provides low-level APIs to control its lifecycle. Please consider using
instead, which provides higher level APIs and works with instrumentation tests too.invalid reference
androidx.fragment.app.testing.FragmentScenario -
buildFragment
@Deprecated public static <T extends Fragment> FragmentController<T> buildFragment(Class<T> fragmentClass, Class<? extends Activity> activityClass, Bundle arguments) Deprecated.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Creates a FragmentController for the given fragment class in the specified host activity with the arguments.In general, it's a bad practice to design a fragment having dependency to a specific activity. Consider removing the dependency and use other
buildFragment(java.lang.Class<T>)method or.invalid reference
androidx.fragment.app.testing.FragmentScenarioFragmentController provides low-level APIs to control its lifecycle. Please consider using
instead, which provides higher level APIs and works with instrumentation tests too.invalid reference
androidx.fragment.app.testing.FragmentScenario -
buildFragment
@Deprecated public static <T extends Fragment> FragmentController<T> buildFragment(Class<T> fragmentClass, Class<? extends Activity> activityClass, Intent intent, Bundle arguments) Deprecated.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Creates a FragmentController for the given fragment class in the specified host activity with the arguments. The given intent is set to the host activity.Note: the host activity class is not determined by the intent.
In general, it's a bad practice to design a fragment having dependency to a specific activity. Consider removing the dependency and use other
buildFragment(java.lang.Class<T>)method or.invalid reference
androidx.fragment.app.testing.FragmentScenarioFragmentController provides low-level APIs to control its lifecycle. Please consider using
instead, which provides higher level APIs and works with instrumentation tests too.invalid reference
androidx.fragment.app.testing.FragmentScenario -
buildBackupAgent
public static <T extends BackupAgent> BackupAgentController<T> buildBackupAgent(Class<T> backupAgentClass) -
setupBackupAgent
-
buildAttributeSet
Deprecated.usegetAttributeSetFromXml(int)insteadAllows for the programmatic creation of anAttributeSet.Useful for testing
Viewclasses without the need for creating XML snippets. -
getAttributeSetFromXml
Helper method for obtaining anAttributeSetfrom an xml resource id -
getForegroundThreadScheduler
Deprecated.TheSchedulerAPIs are designed for LEGACY Looper mode. It is strongly recommended to migrate tests to PAUSED Looper mode to avoid the need for this API.Return the foreground scheduler (e.g. the UI thread scheduler).- Returns:
- Foreground scheduler.
-
flushForegroundThreadScheduler
Deprecated.TheSchedulerAPIs are designed for LEGACY Looper mode. UseShadowLooper.runToEndOfTasks()instead.Execute all runnables that have been enqueued on the foreground scheduler. -
getBackgroundThreadScheduler
Deprecated.TheSchedulerAPIs are designed for LEGACY Looper mode. It is strongly recommended to migrate tests to PAUSED Looper mode to avoid the need for this API.Return the background scheduler.- Returns:
- Background scheduler.
-
flushBackgroundThreadScheduler
Deprecated.TheSchedulerAPIs are designed for LEGACY Looper mode. UseShadowLooper.runToEndOfTasks()instead.Execute all runnables that have been enqueued on the background scheduler.
-
Xml.asAttributeSet(XmlPullParser)instead.