Merge "Moving sysproxy to kotlin" into main

This commit is contained in:
Treehugger Robot
2024-12-20 11:44:23 -08:00
committed by Android (Google) Code Review
6 changed files with 1296 additions and 1676 deletions
@@ -17,6 +17,7 @@
package com.android.launcher3.taskbar
import android.animation.AnimatorTestRule
import androidx.test.core.app.ApplicationProvider
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_DRAGGING
import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_IN_LAUNCHER
@@ -34,6 +35,10 @@ import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.anyOrNull
import org.mockito.kotlin.doAnswer
import org.mockito.kotlin.spy
import org.mockito.kotlin.whenever
@RunWith(LauncherMultivalentJUnit::class)
@EmulatedDevices(["pixelTablet2023"])
@@ -43,11 +48,10 @@ class TaskbarAutohideSuspendControllerTest {
val context =
TaskbarWindowSandboxContext.create { builder ->
builder.bindSystemUiProxy(
object : SystemUiProxy(this) {
override fun notifyTaskbarAutohideSuspend(suspend: Boolean) {
super.notifyTaskbarAutohideSuspend(suspend)
latestSuspendNotification = suspend
}
spy(SystemUiProxy(ApplicationProvider.getApplicationContext())) { proxy ->
doAnswer { latestSuspendNotification = it.getArgument(0) }
.whenever(proxy)
.notifyTaskbarAutohideSuspend(anyOrNull())
}
)
}
@@ -21,6 +21,7 @@ import android.content.ComponentName
import android.content.Intent
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.SetFlagsRule
import androidx.test.core.app.ApplicationProvider
import com.android.launcher3.Flags.FLAG_TASKBAR_OVERFLOW
import com.android.launcher3.R
import com.android.launcher3.taskbar.TaskbarControllerTestUtil.runOnMainSync
@@ -50,6 +51,10 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.anyOrNull
import org.mockito.kotlin.doAnswer
import org.mockito.kotlin.spy
import org.mockito.kotlin.whenever
@RunWith(LauncherMultivalentJUnit::class)
@EmulatedDevices(["pixelTablet2023"])
@@ -66,10 +71,10 @@ class TaskbarOverflowTest {
val context =
TaskbarWindowSandboxContext.create { builder ->
builder.bindSystemUiProxy(
object : SystemUiProxy(this) {
override fun setDesktopTaskListener(listener: IDesktopTaskListener?) {
desktopTaskListener = listener
}
spy(SystemUiProxy(ApplicationProvider.getApplicationContext())) { proxy ->
doAnswer { desktopTaskListener = it.getArgument(0) }
.whenever(proxy)
.setDesktopTaskListener(anyOrNull())
}
)
}
@@ -20,9 +20,9 @@ import android.animation.AnimatorTestRule
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.SetFlagsRule
import android.view.KeyEvent
import android.view.View.GONE
import android.view.View.VISIBLE
import androidx.test.core.app.ApplicationProvider
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController
import com.android.launcher3.taskbar.rules.TaskbarModeRule
@@ -44,6 +44,10 @@ import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.anyOrNull
import org.mockito.kotlin.doAnswer
import org.mockito.kotlin.spy
import org.mockito.kotlin.whenever
@RunWith(LauncherMultivalentJUnit::class)
@EmulatedDevices(["pixelTablet2023"])
@@ -53,11 +57,8 @@ class TaskbarScrimViewControllerTest {
val context =
TaskbarWindowSandboxContext.create { builder ->
builder.bindSystemUiProxy(
object : SystemUiProxy(this) {
override fun onBackEvent(backEvent: KeyEvent?) {
super.onBackEvent(backEvent)
backPressed = true
}
spy(SystemUiProxy(ApplicationProvider.getApplicationContext())) {
doAnswer { backPressed = true }.whenever(it).onBackEvent(anyOrNull())
}
)
}