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

Commit c2b94333 authored by Jernej Virag's avatar Jernej Virag
Browse files

Provide consistent testDispatcher for Kosmos injected Settings

We want to use the same dispatcher so calls like runCurrent and advanceUntilIdle on passed testScope actually execute correctly.
This also fixes some wrong type annotations around nullability - code that should return @NonNull values now correctly returns non-nullables and Java annotations were added.

Bug: 327558308
Flag: TEST_ONLY test only changes
Test: ran deviceless tests
Change-Id: I904370a968f526102061b21515858e80b1896d1a
parent d26385e0
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -38,6 +38,11 @@ public class FakeGlobalSettings implements GlobalSettings {

    public static final Uri CONTENT_URI = Uri.parse("content://settings/fake_global");

    /**
     * @deprecated Please use FakeGlobalSettings(testDispatcher) to provide the same dispatcher used
     * by main test scope.
     */
    @Deprecated
    public FakeGlobalSettings() {
        mDispatcher = StandardTestDispatcher(/* scheduler = */ null, /* name = */ null);
    }
+2 −1
Original line number Diff line number Diff line
@@ -18,5 +18,6 @@ package com.android.systemui.util.settings

import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.testDispatcher

val Kosmos.fakeGlobalSettings: FakeGlobalSettings by Fixture { FakeGlobalSettings() }
val Kosmos.fakeGlobalSettings: FakeGlobalSettings by Fixture { FakeGlobalSettings(testDispatcher) }
+5 −0
Original line number Diff line number Diff line
@@ -50,6 +50,11 @@ public class FakeSettings implements SecureSettings, SystemSettings {
    @UserIdInt
    private int mUserId = UserHandle.USER_CURRENT;

    /**
     * @deprecated Please use FakeSettings(testDispatcher) to provide the same dispatcher used
     * by main test scope.
     */
    @Deprecated
    public FakeSettings() {
        mDispatcher = StandardTestDispatcher(/* scheduler = */ null, /* name = */ null);
        mUserTracker = new FakeUserTracker();
+3 −1
Original line number Diff line number Diff line
@@ -18,5 +18,7 @@ package com.android.systemui.util.settings

import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.settings.fakeUserTracker

val Kosmos.fakeSettings: FakeSettings by Fixture { FakeSettings() }
val Kosmos.fakeSettings: FakeSettings by Fixture { FakeSettings(testDispatcher, fakeUserTracker) }