org.robolectric.util.Scheduler.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中org.robolectric.util.Scheduler.<init>()方法的一些代码示例,展示了Scheduler.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scheduler.<init>()方法的具体详情如下:
包路径:org.robolectric.util.Scheduler
类名称:Scheduler
方法名:<init>

Scheduler.<init>介绍

暂无

代码示例

代码示例来源:origin: robolectric/robolectric

public void resetScheduler() {
 ShadowMessageQueue shadowMessageQueue = shadowOf(realObject.getQueue());
 if (realObject == Looper.getMainLooper() || RoboSettings.isUseGlobalScheduler()) {
  shadowMessageQueue.setScheduler(RuntimeEnvironment.getMasterScheduler());
 } else {
  shadowMessageQueue.setScheduler(new Scheduler());
 }
}

代码示例来源:origin: robolectric/robolectric

@Test
 public void getSetMasterScheduler() {
  Scheduler s = new Scheduler();
  RuntimeEnvironment.setMasterScheduler(s);
  assertThat(RuntimeEnvironment.getMasterScheduler()).isSameAs(s);
 }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void getBackgroundThreadScheduler_shouldDifferFromRuntimeEnvironment_withAdvancedScheduling() {
 Scheduler s = new Scheduler();
 RuntimeEnvironment.setMasterScheduler(s);
 final ShadowApplication shadowApplication = Shadows.shadowOf(context);
 assertThat(shadowApplication.getBackgroundThreadScheduler()).isNotSameAs(s);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void getForegroundThreadScheduler_shouldMatchRuntimeEnvironment() {
 Scheduler s = new Scheduler();
 RuntimeEnvironment.setMasterScheduler(s);
 final ShadowApplication shadowApplication = Shadows.shadowOf(context);
 assertThat(shadowApplication.getForegroundThreadScheduler()).isSameAs(s);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void reset_setsGlobalScheduler_forMainLooper_byDefault() {
 ShadowLooper sMainLooper = ShadowLooper.getShadowMainLooper();
 Scheduler s = new Scheduler();
 RuntimeEnvironment.setMasterScheduler(s);
 sMainLooper.reset();
 assertThat(sMainLooper.getScheduler()).isSameAs(s);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void getBackgroundThreadScheduler_shouldDifferFromRuntimeEnvironment_byDefault() {
 Scheduler s = new Scheduler();
 RuntimeEnvironment.setMasterScheduler(s);
 final ShadowApplication shadowApplication = Shadows.shadowOf(context);
 assertThat(shadowApplication.getBackgroundThreadScheduler()).isNotSameAs(RuntimeEnvironment.getMasterScheduler());
}

代码示例来源:origin: robolectric/robolectric

@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);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testDifferentLoopersGetDifferentQueues() throws Exception {
 Looper looper1 = newLooper(true);
 ShadowLooper.pauseLooper(looper1);
 Looper looper2 = newLooper(true);
 ShadowLooper.pauseLooper(looper2);
 // Make sure looper has a different scheduler to the first
 shadowOf(looper2.getQueue()).setScheduler(new Scheduler());
 Handler handler1 = new Handler(looper1);
 handler1.post(new Say("first thing"));
 Handler handler2 = new Handler(looper2);
 handler2.post(new Say("second thing"));
 shadowOf(looper2).idle();
 assertThat(transcript).containsExactly("second thing");
}

代码示例来源:origin: robolectric/robolectric

@Test
public void reset_setsGlobalScheduler_forMainLooper_withAdvancedScheduling() {
 setAdvancedScheduling();
 ShadowLooper sMainLooper = ShadowLooper.getShadowMainLooper();
 Scheduler s = new Scheduler();
 RuntimeEnvironment.setMasterScheduler(s);
 sMainLooper.reset();
 assertThat(sMainLooper.getScheduler()).isSameAs(s);
}

代码示例来源:origin: robolectric/robolectric

RuntimeEnvironment.setActivityThread(null);
RuntimeEnvironment.setTempDirectory(new TempDirectory(createTestDataDirRootPath(method)));
RuntimeEnvironment.setMasterScheduler(new Scheduler());
RuntimeEnvironment.setMainThread(Thread.currentThread());

代码示例来源:origin: robolectric/robolectric

@Test
public void soStaticRefsToLoopersInAppWorksAcrossTests_shouldRetainSameLooperForMainThreadBetweenResetsButGiveItAFreshScheduler() throws Exception {
 Looper mainLooper = Looper.getMainLooper();
 Scheduler scheduler = shadowOf(mainLooper).getScheduler();
 shadowOf(mainLooper).quit = true;
 assertThat(ApplicationProvider.getApplicationContext().getMainLooper()).isSameAs(mainLooper);
 Scheduler s = new Scheduler();
 RuntimeEnvironment.setMasterScheduler(s);
 ShadowLooper.resetThreadLoopers();
 Application application = new Application();
 ReflectionHelpers.callInstanceMethod(
   application,
   "attach",
   ReflectionHelpers.ClassParameter.from(
     Context.class,
     ((Application) ApplicationProvider.getApplicationContext()).getBaseContext()));
 assertThat(Looper.getMainLooper()).named("Looper.getMainLooper()").isSameAs(mainLooper);
 assertThat(application.getMainLooper()).named("app.getMainLooper()").isSameAs(mainLooper);
 assertThat(shadowOf(mainLooper).getScheduler()).named("scheduler").isNotSameAs(scheduler);
 assertThat(shadowOf(mainLooper).getScheduler()).named("scheduler").isSameAs(s);
 assertThat(shadowOf(mainLooper).hasQuit()).named("quit").isFalse();
}

代码示例来源:origin: org.robolectric/robolectric

RuntimeEnvironment.setActivityThread(null);
RuntimeEnvironment.setTempDirectory(new TempDirectory(createTestDataDirRootPath(method)));
RuntimeEnvironment.setMasterScheduler(new Scheduler());
RuntimeEnvironment.setMainThread(Thread.currentThread());

代码示例来源:origin: org.robolectric/framework

public void resetScheduler() {
 ShadowMessageQueue sQueue = shadowOf(realObject.getQueue());
 if (realObject == Looper.getMainLooper() || RoboSettings.isUseGlobalScheduler()) {
  sQueue.setScheduler(RuntimeEnvironment.getMasterScheduler());
 } else {
  sQueue.setScheduler(new Scheduler());
 }
}

代码示例来源:origin: org.robolectric/shadows-framework

public void resetScheduler() {
 ShadowMessageQueue shadowMessageQueue = shadowOf(realObject.getQueue());
 if (realObject == Looper.getMainLooper() || RoboSettings.isUseGlobalScheduler()) {
  shadowMessageQueue.setScheduler(RuntimeEnvironment.getMasterScheduler());
 } else {
  shadowMessageQueue.setScheduler(new Scheduler());
 }
}

代码示例来源:origin: org.robolectric/shadows-core

public void resetScheduler() {
 ShadowMessageQueue sQueue = shadowOf(realObject.getQueue());
 if (this == getShadowMainLooper() || RoboSettings.isUseGlobalScheduler()) {
  sQueue.setScheduler(RuntimeEnvironment.getMasterScheduler());
 } else {
  sQueue.setScheduler(new Scheduler());
 }
}

代码示例来源:origin: org.robolectric/shadows-core-v23

public void resetScheduler() {
 ShadowMessageQueue sQueue = shadowOf(realObject.getQueue());
 if (this == getShadowMainLooper() || RoboSettings.isUseGlobalScheduler()) {
  sQueue.setScheduler(RuntimeEnvironment.getMasterScheduler());
 } else {
  sQueue.setScheduler(new Scheduler());
 }
}

相关文章