Merge "Using a placeholder icon shape instead of low-res/blurry icon" into ub-launcher3-master
diff --git a/build.gradle b/build.gradle
index dcb5b81..7ac4127 100644
--- a/build.gradle
+++ b/build.gradle
@@ -24,7 +24,7 @@
versionCode 1
versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 20f7cdb..f3dec9a 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -995,10 +995,8 @@
mPendingAnimation = pendingAnimation;
mPendingAnimation.addEndListener((onEndListener) -> {
if (onEndListener.isSuccess) {
- int taskViewCount = getTaskViewCount();
- for (int i = 0; i < taskViewCount; i++) {
- removeTask(getTaskViewAt(i).getTask(), -1, onEndListener, false);
- }
+ // Remove all the task views now
+ ActivityManagerWrapper.getInstance().removeAllRecentTasks();
removeAllViews();
onAllTasksRemoved();
}
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 1c12464..74fc8d1 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -114,8 +114,9 @@
* Indicates if the device has a debug build. Should only be used to store additional info or
* add extra logging and not for changing the app behavior.
*/
- public static final boolean IS_DEBUG_DEVICE = Build.TYPE.toLowerCase().contains("debug")
- || Build.TYPE.toLowerCase().equals("eng");
+ public static final boolean IS_DEBUG_DEVICE =
+ Build.TYPE.toLowerCase(Locale.ROOT).contains("debug") ||
+ Build.TYPE.toLowerCase(Locale.ROOT).equals("eng");
// An intent extra to indicate the horizontal scroll of the wallpaper.
public static final String EXTRA_WALLPAPER_OFFSET = "com.android.launcher3.WALLPAPER_OFFSET";
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
index 709975f..f7c730a 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
@@ -244,7 +244,7 @@
float startX = (getWidth() - mNumPages * circleGap + mDotRadius) / 2;
float x = startX + mDotRadius;
- float y = canvas.getHeight() / 2;
+ float y = getHeight() / 2;
if (mEntryAnimationRadiusFactors != null) {
// During entry animation, only draw the circles
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index ec89f9c..0be5f11 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -28,7 +28,7 @@
<instrumentation
android:functionalTest="false"
android:handleProfiling="false"
- android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:name="androidx.test.runner.AndroidJUnitRunner"
android:targetPackage="com.android.launcher3" >
</instrumentation>
</manifest>
diff --git a/tests/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithmTest.java b/tests/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithmTest.java
index ab2adaa..afbedba 100644
--- a/tests/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithmTest.java
+++ b/tests/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithmTest.java
@@ -15,7 +15,12 @@
*/
package com.android.launcher3.allapps.search;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import android.content.ComponentName;
+
+import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.AppInfo;
@@ -24,12 +29,10 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
/**
* Unit tests for {@link DefaultAppSearchAlgorithm}
*/
+@SmallTest
@RunWith(AndroidJUnit4.class)
public class DefaultAppSearchAlgorithmTest {
private static final DefaultAppSearchAlgorithm.StringMatcher MATCHER =
diff --git a/tests/src/com/android/launcher3/model/AddWorkspaceItemsTaskTest.java b/tests/src/com/android/launcher3/model/AddWorkspaceItemsTaskTest.java
index dae8f2f..38e211b 100644
--- a/tests/src/com/android/launcher3/model/AddWorkspaceItemsTaskTest.java
+++ b/tests/src/com/android/launcher3/model/AddWorkspaceItemsTaskTest.java
@@ -1,5 +1,11 @@
package com.android.launcher3.model;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.verify;
+
import android.content.ComponentName;
import android.content.ContentProviderOperation;
import android.content.ContentValues;
@@ -7,9 +13,11 @@
import android.content.Intent;
import android.graphics.Rect;
import android.net.Uri;
-import androidx.test.runner.AndroidJUnit4;
import android.util.Pair;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherProvider;
import com.android.launcher3.LauncherSettings;
@@ -25,15 +33,10 @@
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.verify;
-
/**
* Tests for {@link AddWorkspaceItemsTask}
*/
+@SmallTest
@RunWith(AndroidJUnit4.class)
public class AddWorkspaceItemsTaskTest extends BaseModelUpdateTaskTestCase {
diff --git a/tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java b/tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java
index 59f807a..db80044 100644
--- a/tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java
+++ b/tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java
@@ -1,5 +1,12 @@
package com.android.launcher3.model;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+
+import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.AppInfo;
@@ -13,15 +20,10 @@
import java.util.Arrays;
import java.util.HashSet;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-
/**
* Tests for {@link CacheDataUpdatedTask}
*/
+@SmallTest
@RunWith(AndroidJUnit4.class)
public class CacheDataUpdatedTaskTest extends BaseModelUpdateTaskTestCase {
diff --git a/tests/src/com/android/launcher3/model/PackageInstallStateChangedTaskTest.java b/tests/src/com/android/launcher3/model/PackageInstallStateChangedTaskTest.java
index 51e21e2..435686f 100644
--- a/tests/src/com/android/launcher3/model/PackageInstallStateChangedTaskTest.java
+++ b/tests/src/com/android/launcher3/model/PackageInstallStateChangedTaskTest.java
@@ -1,5 +1,8 @@
package com.android.launcher3.model;
+import static org.junit.Assert.assertEquals;
+
+import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.ItemInfo;
@@ -15,11 +18,10 @@
import java.util.Arrays;
import java.util.HashSet;
-import static org.junit.Assert.assertEquals;
-
/**
* Tests for {@link PackageInstallStateChangedTask}
*/
+@SmallTest
@RunWith(AndroidJUnit4.class)
public class PackageInstallStateChangedTaskTest extends BaseModelUpdateTaskTestCase {
diff --git a/tests/src/com/android/launcher3/popup/PopupPopulatorTest.java b/tests/src/com/android/launcher3/popup/PopupPopulatorTest.java
index 6a1dc96..d224c89 100644
--- a/tests/src/com/android/launcher3/popup/PopupPopulatorTest.java
+++ b/tests/src/com/android/launcher3/popup/PopupPopulatorTest.java
@@ -16,7 +16,16 @@
package com.android.launcher3.popup;
+import static com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS;
+import static com.android.launcher3.popup.PopupPopulator.NUM_DYNAMIC;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import android.content.pm.ShortcutInfo;
+
+import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
@@ -28,15 +37,10 @@
import java.util.Collections;
import java.util.List;
-import static com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS;
-import static com.android.launcher3.popup.PopupPopulator.NUM_DYNAMIC;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
/**
* Tests the sorting and filtering of shortcuts in {@link PopupPopulator}.
*/
+@SmallTest
@RunWith(AndroidJUnit4.class)
public class PopupPopulatorTest {
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index 7e8890a..d450366 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -29,6 +29,9 @@
import android.os.Process;
import android.os.RemoteException;
import android.os.SystemClock;
+import android.util.Log;
+import android.view.MotionEvent;
+
import androidx.test.InstrumentationRegistry;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.BySelector;
@@ -36,8 +39,6 @@
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;
-import android.util.Log;
-import android.view.MotionEvent;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
@@ -90,7 +91,7 @@
@Before
public void setUp() throws Exception {
mDevice = UiDevice.getInstance(getInstrumentation());
- mLauncher = new LauncherInstrumentation(mDevice);
+ mLauncher = new LauncherInstrumentation(getInstrumentation());
mTargetContext = InstrumentationRegistry.getTargetContext();
mTargetPackage = mTargetContext.getPackageName();
}
@@ -140,7 +141,8 @@
// findObject can only execute after spring settles.
mDevice.wait(Until.findObject(condition), SHORT_UI_TIMEOUT);
UiObject2 widget = container.findObject(condition);
- if (widget != null) {
+ if (widget != null && widget.getVisibleBounds().intersects(
+ 0, 0, mDevice.getDisplayWidth(), mDevice.getDisplayHeight())) {
return widget;
}
} while (container.scroll(Direction.DOWN, 1f));
@@ -260,20 +262,28 @@
});
}
- // Cannot be used between a Tapl call injecting a gesture and a tapl call expecting the
- // results of that gesture because the wait can hide flakeness.
+ // Cannot be used in TaplTests between a Tapl call injecting a gesture and a tapl call expecting
+ // the results of that gesture because the wait can hide flakeness.
protected boolean waitForState(LauncherState state) {
return waitForLauncherCondition(launcher -> launcher.getStateManager().getState() == state);
}
- // Cannot be used after injecting any gesture using Tapl because this can hide flakiness.
+ // Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
+ // flakiness.
protected boolean waitForLauncherCondition(Function<Launcher, Boolean> condition) {
+ return waitForLauncherCondition(condition, DEFAULT_ACTIVITY_TIMEOUT);
+ }
+
+ // Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
+ // flakiness.
+ protected boolean waitForLauncherCondition(
+ Function<Launcher, Boolean> condition, long timeout) {
return Wait.atMost(new Condition() {
@Override
public boolean isTrue() {
return getFromLauncher(condition);
}
- }, DEFAULT_ACTIVITY_TIMEOUT);
+ }, timeout);
}
/**
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 74a91a4..09bf403 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -23,16 +23,19 @@
import static org.junit.Assert.fail;
import android.app.ActivityManager;
+import android.app.Instrumentation;
import android.app.UiAutomation;
import android.os.Bundle;
import android.provider.Settings;
-import androidx.test.InstrumentationRegistry;
+import android.view.accessibility.AccessibilityEvent;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;
-import android.view.accessibility.AccessibilityEvent;
import com.android.launcher3.TestProtocol;
import com.android.quickstep.SwipeUpSetting;
@@ -40,9 +43,6 @@
import java.lang.ref.WeakReference;
import java.util.concurrent.TimeoutException;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
/**
* The main tapl object. The only object that can be explicitly constructed by the using code. It
* produces all other objects.
@@ -90,17 +90,19 @@
private final UiDevice mDevice;
private final boolean mSwipeUpEnabled;
private Boolean mSwipeUpEnabledOverride = null;
+ private final Instrumentation mInstrumentation;
/**
* Constructs the root of TAPL hierarchy. You get all other objects from it.
*/
- public LauncherInstrumentation(UiDevice device) {
- mDevice = device;
+ public LauncherInstrumentation(Instrumentation instrumentation) {
+ mInstrumentation = instrumentation;
+ mDevice = UiDevice.getInstance(instrumentation);
final boolean swipeUpEnabledDefault =
!SwipeUpSetting.isSwipeUpSettingAvailable() ||
SwipeUpSetting.isSwipeUpEnabledDefaultValue();
mSwipeUpEnabled = Settings.Secure.getInt(
- InstrumentationRegistry.getTargetContext().getContentResolver(),
+ instrumentation.getTargetContext().getContentResolver(),
SWIPE_UP_SETTING_NAME,
swipeUpEnabledDefault ? 1 : 0) == 1;
assertTrue("Device must run in a test harness", ActivityManager.isRunningInTestHarness());
@@ -162,9 +164,8 @@
UiAutomation.AccessibilityEventFilter eventFilter, String message) {
try {
final AccessibilityEvent event =
- InstrumentationRegistry.getInstrumentation().getUiAutomation()
- .executeAndWaitForEvent(
- command, eventFilter, WAIT_TIME_MS);
+ mInstrumentation.getUiAutomation().executeAndWaitForEvent(
+ command, eventFilter, WAIT_TIME_MS);
assertNotNull("executeAndWaitForEvent returned null (this can't happen)", event);
return (Bundle) event.getParcelableData();
} catch (TimeoutException e) {