1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.notification; 18 19 import static android.provider.Settings.Global.NOTIFICATION_BUBBLES; 20 21 import static com.android.settings.notification.BadgingNotificationPreferenceController.OFF; 22 import static com.android.settings.notification.BadgingNotificationPreferenceController.ON; 23 24 import static com.google.common.truth.Truth.assertThat; 25 26 import android.content.Context; 27 import android.provider.Settings; 28 29 import androidx.preference.Preference; 30 31 import com.android.settings.R; 32 33 import org.junit.Before; 34 import org.junit.Test; 35 import org.junit.runner.RunWith; 36 import org.robolectric.RobolectricTestRunner; 37 import org.robolectric.RuntimeEnvironment; 38 39 @RunWith(RobolectricTestRunner.class) 40 public class BubbleSummaryNotificationPreferenceControllerTest { 41 42 private Context mContext; 43 44 private BubbleSummaryNotificationPreferenceController mController; 45 private Preference mPreference; 46 47 private static final String KEY_NOTIFICATION_BUBBLES = "notification_bubbles"; 48 49 @Before setUp()50 public void setUp() { 51 mContext = RuntimeEnvironment.application; 52 mController = new BubbleSummaryNotificationPreferenceController(mContext, 53 KEY_NOTIFICATION_BUBBLES); 54 mPreference = new Preference(RuntimeEnvironment.application); 55 } 56 57 @Test getSummary_NOTIFICATION_BUBBLESIsOff_returnOffString()58 public void getSummary_NOTIFICATION_BUBBLESIsOff_returnOffString() { 59 Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF); 60 61 assertThat(mController.getSummary()).isEqualTo("Off"); 62 } 63 64 @Test getSummary_NOTIFICATION_BUBBLESIsOff_returnOnString()65 public void getSummary_NOTIFICATION_BUBBLESIsOff_returnOnString() { 66 Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON); 67 68 String onString = mContext.getString(R.string.notifications_bubble_setting_on_summary); 69 assertThat(mController.getSummary()).isEqualTo(onString); 70 } 71 } 72