use of org.robolectric.annotation.Resetter in project robolectric by robolectric.
the class ShadowBackgroundThread method reset.
@Resetter
public static void reset() {
_BackgroundThread_ _backgroundThreadStatic_ = reflector(_BackgroundThread_.class);
BackgroundThread instance = _backgroundThreadStatic_.getInstance();
if (instance != null) {
instance.quit();
_backgroundThreadStatic_.setInstance(null);
_backgroundThreadStatic_.setHandler(null);
}
}
use of org.robolectric.annotation.Resetter in project robolectric by robolectric.
the class ShadowDeviceConfig method reset.
@Resetter
public static void reset() {
Object lock = ReflectionHelpers.getStaticField(DeviceConfig.class, "sLock");
// noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (lock) {
if (RuntimeEnvironment.getApiLevel() == Build.VERSION_CODES.Q) {
Map singleListeners = ReflectionHelpers.getStaticField(DeviceConfig.class, "sSingleListeners");
singleListeners.clear();
}
Map listeners = ReflectionHelpers.getStaticField(DeviceConfig.class, "sListeners");
listeners.clear();
Map namespaces = ReflectionHelpers.getStaticField(DeviceConfig.class, "sNamespaces");
namespaces.clear();
}
}
use of org.robolectric.annotation.Resetter in project robolectric by robolectric.
the class ShadowFontBuilder method reset.
@Resetter
public static void reset() {
for (Map.Entry<Long, FontInternal> entry : resettableByteBuffers.entrySet()) {
FontInternal fontInternal = entry.getValue();
if (fontInternal == null || fontInternal.buffer == null) {
continue;
}
ByteBuffer buffer = fontInternal.buffer;
buffer.rewind();
buffer.clear();
}
resettableByteBuffers.clear();
}
use of org.robolectric.annotation.Resetter in project robolectric by robolectric.
the class ShadowLegacyLooper method resetThreadLoopers.
@Resetter
public static synchronized void resetThreadLoopers() {
// do not use looperMode() here, because its cached value might already have been reset
if (ConfigurationRegistry.get(LooperMode.Mode.class) == LooperMode.Mode.PAUSED) {
// ignore if realistic looper
return;
}
// from being garbage collected.
if (!isMainThread()) {
throw new IllegalStateException("you should only be calling this from the main thread!");
}
synchronized (loopingLoopers) {
for (Looper looper : loopingLoopers.values()) {
synchronized (looper) {
if (!shadowOf(looper).quit) {
looper.quit();
} else {
// Reset the schedulers of all loopers. This prevents un-run tasks queued up in static
// background handlers from leaking to subsequent tests.
shadowOf(looper).getScheduler().reset();
shadowOf(looper.getQueue()).reset();
}
}
}
}
// prepareMainLooper() is called, this might be null on that occasion.
if (mainLooper != null) {
shadowOf(mainLooper).reset();
}
}
use of org.robolectric.annotation.Resetter in project robolectric by robolectric.
the class ShadowPausedLooper method resetLoopers.
@Resetter
public static synchronized void resetLoopers() {
// do not use looperMode() here, because its cached value might already have been reset
if (ConfigurationRegistry.get(LooperMode.Mode.class) != LooperMode.Mode.PAUSED) {
// ignore if not realistic looper
return;
}
Collection<Looper> loopersCopy = new ArrayList(loopingLoopers);
for (Looper looper : loopersCopy) {
ShadowPausedMessageQueue shadowQueue = Shadow.extract(looper.getQueue());
shadowQueue.reset();
}
}
Aggregations