Browse Source

extract openDrawer test into AbstractIT
rebased

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>

tobiasKaminsky 5 years ago
parent
commit
778fec9e21

+ 1 - 17
src/androidTest/java/com/nextcloud/client/ActivitiesActivityIT.java

@@ -23,44 +23,28 @@
 package com.nextcloud.client;
 
 import android.Manifest;
-import android.app.Activity;
 
-import com.facebook.testing.screenshot.Screenshot;
 import com.owncloud.android.AbstractIT;
-import com.owncloud.android.R;
 import com.owncloud.android.ui.activities.ActivitiesActivity;
 
 import org.junit.Rule;
 import org.junit.Test;
 
-import androidx.test.espresso.contrib.DrawerActions;
 import androidx.test.espresso.intent.rule.IntentsTestRule;
 import androidx.test.rule.GrantPermissionRule;
 
-import static androidx.test.espresso.Espresso.onView;
-import static androidx.test.espresso.matcher.ViewMatchers.withId;
-
 
 public class ActivitiesActivityIT extends AbstractIT {
     @Rule public IntentsTestRule<ActivitiesActivity> activityRule = new IntentsTestRule<>(ActivitiesActivity.class,
                                                                                           true,
                                                                                           false);
 
-
     @Rule
     public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
         Manifest.permission.WRITE_EXTERNAL_STORAGE);
 
     @Test
     public void openDrawer() throws InterruptedException {
-        Activity sut = activityRule.launchActivity(null);
-
-        Thread.sleep(3000);
-
-        onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
-
-        waitForIdleSync();
-
-        Screenshot.snapActivity(sut).record();
+        super.openDrawer(activityRule);
     }
 }

+ 1 - 17
src/androidTest/java/com/nextcloud/client/NotificationsActivityIT.java

@@ -23,44 +23,28 @@
 package com.nextcloud.client;
 
 import android.Manifest;
-import android.app.Activity;
 
-import com.facebook.testing.screenshot.Screenshot;
 import com.owncloud.android.AbstractIT;
-import com.owncloud.android.R;
 import com.owncloud.android.ui.activity.NotificationsActivity;
 
 import org.junit.Rule;
 import org.junit.Test;
 
-import androidx.test.espresso.contrib.DrawerActions;
 import androidx.test.espresso.intent.rule.IntentsTestRule;
 import androidx.test.rule.GrantPermissionRule;
 
-import static androidx.test.espresso.Espresso.onView;
-import static androidx.test.espresso.matcher.ViewMatchers.withId;
-
 
 public class NotificationsActivityIT extends AbstractIT {
     @Rule public IntentsTestRule<NotificationsActivity> activityRule = new IntentsTestRule<>(NotificationsActivity.class,
                                                                                              true,
                                                                                              false);
 
-
     @Rule
     public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
         Manifest.permission.WRITE_EXTERNAL_STORAGE);
 
     @Test
     public void openDrawer() throws InterruptedException {
-        Activity sut = activityRule.launchActivity(null);
-
-        Thread.sleep(3000);
-
-        onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
-
-        waitForIdleSync();
-
-        Screenshot.snapActivity(sut).record();
+        super.openDrawer(activityRule);
     }
 }

+ 1 - 17
src/androidTest/java/com/nextcloud/client/SyncedFoldersActivityIT.java

@@ -23,44 +23,28 @@
 package com.nextcloud.client;
 
 import android.Manifest;
-import android.app.Activity;
 
-import com.facebook.testing.screenshot.Screenshot;
 import com.owncloud.android.AbstractIT;
-import com.owncloud.android.R;
 import com.owncloud.android.ui.activity.SyncedFoldersActivity;
 
 import org.junit.Rule;
 import org.junit.Test;
 
-import androidx.test.espresso.contrib.DrawerActions;
 import androidx.test.espresso.intent.rule.IntentsTestRule;
 import androidx.test.rule.GrantPermissionRule;
 
