Search in sources :

Example 11 with Scheduler

use of org.robolectric.util.Scheduler in project robolectric by robolectric.

the class ShadowLegacyLooperTest method reset_setsGlobalScheduler_forMainLooper_byDefault.

@Test
public void reset_setsGlobalScheduler_forMainLooper_byDefault() {
    ShadowLooper sMainLooper = ShadowLooper.getShadowMainLooper();
    Scheduler s = new Scheduler();
    RuntimeEnvironment.setMasterScheduler(s);
    sMainLooper.reset();
    assertThat(sMainLooper.getScheduler()).isSameInstanceAs(s);
}
Also used : Scheduler(org.robolectric.util.Scheduler) Test(org.junit.Test)

Example 12 with Scheduler

use of org.robolectric.util.Scheduler in project robolectric by robolectric.

the class ShadowLegacyLooperTest method reset_setsNewScheduler_forNonMainLooper_byDefault.

@Test
public void reset_setsNewScheduler_forNonMainLooper_byDefault() {
    HandlerThread ht = getHandlerThread();
    ShadowLooper sLooper = shadowOf(ht.getLooper());
    Scheduler old = sLooper.getScheduler();
    sLooper.reset();
    assertThat(sLooper.getScheduler()).isNotSameInstanceAs(old);
    assertThat(sLooper.getScheduler()).isNotSameInstanceAs(RuntimeEnvironment.getMasterScheduler());
}
Also used : HandlerThread(android.os.HandlerThread) Scheduler(org.robolectric.util.Scheduler) Test(org.junit.Test)

Example 13 with Scheduler

use of org.robolectric.util.Scheduler in project robolectric by robolectric.

the class ShadowApplicationTest method getBackgroundThreadScheduler_shouldDifferFromRuntimeEnvironment_byDefault.

@Test
@LooperMode(LEGACY)
public void getBackgroundThreadScheduler_shouldDifferFromRuntimeEnvironment_byDefault() {
    Scheduler s = new Scheduler();
    RuntimeEnvironment.setMasterScheduler(s);
    assertThat(Shadows.shadowOf(context).getBackgroundThreadScheduler()).isNotSameInstanceAs(RuntimeEnvironment.getMasterScheduler());
}
Also used : Scheduler(org.robolectric.util.Scheduler) Test(org.junit.Test) LooperMode(org.robolectric.annotation.LooperMode)

Example 14 with Scheduler

use of org.robolectric.util.Scheduler in project robolectric by robolectric.

the class ShadowLooperTest method reset_setsSchedulerToMaster_forNonMainLooper_withAdvancedScheduling.

@Test
public void reset_setsSchedulerToMaster_forNonMainLooper_withAdvancedScheduling() {
    HandlerThread ht = getHandlerThread();
    ShadowLooper sLooper = shadowOf(ht.getLooper());
    Scheduler s = new Scheduler();
    RuntimeEnvironment.setMasterScheduler(s);
    setAdvancedScheduling();
    sLooper.reset();
    assertThat(sLooper.getScheduler()).isSameAs(s);
}
Also used : HandlerThread(android.os.HandlerThread) Scheduler(org.robolectric.util.Scheduler) Test(org.junit.Test)

Example 15 with Scheduler

use of org.robolectric.util.Scheduler in project robolectric by robolectric.

the class ShadowLooperTest method reset_setsNewScheduler_forNonMainLooper_byDefault.

@Test
public void reset_setsNewScheduler_forNonMainLooper_byDefault() {
    HandlerThread ht = getHandlerThread();
    ShadowLooper sLooper = shadowOf(ht.getLooper());
    Scheduler old = sLooper.getScheduler();
    sLooper.reset();
    assertThat(sLooper.getScheduler()).isNotSameAs(old).isNotSameAs(RuntimeEnvironment.getMasterScheduler());
}
Also used : HandlerThread(android.os.HandlerThread) Scheduler(org.robolectric.util.Scheduler) Test(org.junit.Test)

Aggregations

Scheduler (org.robolectric.util.Scheduler)30 Test (org.junit.Test)22 HandlerThread (android.os.HandlerThread)8 Handler (android.os.Handler)6 Looper (android.os.Looper)6 LooperMode (org.robolectric.annotation.LooperMode)5 Application (android.app.Application)4 Context (android.content.Context)3 ApplicationInfo (android.content.pm.ApplicationInfo)2 Message (android.os.Message)2 ArrayList (java.util.ArrayList)2 BouncyCastleProvider (org.bouncycastle.jce.provider.BouncyCastleProvider)2 ShadowLooper.shadowMainLooper (org.robolectric.shadows.ShadowLooper.shadowMainLooper)2 ActivityThread (android.app.ActivityThread)1 Instrumentation (android.app.Instrumentation)1 LoadedApk (android.app.LoadedApk)1 JobScheduler (android.app.job.JobScheduler)1 PackageManager (android.content.pm.PackageManager)1 Configuration (android.content.res.Configuration)1 Resources (android.content.res.Resources)1