From 27283f7ea8b4eea6b9420ee652c841db1a96a008 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Fri, 26 Apr 2019 10:56:52 -0700 Subject: Setting predition enabled/disabled state based on callbacks from the service > If no callback is received within a timeout, it is set to disabled Bug: 131188880 Change-Id: Ie6022b190a2504739f1569a500d6f5cc1566d373 --- .../android/quickstep/AppPredictionsUITests.java | 41 +++++++++------------- 1 file changed, 17 insertions(+), 24 deletions(-) (limited to 'quickstep/tests/src') diff --git a/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java b/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java index 72de80bfa..e6dbf875c 100644 --- a/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java +++ b/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java @@ -17,6 +17,7 @@ package com.android.quickstep; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import android.app.prediction.AppPredictor; import android.app.prediction.AppTarget; @@ -25,7 +26,6 @@ import android.content.ComponentName; import android.content.pm.LauncherActivityInfo; import android.os.Process; import android.view.View; -import android.widget.ProgressBar; import com.android.launcher3.BubbleTextView; import com.android.launcher3.Launcher; @@ -49,8 +49,7 @@ import androidx.test.runner.AndroidJUnit4; @LargeTest @RunWith(AndroidJUnit4.class) -public class AppPredictionsUITests extends AbstractQuickStepTest { - private static final String TAG = "AppPredictionsUITests"; +public class AppPredictionsUITests extends AbstractQuickStepTest { private LauncherActivityInfo mSampleApp1; private LauncherActivityInfo mSampleApp2; @@ -91,20 +90,15 @@ public class AppPredictionsUITests extends AbstractQuickStepTest { mActivityMonitor.startLauncher(); mLauncher.pressHome().switchToAllApps(); - // There has not been any update, verify that progress bar is showing - waitForLauncherCondition("Prediction is not in loading state", launcher -> { - ProgressBar p = findLoadingBar(launcher); - return p != null && p.isShown(); - }); - // Dispatch an update sendPredictionUpdate(mSampleApp1, mSampleApp2); + // The first update should apply immediately. waitForLauncherCondition("Predictions were not updated in loading state", launcher -> getPredictedApp(launcher).size() == 2); } /** - * Test tat prediction update is deferred if it is already visible + * Test that prediction update is deferred if it is already visible */ @Test @Ignore // b/131188880 @@ -124,6 +118,19 @@ public class AppPredictionsUITests extends AbstractQuickStepTest { assertEquals(3, getFromLauncher(this::getPredictedApp).size()); } + @Test + public void testPredictionsDisabled() { + mActivityMonitor.startLauncher(); + sendPredictionUpdate(); + mLauncher.pressHome().switchToAllApps(); + + waitForLauncherCondition("Predictions were not updated in loading state", + launcher -> launcher.getAppsView().getFloatingHeaderView() + .findFixedRowByType(PredictionRowView.class).getVisibility() == View.GONE); + assertFalse(PredictionUiStateManager.INSTANCE.get(mTargetContext) + .getCurrentState().isEnabled); + } + public ArrayList getPredictedApp(Launcher launcher) { PredictionRowView container = launcher.getAppsView().getFloatingHeaderView() .findFixedRowByType(PredictionRowView.class); @@ -138,20 +145,6 @@ public class AppPredictionsUITests extends AbstractQuickStepTest { return predictedAppViews; } - private ProgressBar findLoadingBar(Launcher launcher) { - PredictionRowView container = launcher.getAppsView().getFloatingHeaderView() - .findFixedRowByType(PredictionRowView.class); - - for (int i = 0; i < container.getChildCount(); i++) { - View view = container.getChildAt(i); - if (view instanceof ProgressBar) { - return (ProgressBar) view; - } - } - return null; - } - - private void sendPredictionUpdate(LauncherActivityInfo... activities) { getOnUiThread(() -> { List targets = new ArrayList<>(activities.length); -- cgit v1.2.3