From d7007ef6e80fca1e7ea38b703a3a2fcc5e056f0a Mon Sep 17 00:00:00 2001 From: Uwais Ashraf Date: Wed, 12 Feb 2025 08:46:39 +0000 Subject: [PATCH] Destroy RecentsDependencies in tests that initialise it. This prevents unaccounted for destructions which can lead to a leak in tests after these. Bug: 395214062 Flag: com.android.launcher3.enable_refactor_task_thumbnail Test: TaplStartLauncherViaGestureTests.testStressPressHome Change-Id: I5cf9214ea9344f7e9d79b61e87269fd6e2c05753 --- .../task/thumbnail/TaskThumbnailViewScreenshotTest.kt | 6 ++++++ .../android/launcher3/model/data/TaskViewItemInfoTest.kt | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/quickstep/tests/multivalentScreenshotTests/src/com/android/quickstep/task/thumbnail/TaskThumbnailViewScreenshotTest.kt b/quickstep/tests/multivalentScreenshotTests/src/com/android/quickstep/task/thumbnail/TaskThumbnailViewScreenshotTest.kt index 232a08a321..c3b4d1581d 100644 --- a/quickstep/tests/multivalentScreenshotTests/src/com/android/quickstep/task/thumbnail/TaskThumbnailViewScreenshotTest.kt +++ b/quickstep/tests/multivalentScreenshotTests/src/com/android/quickstep/task/thumbnail/TaskThumbnailViewScreenshotTest.kt @@ -24,6 +24,7 @@ import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.BackgroundOnly import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.Uninitialized import com.android.quickstep.task.viewmodel.TaskThumbnailViewModel import com.google.android.apps.nexuslauncher.imagecomparison.goldenpathmanager.ViewScreenshotGoldenPathManager +import org.junit.After import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -47,6 +48,11 @@ class TaskThumbnailViewScreenshotTest(emulationSpec: DeviceEmulationSpec) { private val taskThumbnailViewModel = FakeTaskThumbnailViewModel() + @After + fun tearDown() { + RecentsDependencies.destroy() + } + @Test fun taskThumbnailView_uninitializedByDefault() { screenshotRule.screenshotTest("taskThumbnailView_uninitialized") { activity -> diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/model/data/TaskViewItemInfoTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/model/data/TaskViewItemInfoTest.kt index de0da645d3..adfbca567d 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/model/data/TaskViewItemInfoTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/model/data/TaskViewItemInfoTest.kt @@ -47,6 +47,7 @@ import com.android.systemui.shared.recents.model.Task.TaskKey import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component +import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -78,6 +79,11 @@ class TaskViewItemInfoTest { RecentsDependencies.initialize(context) } + @After + fun tearDown() { + RecentsDependencies.destroy() + } + @Test fun singleTask() { val taskContainers = listOf(createTaskContainer(createTask(1)))