From 2ba42ef94d5c9b01ed8f2c8b749b08972ebc21c6 Mon Sep 17 00:00:00 2001 From: Vadim Tryshev Date: Tue, 27 Jun 2023 22:12:45 +0000 Subject: [PATCH] Removing ViewCaptureAnalysisRule Bug: 286251603 Test: presubmit Flag: N/A Change-Id: I0123ed3892bbfd6d0e880141ace878b6204dbd81 --- .../quickstep/FallbackRecentsTest.java | 4 +- tests/Android.bp | 1 - .../launcher3/ui/AbstractLauncherUiTest.java | 4 +- .../util/rule/ViewCaptureAnalysisRule.java | 56 ------------------- .../launcher3/util/rule/ViewCaptureRule.kt | 2 +- 5 files changed, 3 insertions(+), 64 deletions(-) delete mode 100644 tests/src/com/android/launcher3/util/rule/ViewCaptureAnalysisRule.java diff --git a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java index 7492ab8c16..a67d787842 100644 --- a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java +++ b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java @@ -62,7 +62,6 @@ import com.android.launcher3.util.rule.FailureWatcher; import com.android.launcher3.util.rule.SamplerRule; import com.android.launcher3.util.rule.ScreenRecordRule; import com.android.launcher3.util.rule.TestStabilityRule; -import com.android.launcher3.util.rule.ViewCaptureAnalysisRule; import com.android.launcher3.util.rule.ViewCaptureRule; import com.android.quickstep.views.RecentsView; @@ -123,8 +122,7 @@ public class FallbackRecentsTest { .outerRule(new SamplerRule()) .around(new NavigationModeSwitchRule(mLauncher)) .around(new FailureWatcher(mLauncher, viewCaptureRule::getViewCaptureData)) - .around(viewCaptureRule) - .around(new ViewCaptureAnalysisRule(viewCaptureRule.getViewCapture())); + .around(viewCaptureRule); mOtherLauncherActivity = context.getPackageManager().queryIntentActivities( getHomeIntentInPackage(context), diff --git a/tests/Android.bp b/tests/Android.bp index d518a0ee53..e7f408487d 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -58,7 +58,6 @@ filegroup { "src/com/android/launcher3/util/rule/SimpleActivityRule.java", "src/com/android/launcher3/util/rule/TestStabilityRule.java", "src/com/android/launcher3/util/rule/TISBindRule.java", - "src/com/android/launcher3/util/rule/ViewCaptureAnalysisRule.java", "src/com/android/launcher3/testcomponent/BaseTestingActivity.java", "src/com/android/launcher3/testcomponent/OtherBaseTestingActivity.java", "src/com/android/launcher3/testcomponent/CustomShortcutConfigActivity.java", diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index 1262a26338..969b329fd4 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -69,7 +69,6 @@ import com.android.launcher3.util.rule.SamplerRule; import com.android.launcher3.util.rule.ScreenRecordRule; import com.android.launcher3.util.rule.ShellCommandRule; import com.android.launcher3.util.rule.TestStabilityRule; -import com.android.launcher3.util.rule.ViewCaptureAnalysisRule; import com.android.launcher3.util.rule.ViewCaptureRule; import org.junit.After; @@ -208,8 +207,7 @@ public abstract class AbstractLauncherUiTest { final RuleChain inner = RuleChain .outerRule(new PortraitLandscapeRunner(this)) .around(new FailureWatcher(mLauncher, viewCaptureRule::getViewCaptureData)) - .around(viewCaptureRule) - .around(new ViewCaptureAnalysisRule(viewCaptureRule.getViewCapture())); + .around(viewCaptureRule); return TestHelpers.isInLauncherProcess() ? RuleChain.outerRule(ShellCommandRule.setDefaultLauncher()).around(inner) diff --git a/tests/src/com/android/launcher3/util/rule/ViewCaptureAnalysisRule.java b/tests/src/com/android/launcher3/util/rule/ViewCaptureAnalysisRule.java deleted file mode 100644 index 702757f0e2..0000000000 --- a/tests/src/com/android/launcher3/util/rule/ViewCaptureAnalysisRule.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2023 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.util.rule; - -import androidx.annotation.NonNull; -import androidx.test.InstrumentationRegistry; - -import com.android.app.viewcapture.ViewCapture; -import com.android.app.viewcapture.data.ExportedData; - -import org.junit.rules.TestWatcher; -import org.junit.runner.Description; - -import java.util.concurrent.ExecutionException; - -/** - * After the test succeeds, the rule looks for anomalies in the data accumulated by ViewCapture - * that's passed as a parameter. If anomalies are detected, throws an exception and fails the test. - */ -public class ViewCaptureAnalysisRule extends TestWatcher { - @NonNull - private final ViewCapture mViewCapture; - - public ViewCaptureAnalysisRule(@NonNull ViewCapture viewCapture) { - mViewCapture = viewCapture; - } - - @Override - protected void succeeded(Description description) { - super.succeeded(description); - try { - analyzeViewCaptureData(mViewCapture.getExportedData( - InstrumentationRegistry.getTargetContext())); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } catch (ExecutionException e) { - throw new RuntimeException(e); - } - } - - private static void analyzeViewCaptureData(ExportedData viewCaptureData) { - } -} diff --git a/tests/src/com/android/launcher3/util/rule/ViewCaptureRule.kt b/tests/src/com/android/launcher3/util/rule/ViewCaptureRule.kt index 6c065026b4..8e2aea8ff0 100644 --- a/tests/src/com/android/launcher3/util/rule/ViewCaptureRule.kt +++ b/tests/src/com/android/launcher3/util/rule/ViewCaptureRule.kt @@ -36,7 +36,7 @@ import org.junit.runners.model.Statement * This rule will not work in OOP tests that don't have access to the activity under test. */ class ViewCaptureRule(var alreadyOpenActivitySupplier: Supplier) : TestRule { - val viewCapture = SimpleViewCapture("test-view-capture") + private val viewCapture = SimpleViewCapture("test-view-capture") var viewCaptureData: ExportedData? = null private set