[flexiglass] DataStoreWrapper
A reusable utility to create wrapper objects of Jetpack DataStore in a way that they can be used in unit tests. DataStore creates files and basically forces developers to rely on on-device, instrumented tests only. This wrapper fixes it by skipping the file creation part, allowing everyone to use DataStore and have it supported in deviceless tests. The problem is that there's no way to implement a fake that depends on the actual DataStore type because its APIs (Preferences and Preferences.Key) have internal constructors and use type inference to know what value should be associated with each key. By using a Map to avoid Preferences, we circumvent the former problem. By limiting the wrapper to String values, we circumvent the latter problem. This is used in the next CL. Bug: 406213664 Test: tested in the next CL Flag: com.android.systemui.scene_container Change-Id: I7725f861c5c06dd6ccd028e4703363bc1505866b
Loading
Please register or sign in to comment