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

Commit d99a8ef4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Misc fixes"

parents 0fea51b3 43c85f5f
Loading
Loading
Loading
Loading

tests/robotests/OWNERS

0 → 100644
+2 −0
Original line number Diff line number Diff line
# We do not guard tests - everyone is welcomed to contribute to tests.
per-file *.java=*
 No newline at end of file
+12 −4
Original line number Diff line number Diff line
@@ -20,14 +20,11 @@ import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static android.app.NotificationManager.IMPORTANCE_LOW;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;

import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -50,8 +47,10 @@ import android.util.AttributeSet;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.TestConfig;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settingslib.RestrictedLockUtils;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -62,7 +61,9 @@ import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;

@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
        SettingsShadowResources.class
})
public class SoundPreferenceControllerTest {

    private Context mContext;
@@ -87,11 +88,18 @@ public class SoundPreferenceControllerTest {
        ShadowApplication shadowApplication = ShadowApplication.getInstance();
        shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
        shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
        SettingsShadowResources.overrideResource(com.android.internal.R.string.ringtone_silent,
                "silent");
        mContext = shadowApplication.getApplicationContext();
        mController = spy(new SoundPreferenceController(
                mContext, mFragment, mImportanceListener, mBackend));
    }

    @After
    public void tearDown() {
        SettingsShadowResources.reset();
    }

    @Test
    public void testNoCrashIfNoOnResume() throws Exception {
        mController.isAvailable();