1 /* 2 * Copyright (C) 2022 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 package com.android.systemui.shared.rotation 17 18 import android.testing.TestableLooper.RunWithLooper 19 import android.view.Display 20 import android.view.WindowInsetsController 21 import android.view.WindowManagerPolicyConstants 22 import androidx.test.ext.junit.runners.AndroidJUnit4 23 import androidx.test.filters.SmallTest 24 import com.android.systemui.SysuiTestCase 25 import com.google.common.truth.Truth.assertThat 26 import org.junit.Before 27 import org.junit.Test 28 import org.junit.runner.RunWith 29 30 @RunWith(AndroidJUnit4::class) 31 @SmallTest 32 @RunWithLooper 33 class RotationButtonControllerTest : SysuiTestCase() { 34 35 private lateinit var mController: RotationButtonController 36 37 @Before setUpnull38 fun setUp() { 39 mController = RotationButtonController( 40 mContext, 41 /* lightIconColor = */ 0, 42 /* darkIconColor = */ 0, 43 /* iconCcwStart0ResId = */ 0, 44 /* iconCcwStart90ResId = */ 0, 45 /* iconCwStart0ResId = */ 0, 46 /* iconCwStart90ResId = */ 0 47 ) { 0 } 48 } 49 50 @Test ifGestural_showRotationSuggestionnull51 fun ifGestural_showRotationSuggestion() { 52 mController.onNavigationBarWindowVisibilityChange( /* showing = */ false) 53 mController.onBehaviorChanged(Display.DEFAULT_DISPLAY, 54 WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE) 55 mController.onNavigationModeChanged(WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON) 56 mController.onTaskbarStateChange( /* visible = */ false, /* stashed = */ false) 57 assertThat(mController.canShowRotationButton()).isFalse() 58 59 mController.onNavigationModeChanged(WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL) 60 61 assertThat(mController.canShowRotationButton()).isTrue() 62 } 63 } 64