1 /* 2 * Copyright (C) 2018 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 18 package com.android.settings.panel; 19 20 import static com.android.settings.panel.SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME; 21 import static com.android.settings.panel.SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT; 22 import static com.android.settingslib.media.MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT; 23 24 import static com.google.common.truth.Truth.assertThat; 25 26 import android.content.Context; 27 import android.os.Bundle; 28 import android.provider.Settings; 29 30 import org.junit.Before; 31 import org.junit.Test; 32 import org.junit.runner.RunWith; 33 import org.robolectric.RobolectricTestRunner; 34 import org.robolectric.RuntimeEnvironment; 35 36 @RunWith(RobolectricTestRunner.class) 37 public class PanelFeatureProviderImplTest { 38 39 private static final String TEST_PACKAGENAME = "com.test.packagename"; 40 41 private Context mContext; 42 private PanelFeatureProviderImpl mProvider; 43 private Bundle mBundle; 44 45 @Before setUp()46 public void setUp() { 47 mContext = RuntimeEnvironment.application; 48 mProvider = new PanelFeatureProviderImpl(); 49 mBundle = new Bundle(); 50 mBundle.putString(KEY_MEDIA_PACKAGE_NAME, TEST_PACKAGENAME); 51 } 52 53 @Test getPanel_internetConnectivityKey_returnsCorrectPanel()54 public void getPanel_internetConnectivityKey_returnsCorrectPanel() { 55 mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, Settings.Panel.ACTION_INTERNET_CONNECTIVITY); 56 57 final PanelContent panel = mProvider.getPanel(mContext, mBundle); 58 59 assertThat(panel).isInstanceOf(InternetConnectivityPanel.class); 60 } 61 62 @Test getPanel_volume_returnsCorrectPanel()63 public void getPanel_volume_returnsCorrectPanel() { 64 mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, Settings.Panel.ACTION_VOLUME); 65 66 final PanelContent panel = mProvider.getPanel(mContext, mBundle); 67 68 assertThat(panel).isInstanceOf(VolumePanel.class); 69 } 70 71 @Test getPanel_mediaOutputKey_returnsCorrectPanel()72 public void getPanel_mediaOutputKey_returnsCorrectPanel() { 73 mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, ACTION_MEDIA_OUTPUT); 74 75 final PanelContent panel = mProvider.getPanel(mContext, mBundle); 76 77 assertThat(panel).isInstanceOf(MediaOutputPanel.class); 78 } 79 } 80