浏览代码

add test

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 2 年之前
父节点
当前提交
2574ee288b
共有 1 个文件被更改,包括 22 次插入0 次删除
  1. 22 0
      app/src/androidTest/java/com/nextcloud/client/account/UserAccountManagerImplTest.java

+ 22 - 0
app/src/androidTest/java/com/nextcloud/client/account/UserAccountManagerImplTest.java

@@ -7,6 +7,7 @@ import android.os.Bundle;
 import com.nextcloud.client.preferences.AppPreferences;
 import com.nextcloud.client.preferences.AppPreferencesImpl;
 import com.owncloud.android.AbstractOnServerIT;
+import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.lib.common.accounts.AccountUtils;
 
 import org.junit.Before;
@@ -48,4 +49,25 @@ public class UserAccountManagerImplTest extends AbstractOnServerIT {
         // assume that userId == loginname (as we manually set it)
         assertEquals(userId, accountManager.getUserData(account, AccountUtils.Constants.KEY_USER_ID));
     }
+
+    @Test
+    public void checkName() {
+        UserAccountManagerImpl sut = new UserAccountManagerImpl(targetContext, accountManager);
+
+        Account owner = new Account("John@nextcloud.local", "nextcloud");
+        Account account1 = new Account("John@nextcloud.local", "nextcloud");
+        Account account2 = new Account("john@nextcloud.local", "nextcloud");
+
+        OCFile file1 = new OCFile("/test1.pdf");
+        file1.setOwnerId("John");
+
+        assertTrue(sut.accountOwnsFile(file1, owner));
+        assertTrue(sut.accountOwnsFile(file1, account1));
+        assertTrue(sut.accountOwnsFile(file1, account2));
+
+        file1.setOwnerId("john");
+        assertTrue(sut.accountOwnsFile(file1, owner));
+        assertTrue(sut.accountOwnsFile(file1, account1));
+        assertTrue(sut.accountOwnsFile(file1, account2));
+    }
 }