-import static androidx.test.espresso.Espresso.onView;
-import static androidx.test.espresso.matcher.ViewMatchers.withId;
-
 
 public class SyncedFoldersActivityIT extends AbstractIT {
     @Rule public IntentsTestRule<SyncedFoldersActivity> activityRule = new IntentsTestRule<>(SyncedFoldersActivity.class,
                                                                                              true,
                                                                                              false);
 
-
     @Rule
     public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
         Manifest.permission.WRITE_EXTERNAL_STORAGE);
 
     @Test
     public void openDrawer() throws InterruptedException {
-        Activity sut = activityRule.launchActivity(null);
-
-        Thread.sleep(3000);
-
-        onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
-
-        waitForIdleSync();
-
-        Screenshot.snapActivity(sut).record();
+        super.openDrawer(activityRule);
     }
 }

+ 1 - 17
src/androidTest/java/com/nextcloud/client/UploadListActivityActivityIT.java

@@ -23,44 +23,28 @@
 package com.nextcloud.client;
 
 import android.Manifest;
-import android.app.Activity;
 
-import com.facebook.testing.screenshot.Screenshot;
 import com.owncloud.android.AbstractIT;
-import com.owncloud.android.R;
 import com.owncloud.android.ui.activity.UploadListActivity;
 
 import org.junit.Rule;
 import org.junit.Test;
 
-import androidx.test.espresso.contrib.DrawerActions;
 import androidx.test.espresso.intent.rule.IntentsTestRule;
 import androidx.test.rule.GrantPermissionRule;
 
-import static androidx.test.espresso.Espresso.onView;
-import static androidx.test.espresso.matcher.ViewMatchers.withId;
-
 
 public class UploadListActivityActivityIT extends AbstractIT {
     @Rule public IntentsTestRule<UploadListActivity> activityRule = new IntentsTestRule<>(UploadListActivity.class,
                                                                                           true,
                                                                                           false);
 
-
     @Rule
     public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
         Manifest.permission.WRITE_EXTERNAL_STORAGE);
 
     @Test
     public void openDrawer() throws InterruptedException {
-        Activity sut = activityRule.launchActivity(null);
-
-        Thread.sleep(3000);
-
-        onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
-
-        waitForIdleSync();
-
-        Screenshot.snapActivity(sut).record();
+        super.openDrawer(activityRule);
     }
 }

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

@@ -4,11 +4,13 @@ import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.accounts.AuthenticatorException;
 import android.accounts.OperationCanceledException;
+import android.app.Activity;
 import android.content.ActivityNotFoundException;
 import android.content.Context;
 import android.net.Uri;
 import android.os.Bundle;
 
+import com.facebook.testing.screenshot.Screenshot;
 import com.nextcloud.client.account.UserAccountManager;
 import com.nextcloud.client.account.UserAccountManagerImpl;
 import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -29,10 +31,14 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
 
+import androidx.test.espresso.contrib.DrawerActions;
+import androidx.test.espresso.intent.rule.IntentsTestRule;
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 import androidx.test.platform.app.InstrumentationRegistry;
 
 import static androidx.test.InstrumentationRegistry.getInstrumentation;
+import static androidx.test.espresso.Espresso.onView;
+import static androidx.test.espresso.matcher.ViewMatchers.withId;
 
 
 /**
@@ -149,4 +155,16 @@ public abstract class AbstractIT {
     protected void waitForIdleSync() {
         InstrumentationRegistry.getInstrumentation().waitForIdleSync();
     }
+
+    protected void openDrawer(IntentsTestRule activityRule) throws InterruptedException {
+        Activity sut = activityRule.launchActivity(null);
+
+        Thread.sleep(3000);
+
+        onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
+
+        waitForIdleSync();
+
+        Screenshot.snapActivity(sut).record();
+    }
 }

+ 1 - 2
src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java

@@ -320,8 +320,7 @@ public class ExtendedListFragment extends Fragment implements
                     handler.post(() -> {
                         if (adapter instanceof OCFileListAdapter) {
                             EventBus.getDefault().post(new SearchEvent(query,
-                                                                       SearchRemoteOperation.SearchType.FILE_SEARCH,
-                                                                       SearchEvent.UnsetType.NO_UNSET));
+                                                                       SearchRemoteOperation.SearchType.FILE_SEARCH));
                         } else if (adapter instanceof LocalFileListAdapter) {
                             LocalFileListAdapter localFileListAdapter = (LocalFileListAdapter) adapter;
                             localFileListAdapter.filter(query);