Search in sources :

Example 1 with ShadowLooper

use of org.robolectric.shadows.ShadowLooper in project weex-example by KalicyZhou.

the class WXDomStatementTest method setUp.

@Before
public void setUp() throws Exception {
    WXSDKEngine.initialize(RuntimeEnvironment.application, new InitConfig.Builder().build());
    ShadowLooper looper = WXBridgeManagerTest.getLooper();
    looper.idle();
    ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
    instance = WXSDKInstanceTest.createInstance();
    rednerManager = new WXRenderManager();
    //
    rednerManager.registerInstance(instance);
    stmt = new WXDomStatement(instance.getInstanceId(), rednerManager);
}
Also used : ShadowLooper(org.robolectric.shadows.ShadowLooper) WXRenderManager(com.taobao.weex.ui.WXRenderManager) Before(org.junit.Before)

Example 2 with ShadowLooper

use of org.robolectric.shadows.ShadowLooper in project incubator-weex by apache.

the class WXDomStatementTest method setUp.

@Before
public void setUp() throws Exception {
    WXSDKEngine.initialize(RuntimeEnvironment.application, new InitConfig.Builder().build());
    ShadowLooper looper = WXBridgeManagerTest.getLooper();
    looper.idle();
    ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
    instance = WXSDKInstanceTest.createInstance();
    rednerManager = new WXRenderManager();
    // 
    rednerManager.registerInstance(instance);
    WXSDKManagerTest.setRenderManager(rednerManager);
    stmt = new DOMActionContextImpl(instance.getInstanceId(), rednerManager);
}
Also used : ShadowLooper(org.robolectric.shadows.ShadowLooper) WXRenderManager(com.taobao.weex.ui.WXRenderManager) Before(org.junit.Before)

Example 3 with ShadowLooper

use of org.robolectric.shadows.ShadowLooper in project RxAndroid by ReactiveX.

the class AndroidSchedulersTest method asyncIgnoredPre16.

@Test
public void asyncIgnoredPre16() {
    ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", 14);
    ShadowLooper mainLooper = shadowOf(Looper.getMainLooper());
    mainLooper.pause();
    ShadowMessageQueue mainMessageQueue = shadowOf(Looper.getMainLooper().getQueue());
    Scheduler main = AndroidSchedulers.from(Looper.getMainLooper(), true);
    main.scheduleDirect(new Runnable() {

        @Override
        public void run() {
        }
    });
    Message message = mainMessageQueue.getHead();
    assertFalse(message.isAsynchronous());
}
Also used : ShadowMessageQueue(org.robolectric.shadows.ShadowMessageQueue) Message(android.os.Message) Build(android.os.Build) Scheduler(io.reactivex.rxjava3.core.Scheduler) EmptyScheduler(io.reactivex.rxjava3.android.testutil.EmptyScheduler) ShadowLooper(org.robolectric.shadows.ShadowLooper) Test(org.junit.Test)

Example 4 with ShadowLooper

use of org.robolectric.shadows.ShadowLooper in project RxAndroid by ReactiveX.

the class AndroidSchedulersTest method fromAsyncMessagesByDefault.

@Test
public void fromAsyncMessagesByDefault() {
    ShadowLooper mainLooper = shadowOf(Looper.getMainLooper());
    mainLooper.pause();
    ShadowMessageQueue mainMessageQueue = shadowOf(Looper.getMainLooper().getQueue());
    Scheduler main = AndroidSchedulers.from(Looper.getMainLooper());
    main.scheduleDirect(new Runnable() {

        @Override
        public void run() {
        }
    });
    Message message = mainMessageQueue.getHead();
    assertTrue(message.isAsynchronous());
}
Also used : ShadowMessageQueue(org.robolectric.shadows.ShadowMessageQueue) Message(android.os.Message) Scheduler(io.reactivex.rxjava3.core.Scheduler) EmptyScheduler(io.reactivex.rxjava3.android.testutil.EmptyScheduler) ShadowLooper(org.robolectric.shadows.ShadowLooper) Test(org.junit.Test)

Example 5 with ShadowLooper

use of org.robolectric.shadows.ShadowLooper in project RxAndroid by ReactiveX.

the class AndroidSchedulersTest method mainThreadAsyncMessagesByDefault.

@Test
public void mainThreadAsyncMessagesByDefault() {
    ShadowLooper mainLooper = shadowOf(Looper.getMainLooper());
    mainLooper.pause();
    ShadowMessageQueue mainMessageQueue = shadowOf(Looper.getMainLooper().getQueue());
    Scheduler main = AndroidSchedulers.mainThread();
    main.scheduleDirect(new Runnable() {

        @Override
        public void run() {
        }
    });
    Message message = mainMessageQueue.getHead();
    assertTrue(message.isAsynchronous());
}
Also used : ShadowMessageQueue(org.robolectric.shadows.ShadowMessageQueue) Message(android.os.Message) Scheduler(io.reactivex.rxjava3.core.Scheduler) EmptyScheduler(io.reactivex.rxjava3.android.testutil.EmptyScheduler) ShadowLooper(org.robolectric.shadows.ShadowLooper) Test(org.junit.Test)

Aggregations

ShadowLooper (org.robolectric.shadows.ShadowLooper)23 Test (org.junit.Test)20 Handler (android.os.Handler)4 MediaCodec (android.media.MediaCodec)3 Looper (android.os.Looper)3 Message (android.os.Message)3 EmptyScheduler (io.reactivex.rxjava3.android.testutil.EmptyScheduler)3 Scheduler (io.reactivex.rxjava3.core.Scheduler)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 ShadowMessageQueue (org.robolectric.shadows.ShadowMessageQueue)3 DrmSessionEventListener (com.google.android.exoplayer2.drm.DrmSessionEventListener)2 FakeSampleStream (com.google.android.exoplayer2.testutil.FakeSampleStream)2 DefaultAllocator (com.google.android.exoplayer2.upstream.DefaultAllocator)2 WXRenderManager (com.taobao.weex.ui.WXRenderManager)2 Before (org.junit.Before)2 LooperMode (org.robolectric.annotation.LooperMode)2 Build (android.os.Build)1 TimeoutException (java.util.concurrent.TimeoutException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1