mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 01:46:49 +00:00
Use SandboxContext in AbstractDeviceProfileTest
- Added a initializeForTesting method to SandboxContext - Also made SandboxContext non-abstract, so it can be used in tests to inject mock MainThreadInitializedObject into the SandboxContext, this should avoid mocked MainThreadInitializedObject bled into another test Test: presubmit Flag: None Bug: 303328913 Change-Id: I37157d81b08b80f1e90eacca7dc2ce482cd08aa4
This commit is contained in:
@@ -93,7 +93,7 @@ public class MainThreadInitializedObject<T> {
|
||||
* Abstract Context which allows custom implementations for
|
||||
* {@link MainThreadInitializedObject} providers
|
||||
*/
|
||||
public static abstract class SandboxContext extends ContextWrapper {
|
||||
public static class SandboxContext extends ContextWrapper {
|
||||
|
||||
private static final String TAG = "SandboxContext";
|
||||
|
||||
@@ -165,5 +165,14 @@ public class MainThreadInitializedObject<T> {
|
||||
protected <T> T createObject(MainThreadInitializedObject<T> object) {
|
||||
return object.mProvider.get(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a value into mObjectMap, can be used to put mocked MainThreadInitializedObject
|
||||
* instances into SandboxContext.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public <T> void putObject(MainThreadInitializedObject<T> object, T value) {
|
||||
mObjectMap.put(object, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user