Эх сурвалжийг харах

Enable accessibility scanner: https://developer.android.com/guide/topics/ui/accessibility/testing#espresso-enable-checks

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 4 жил өмнө
parent
commit
69256d0c53

+ 1 - 0
build.gradle

@@ -382,6 +382,7 @@ dependencies {
     androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
     androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
     androidTestImplementation "androidx.test.espresso:espresso-web:$espressoVersion"
+    androidTestImplementation "androidx.test.espresso:espresso-accessibility:$espressoVersion"
 
     // Mocking support
     androidTestImplementation 'com.github.tmurakami:dexopener:2.0.5' // required to allow mocking on API 27 and older

+ 20 - 0
src/androidTest/java/com/nextcloud/client/FileDisplayActivityIT.java

@@ -43,12 +43,14 @@ import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
 
+import androidx.test.espresso.Espresso;
 import androidx.test.espresso.contrib.DrawerActions;
 import androidx.test.espresso.contrib.NavigationViewActions;
 import androidx.test.espresso.intent.rule.IntentsTestRule;
 import androidx.test.rule.GrantPermissionRule;
 
 import static androidx.test.espresso.Espresso.onView;
+import static androidx.test.espresso.action.ViewActions.click;
 import static androidx.test.espresso.matcher.ViewMatchers.withId;
 import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
 import static junit.framework.TestCase.assertEquals;
@@ -155,4 +157,22 @@ public class FileDisplayActivityIT extends AbstractOnServerIT {
         shortSleep();
         assertEquals(getStorageManager().getFileByPath("/"), sut.getCurrentDir());
     }
+
+    @Test
+    public void switchToGridView() {
+        activityRule.launchActivity(null);
+
+        assertTrue(new CreateFolderOperation("/test/", user, targetContext)
+                       .execute(client, getStorageManager())
+                       .isSuccess());
+
+        Espresso.onView(withId(R.id.switch_grid_view_button)).perform(click());
+    }
+
+    @Test
+    public void openAccountSwitcher() {
+        activityRule.launchActivity(null);
+
+        Espresso.onView(withId(R.id.switch_account_button)).perform(click());
+    }
 }

+ 6 - 0
src/androidTest/java/com/owncloud/android/AbstractIT.java

@@ -41,6 +41,7 @@ import com.owncloud.android.utils.FileStorageUtils;
 import junit.framework.TestCase;
 
 import org.apache.commons.io.FileUtils;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 
@@ -185,6 +186,11 @@ public abstract class AbstractIT {
         }
     }
 
+    @Before
+    public void enableAccessibilityChecks() {
+        androidx.test.espresso.accessibility.AccessibilityChecks.enable().setRunChecksFromRootView(true);
+    }
+
     protected FileDataStorageManager getStorageManager() {
         return fileDataStorageManager;
     }

+ 1 - 1
src/main/res/layout/account_item.xml

@@ -123,7 +123,7 @@
 
         <ImageView
             android:id="@+id/account_menu"
-            android:layout_width="wrap_content"
+            android:layout_width="@dimen/minimum_size_for_touchable_area"
             android:layout_height="match_parent"
             android:layout_alignParentEnd="true"
             android:layout_centerVertical="true"

+ 1 - 0
src/main/res/layout/first_run_activity.xml

@@ -97,6 +97,7 @@
             android:id="@+id/host_own_server"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:minHeight="@dimen/minimum_size_for_touchable_area"
             android:layout_marginBottom="10dp"
             android:layout_marginTop="10dp"
             android:gravity="center_horizontal"

+ 5 - 5
src/main/res/layout/list_item.xml

@@ -160,14 +160,14 @@
 
         <ImageView
             android:id="@+id/sharedIcon"
-            android:layout_width="wrap_content"
+            android:layout_width="48dp"
             android:layout_height="match_parent"
             android:layout_centerVertical="true"
             android:layout_toEndOf="@id/unreadComments"
             android:clickable="true"
             android:contentDescription="@string/shared_icon_share"
             android:focusable="true"
-            android:paddingStart="@dimen/standard_half_padding"
+            android:paddingStart="@dimen/list_item_share_right_margin"
             android:paddingEnd="@dimen/list_item_share_right_margin"
             android:src="@drawable/ic_unshared" />
 
@@ -196,15 +196,15 @@
 
         <ImageView
             android:id="@+id/overflow_menu"
-            android:layout_width="wrap_content"
+            android:layout_width="48dp"
             android:layout_height="match_parent"
             android:layout_centerVertical="true"
             android:layout_toEndOf="@id/custom_checkbox"
             android:clickable="true"
             android:contentDescription="@string/overflow_menu"
             android:focusable="true"
-            android:paddingStart="@dimen/standard_half_padding"
-            android:paddingEnd="@dimen/alternate_padding"
+            android:paddingStart="12dp"
+            android:paddingEnd="12dp"
             android:src="@drawable/ic_dots_vertical" />
 
     </RelativeLayout>

+ 8 - 8
src/main/res/layout/toolbar_standard.xml

@@ -67,8 +67,8 @@
             <com.google.android.material.button.MaterialButton
                 android:id="@+id/switch_grid_view_button"
                 style="@style/Widget.AppTheme.Button.IconButton"
-                android:layout_width="38dp"
-                android:layout_height="38dp"
+                android:layout_width="48dp"
+                android:layout_height="48dp"
                 android:layout_marginEnd="4dp"
                 android:contentDescription="@string/action_switch_grid_view"
                 app:cornerRadius="24dp"
@@ -147,8 +147,8 @@
                 <com.google.android.material.button.MaterialButton
                     android:id="@+id/menu_button"
                     style="@style/Widget.AppTheme.Button.IconButton"
-                    android:layout_width="38dp"
-                    android:layout_height="38dp"
+                    android:layout_width="48dp"
+                    android:layout_height="48dp"
                     android:layout_marginStart="8dp"
                     android:contentDescription="@string/action_switch_grid_view"
                     app:cornerRadius="@dimen/button_corner_radius"
@@ -161,11 +161,11 @@
                 <com.google.android.material.textview.MaterialTextView
                     android:id="@+id/search_text"
                     android:layout_width="0dp"
-                    android:layout_height="wrap_content"
+                    android:layout_height="48dp"
                     android:layout_marginStart="18dp"
                     android:layout_marginEnd="18dp"
                     android:ellipsize="end"
-                    android:gravity="start"
+                    android:gravity="start|center_vertical"
                     android:lines="1"
                     android:textColor="@color/fontSecondaryAppbar"
                     android:textSize="16sp"
@@ -178,8 +178,8 @@
                 <com.google.android.material.button.MaterialButton
                     android:id="@+id/switch_account_button"
                     style="@style/Widget.AppTheme.Button.IconButton"
-                    android:layout_width="42dp"
-                    android:layout_height="42dp"
+                    android:layout_width="48dp"
+                    android:layout_height="48dp"
                     android:layout_marginEnd="6dp"
                     app:cornerRadius="@dimen/button_corner_radius"
                     app:iconSize="30dp"

+ 1 - 0
src/main/res/values/dims.xml

@@ -139,4 +139,5 @@
     <dimen name="account_action_button_height">50dp</dimen>
     <dimen name="account_action_button_vertical_margin">10dp</dimen>
     <dimen name="online_status_item_height">52dp</dimen>
+    <dimen name="minimum_size_for_touchable_area">48dp</dimen>
 </resources>