/* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.taskbar.rules import com.android.launcher3.InvariantDeviceProfile import com.android.launcher3.taskbar.rules.TaskbarModeRule.Mode.PINNED import com.android.launcher3.taskbar.rules.TaskbarModeRule.Mode.THREE_BUTTONS import com.android.launcher3.taskbar.rules.TaskbarModeRule.Mode.TRANSIENT import com.android.launcher3.taskbar.rules.TaskbarModeRule.TaskbarMode import com.android.launcher3.util.DisplayController import com.android.launcher3.util.LauncherMultivalentJUnit import com.android.launcher3.util.LauncherMultivalentJUnit.EmulatedDevices import com.android.launcher3.util.NavigationMode import com.android.launcher3.util.TaskbarModeUtil import com.google.common.truth.Truth.assertThat import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @RunWith(LauncherMultivalentJUnit::class) @EmulatedDevices(["pixelFoldable2023", "pixelTablet2023"]) class TaskbarModeRuleTest { @get:Rule(order = 0) val context = TaskbarWindowSandboxContext.create() @get:Rule(order = 1) val taskbarModeRule = TaskbarModeRule(context) @Test @TaskbarMode(TRANSIENT) fun testTaskbarMode_transient_overridesTaskbarUtil() { assertThat(TaskbarModeUtil.INSTANCE.get(context).isTransient).isTrue() assertThat(TaskbarModeUtil.INSTANCE.get(context).isPinned).isFalse() assertThat(DisplayController.getNavigationMode(context)).isEqualTo(NavigationMode.NO_BUTTON) } @Test @TaskbarMode(TRANSIENT) fun testTaskbarMode_transient_overridesDeviceProfile() { val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context) assertThat(dp.taskbarProfile.isTransientTaskbar).isTrue() assertThat(dp.deviceProperties.isGestureMode).isTrue() } @Test @TaskbarMode(PINNED) fun testTaskbarMode_pinned_overridesTaskbarUtil() { assertThat(TaskbarModeUtil.INSTANCE.get(context).isTransient).isFalse() assertThat(TaskbarModeUtil.INSTANCE.get(context).isPinned).isTrue() assertThat(DisplayController.getNavigationMode(context)).isEqualTo(NavigationMode.NO_BUTTON) } @Test @TaskbarMode(PINNED) fun testTaskbarMode_pinned_overridesDeviceProfile() { val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context) assertThat(dp.taskbarProfile.isTransientTaskbar).isFalse() assertThat(dp.deviceProperties.isGestureMode).isTrue() } @Test @TaskbarMode(THREE_BUTTONS) fun testTaskbarMode_threeButtons_overridesTaskbarUtil() { assertThat(TaskbarModeUtil.INSTANCE.get(context).isTransient).isFalse() assertThat(TaskbarModeUtil.INSTANCE.get(context).isPinned).isFalse() assertThat(DisplayController.getNavigationMode(context)) .isEqualTo(NavigationMode.THREE_BUTTONS) } @Test @TaskbarMode(THREE_BUTTONS) fun testTaskbarMode_threeButtons_overridesDeviceProfile() { val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context) assertThat(dp.taskbarProfile.isTransientTaskbar).isFalse() assertThat(dp.deviceProperties.isGestureMode).isFalse() } }