Set a value in Settings.Global to indicate if user is on audio sharing dashboard fragment
Change-Id: I081db5db644cdc42294063783c29a93914e12328 BUG: 394810407
This commit is contained in:
@@ -39,8 +39,10 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Settings;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -115,6 +117,41 @@ public class AudioSharingDashboardFragmentTest {
|
||||
assertThat(mFragment.getHelpResource()).isEqualTo(R.string.help_url_audio_sharing);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onResume_setAudioSharingDashboardSettingsGlobal_showAudioSharingDashboard() {
|
||||
mFragment = spy(new AudioSharingDashboardFragment());
|
||||
doReturn(mActivity).when(mFragment).getActivity();
|
||||
doReturn(mContext).when(mFragment).getContext();
|
||||
final PreferenceScreen screen = new PreferenceScreen(mContext, null /* attrs */);
|
||||
doReturn(screen).when(mFragment).getPreferenceScreen();
|
||||
mFragment.onAttach(mContext);
|
||||
mFragment.onResume();
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
assertThat(
|
||||
Settings.Global.getInt(
|
||||
mContext.getContentResolver(),
|
||||
AudioSharingDashboardFragment
|
||||
.IS_SHOWING_AUDIO_SHARING_DASHBOARD_KEY,
|
||||
-1))
|
||||
.isEqualTo(AudioSharingDashboardFragment.SHOWING_AUDIO_SHARING_DASHBOARD);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPause_setAudioSharingDashboardSettingsGlobal_notShowAudioSharingDashboard() {
|
||||
mFragment.onAttach(mContext);
|
||||
mFragment.onPause();
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
assertThat(
|
||||
Settings.Global.getInt(
|
||||
mContext.getContentResolver(),
|
||||
AudioSharingDashboardFragment
|
||||
.IS_SHOWING_AUDIO_SHARING_DASHBOARD_KEY,
|
||||
-1))
|
||||
.isEqualTo(AudioSharingDashboardFragment.NOT_SHOWING_AUDIO_SHARING_DASHBOARD);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onActivityCreated_showSwitchBar() {
|
||||
doReturn(mSwitchBar).when(mActivity).getSwitchBar();
|
||||
|
Reference in New Issue
Block a user