public boolean setThemeFromManifest() { ShadowApplication shadowApplication = shadowOf(realActivity.getApplication()); AndroidManifest appManifest = shadowApplication.getAppManifest(); if (appManifest == null) return false; String themeRef = appManifest.getThemeRef(realActivity.getClass()); if (themeRef != null) { ResName style = ResName.qualifyResName(themeRef.replace("@", ""), appManifest.getPackageName(), "style"); Integer themeRes = shadowApplication.getResourceLoader().getResourceIndex().getResourceId(style); if (themeRes == null) throw new Resources.NotFoundException("no such theme " + style.getFullyQualifiedName()); realActivity.setTheme(themeRes); return true; } return false; }
@Implementation public void postInvalidateDelayed(long delayMilliseconds) { ShadowApplication.getInstance() .getForegroundThreadScheduler() .postDelayed( new Runnable() { @Override public void run() { realView.invalidate(); } }, delayMilliseconds); }
@Before public void setUp() throws Exception { context = new Application(); ShadowApplication.bind(context, new ResourceLoader(DEFAULT_SDK_VERSION, R.class, null, null)); root = new FrameLayout(context); child1 = new View(context); child2 = new View(context); child3 = new FrameLayout(context); child3a = new View(context); child3b = new View(context); root.addView(child1); root.addView(child2); root.addView(child3); child3.addView(child3a); child3.addView(child3b); defaultLineSeparator = System.getProperty("line.separator"); System.setProperty("line.separator", "\n"); }
/** Non-Android accessor that discards the most recent {@code PowerManager.WakeLock}s */ public static void reset() { ShadowApplication shadowApplication = Robolectric.getShadowApplication(); if (shadowApplication != null) { shadowApplication.clearWakeLocks(); } }
@Implementation public void postDelayed(Runnable action, long delayMills) { ShadowApplication.getInstance().getForegroundThreadScheduler().postDelayed(action, delayMills); }
@Implementation public void post(Runnable action) { ShadowApplication.getInstance().getForegroundThreadScheduler().post(action); }
public static void setLatestDialog(ShadowDialog latestDialog) { ShadowApplication shadowApplication = Robolectric.getShadowApplication(); if (shadowApplication != null) shadowApplication.setLatestDialog(latestDialog); }