summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
author Wenbo Jie <wenbojie@google.com> 2025-03-10 06:28:53 +0000
committer Wenbo Jie <wenbojie@google.com> 2025-03-13 03:13:54 +0000
commit165058c81c7d402cf6580e57f5efb7dd009e941d (patch)
tree9ac17c67b71deeb95b5174a4e10760566a83908a /tests
parent595ae7b5cb5550b63fa29d1a2e664e4ea8101ed2 (diff)
[DocsUI M3] Restyle drag drop badge for M3
* When there are multiple dragging files: * add an additional drag layer * add a file counter * Update drag show (radius/offset) to match the new M3 spec. * drag shadow view is an isolated view without the theme context, so M3 color attributes like "?attr/colorXXX" can't be used directly, instead, system color tokens are being used in light/dark mode. Since system color tokens are only available in SDK 31, fallback static colors are being used in the original colors.xml. Check the attached bug for demo. Bug: 377771158 Test: m DocumentsUIGoogle && manual inspection Flag: com.android.documentsui.flags.use_material3 Change-Id: Ia00bb0037a19813b4137d9d6cd7a42441b7f255e
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/com/android/documentsui/DragAndDropManagerTests.java39
1 files changed, 37 insertions, 2 deletions
diff --git a/tests/unit/com/android/documentsui/DragAndDropManagerTests.java b/tests/unit/com/android/documentsui/DragAndDropManagerTests.java
index d7a701f75..27b4074fd 100644
--- a/tests/unit/com/android/documentsui/DragAndDropManagerTests.java
+++ b/tests/unit/com/android/documentsui/DragAndDropManagerTests.java
@@ -26,17 +26,22 @@ import android.content.ClipData;
import android.content.ClipDescription;
import android.graphics.drawable.Drawable;
import android.os.PersistableBundle;
+import android.platform.test.annotations.RequiresFlagsDisabled;
+import android.platform.test.annotations.RequiresFlagsEnabled;
+import android.platform.test.flag.junit.CheckFlagsRule;
+import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.util.Pair;
import android.view.KeyEvent;
import android.view.View;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
import com.android.documentsui.DragAndDropManager.RuntimeDragAndDropManager;
import com.android.documentsui.DragAndDropManager.State;
import com.android.documentsui.base.DocumentStack;
import com.android.documentsui.base.RootInfo;
+import com.android.documentsui.flags.Flags;
import com.android.documentsui.services.FileOperationService;
import com.android.documentsui.services.FileOperations;
import com.android.documentsui.testing.ClipDatas;
@@ -52,6 +57,7 @@ import com.android.documentsui.testing.TestSelectionDetails;
import com.android.documentsui.testing.Views;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
@@ -93,6 +99,9 @@ public class DragAndDropManagerTests {
private DragAndDropManager mManager;
+ @Rule
+ public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
+
@Before
public void setUp() {
mEnv = TestEnv.create();
@@ -191,7 +200,8 @@ public class DragAndDropManagerTests {
}
@Test
- public void testStartDrag_BuildsCorrectShadow_MultipleDocs() {
+ @RequiresFlagsDisabled({Flags.FLAG_USE_MATERIAL3})
+ public void testStartDrag_BuildsCorrectShadow_MultipleDocs_M3Disabled() {
mManager.startDrag(
mStartDragView,
Arrays.asList(TestEnv.FILE_APK, TestEnv.FILE_JPG),
@@ -208,6 +218,24 @@ public class DragAndDropManagerTests {
}
@Test
+ @RequiresFlagsEnabled({Flags.FLAG_USE_MATERIAL3})
+ public void testStartDrag_BuildsCorrectShadow_MultipleDocs() {
+ mManager.startDrag(
+ mStartDragView,
+ Arrays.asList(TestEnv.FILE_APK, TestEnv.FILE_JPG),
+ TestProvidersAccess.HOME,
+ Arrays.asList(TestEnv.FOLDER_0.derivedUri, TestEnv.FILE_APK.derivedUri,
+ TestEnv.FILE_JPG.derivedUri),
+ mDetails,
+ mIconHelper,
+ TestEnv.FOLDER_0);
+
+ mShadowBuilder.title.assertLastArgument(TestEnv.FILE_APK.displayName);
+ mShadowBuilder.icon.assertLastArgument(mIconHelper.nextDocumentIcon);
+ mShadowBuilder.count.assertLastArgument(2);
+ }
+
+ @Test
public void testCanSpringOpen_ReturnsFalse_RootNotSupportCreate() {
mManager.startDrag(
mStartDragView,
@@ -860,6 +888,7 @@ public class DragAndDropManagerTests {
public TestEventListener<String> title;
public TestEventListener<Drawable> icon;
public TestEventListener<Integer> state;
+ public TestEventListener<Integer> count;
private TestDragShadowBuilder() {
super(null);
@@ -880,6 +909,11 @@ public class DragAndDropManagerTests {
this.state.accept(state);
}
+ @Override
+ void updateDragFileCount(int count) {
+ this.count.accept(count);
+ }
+
public static TestDragShadowBuilder create() {
TestDragShadowBuilder builder =
Mockito.mock(TestDragShadowBuilder.class, Mockito.CALLS_REAL_METHODS);
@@ -887,6 +921,7 @@ public class DragAndDropManagerTests {
builder.title = new TestEventListener<>();
builder.icon = new TestEventListener<>();
builder.state = new TestEventListener<>();
+ builder.count = new TestEventListener<>();
return builder;
}