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

Add UI tests

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

+ 44 - 0
src/androidTest/java/com/owncloud/android/ui/trashbin/TrashbinActivityIT.kt

@@ -21,8 +21,13 @@
  */
 package com.owncloud.android.ui.trashbin
 
+import android.accounts.Account
+import android.accounts.AccountManager
+import android.content.Intent
 import androidx.test.espresso.intent.rule.IntentsTestRule
 import com.owncloud.android.AbstractIT
+import com.owncloud.android.MainApp
+import com.owncloud.android.lib.common.accounts.AccountUtils
 import com.owncloud.android.utils.ScreenshotTest
 import org.junit.Rule
 import org.junit.Test
@@ -100,4 +105,43 @@ class TrashbinActivityIT : AbstractIT() {
 
         screenshot(sut)
     }
+
+    @Test
+    fun normalUser() {
+        val sut: TrashbinActivity = activityRule.launchActivity(null)
+
+        val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
+
+        sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
+
+        sut.runOnUiThread { sut.showUser() }
+
+        shortSleep()
+
+        screenshot(sut)
+    }
+
+    @Test
+    fun differentUser() {
+        val temp = Account("differentUser@https://server.com", MainApp.getAccountType(targetContext))
+
+        val platformAccountManager = AccountManager.get(targetContext)
+        platformAccountManager.addAccountExplicitly(temp, "password", null)
+        platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, "https://server.com")
+        platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, "differentUser")
+
+        val intent = Intent()
+        intent.putExtra(Intent.EXTRA_USER, "differentUser@https://server.com")
+        val sut: TrashbinActivity = activityRule.launchActivity(intent)
+
+        val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
+
+        sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
+
+        sut.runOnUiThread { sut.showUser() }
+
+        shortSleep()
+
+        screenshot(sut)
+    }
 }

+ 11 - 0
src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.java

@@ -285,6 +285,17 @@ public class TrashbinActivity extends DrawerActivity implements
         binding.list.setVisibility(View.GONE);
     }
 
+    @VisibleForTesting
+    public void showUser() {
+        binding.loadingContent.setVisibility(View.GONE);
+        binding.list.setVisibility(View.VISIBLE);
+        binding.swipeContainingList.setRefreshing(false);
+
+        binding.emptyList.emptyListViewText.setText(getUser().get().getAccountName());
+        binding.emptyList.emptyListViewText.setVisibility(View.VISIBLE);
+        binding.emptyList.emptyListView.setVisibility(View.VISIBLE);
+    }
+
     @Override
     public void showError(int message) {
         if (active) {