Android Testing Handler.postDelayed

后端 未结 3 1453
自闭症患者
自闭症患者 2021-01-01 23:22

I\'m newbie on Android and get stuck on testing a SplashScreen, basically what I\'m doing is trying to test that the splash screen stays on for 3s. this is the code for the

3条回答
  •  梦谈多话
    2021-01-01 23:27

    In Robolectric 3.0, IuriiO's answer would translate to-

    ShadowLooper.pauseMainLooper();
    Robolectric.getForegroundThreadScheduler().advanceBy(intervalMs);
    ShadowLooper.unPauseMainLooper();
    

提交回复
热议问题