Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit edf33ae6 authored by Ale Nijamkin's avatar Ale Nijamkin
Browse files

[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
parent c04b1027
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment