Merge "DO NOT MERGE Fix subclass/superclass check for NotificationPanelViewMediator." into rvc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a1a12910b7
@@ -239,14 +239,14 @@ public class SystemBarConfigs {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mTopNavBarEnabled && notificationPanelMediatorUsed.isAssignableFrom(
|
if (!mTopNavBarEnabled && TopNotificationPanelViewMediator.class.isAssignableFrom(
|
||||||
TopNotificationPanelViewMediator.class)) {
|
notificationPanelMediatorUsed)) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"Top System Bar must be enabled to use " + notificationPanelMediatorName);
|
"Top System Bar must be enabled to use " + notificationPanelMediatorName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mBottomNavBarEnabled && notificationPanelMediatorUsed.isAssignableFrom(
|
if (!mBottomNavBarEnabled && BottomNotificationPanelViewMediator.class.isAssignableFrom(
|
||||||
BottomNotificationPanelViewMediator.class)) {
|
notificationPanelMediatorUsed)) {
|
||||||
throw new RuntimeException("Bottom System Bar must be enabled to use "
|
throw new RuntimeException("Bottom System Bar must be enabled to use "
|
||||||
+ notificationPanelMediatorName);
|
+ notificationPanelMediatorName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,14 @@ import androidx.test.filters.SmallTest;
|
|||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
|
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||||
|
import com.android.systemui.car.CarDeviceProvisionedController;
|
||||||
import com.android.systemui.car.CarSystemUiTest;
|
import com.android.systemui.car.CarSystemUiTest;
|
||||||
|
import com.android.systemui.car.notification.NotificationPanelViewController;
|
||||||
|
import com.android.systemui.car.notification.NotificationPanelViewMediator;
|
||||||
|
import com.android.systemui.car.notification.PowerManagerHelper;
|
||||||
|
import com.android.systemui.car.notification.TopNotificationPanelViewMediator;
|
||||||
|
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -92,6 +99,33 @@ public class SystemBarConfigsTest extends SysuiTestCase {
|
|||||||
mSystemBarConfigs = new SystemBarConfigs(mResources);
|
mSystemBarConfigs = new SystemBarConfigs(mResources);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onInit_topNotifPanelViewMediatorUsed_topBarEnabled_doesNotThrowException() {
|
||||||
|
when(mResources.getBoolean(R.bool.config_enableTopNavigationBar)).thenReturn(true);
|
||||||
|
when(mResources.getString(R.string.config_notificationPanelViewMediator)).thenReturn(
|
||||||
|
TestTopNotificationPanelViewMediator.class.getName());
|
||||||
|
|
||||||
|
mSystemBarConfigs = new SystemBarConfigs(mResources);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = RuntimeException.class)
|
||||||
|
public void onInit_topNotifPanelViewMediatorUsed_topBarNotEnabled_throwsRuntimeException() {
|
||||||
|
when(mResources.getBoolean(R.bool.config_enableTopNavigationBar)).thenReturn(false);
|
||||||
|
when(mResources.getString(R.string.config_notificationPanelViewMediator)).thenReturn(
|
||||||
|
TestTopNotificationPanelViewMediator.class.getName());
|
||||||
|
|
||||||
|
mSystemBarConfigs = new SystemBarConfigs(mResources);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onInit_notificationPanelViewMediatorUsed_topBarNotEnabled_doesNotThrowException() {
|
||||||
|
when(mResources.getBoolean(R.bool.config_enableTopNavigationBar)).thenReturn(false);
|
||||||
|
when(mResources.getString(R.string.config_notificationPanelViewMediator)).thenReturn(
|
||||||
|
NotificationPanelViewMediator.class.getName());
|
||||||
|
|
||||||
|
mSystemBarConfigs = new SystemBarConfigs(mResources);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getTopSystemBarLayoutParams_topBarEnabled_returnsTopSystemBarLayoutParams() {
|
public void getTopSystemBarLayoutParams_topBarEnabled_returnsTopSystemBarLayoutParams() {
|
||||||
mSystemBarConfigs = new SystemBarConfigs(mResources);
|
mSystemBarConfigs = new SystemBarConfigs(mResources);
|
||||||
@@ -159,4 +193,20 @@ public class SystemBarConfigsTest extends SysuiTestCase {
|
|||||||
when(mResources.getInteger(R.integer.config_leftSystemBarZOrder)).thenReturn(2);
|
when(mResources.getInteger(R.integer.config_leftSystemBarZOrder)).thenReturn(2);
|
||||||
when(mResources.getInteger(R.integer.config_rightSystemBarZOrder)).thenReturn(3);
|
when(mResources.getInteger(R.integer.config_rightSystemBarZOrder)).thenReturn(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Intentionally using a subclass of TopNotificationPanelViewMediator for testing purposes to
|
||||||
|
// ensure that OEM's will be able to implement and use their own NotificationPanelViewMediator.
|
||||||
|
private class TestTopNotificationPanelViewMediator extends
|
||||||
|
TopNotificationPanelViewMediator {
|
||||||
|
TestTopNotificationPanelViewMediator(
|
||||||
|
CarNavigationBarController carNavigationBarController,
|
||||||
|
NotificationPanelViewController notificationPanelViewController,
|
||||||
|
PowerManagerHelper powerManagerHelper,
|
||||||
|
BroadcastDispatcher broadcastDispatcher,
|
||||||
|
CarDeviceProvisionedController carDeviceProvisionedController,
|
||||||
|
ConfigurationController configurationController) {
|
||||||
|
super(carNavigationBarController, notificationPanelViewController, powerManagerHelper,
|
||||||
|
broadcastDispatcher, carDeviceProvisionedController, configurationController);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user