-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into dev
- Loading branch information
Showing
11 changed files
with
284 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: "Validate Gradle Wrapper" | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
validation: | ||
name: "Validation" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: gradle/wrapper-validation-action@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
src/androidTest/java/com/owncloud/android/ui/activity/DrawerActivityIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
* | ||
* Nextcloud Android client application | ||
* | ||
* @author Tobias Kaminsky | ||
* Copyright (C) 2020 Tobias Kaminsky | ||
* Copyright (C) 2020 Nextcloud GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.owncloud.android.ui.activity; | ||
|
||
import android.Manifest; | ||
import android.accounts.Account; | ||
import android.accounts.AccountManager; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
|
||
import com.nextcloud.client.account.UserAccountManager; | ||
import com.nextcloud.client.account.UserAccountManagerImpl; | ||
import com.owncloud.android.AbstractIT; | ||
import com.owncloud.android.MainApp; | ||
import com.owncloud.android.R; | ||
import com.owncloud.android.lib.common.accounts.AccountUtils; | ||
|
||
import org.junit.BeforeClass; | ||
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.action.ViewActions.click; | ||
import static androidx.test.espresso.matcher.ViewMatchers.withId; | ||
import static androidx.test.espresso.matcher.ViewMatchers.withText; | ||
import static org.hamcrest.Matchers.anyOf; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
public class DrawerActivityIT extends AbstractIT { | ||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule = new IntentsTestRule<>(FileDisplayActivity.class, | ||
true, | ||
false); | ||
|
||
@Rule | ||
public final GrantPermissionRule permissionRule = GrantPermissionRule.grant( | ||
Manifest.permission.WRITE_EXTERNAL_STORAGE); | ||
private static Account account2; | ||
private static String account2Name; | ||
private static String account2DisplayName; | ||
|
||
@BeforeClass | ||
public static void beforeClass() { | ||
Bundle arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments(); | ||
Uri baseUrl = Uri.parse(arguments.getString("TEST_SERVER_URL")); | ||
String loginName = "user1"; | ||
String password = "user1"; | ||
|
||
Account temp = new Account(loginName + "@" + baseUrl, MainApp.getAccountType(targetContext)); | ||
UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext); | ||
if (!accountManager.exists(temp)) { | ||
AccountManager platformAccountManager = AccountManager.get(targetContext); | ||
platformAccountManager.addAccountExplicitly(temp, password, null); | ||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION, | ||
Integer.toString(UserAccountManager.ACCOUNT_VERSION)); | ||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_VERSION, "14.0.0.0"); | ||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, baseUrl.toString()); | ||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, loginName); // same as userId | ||
} | ||
|
||
final UserAccountManager userAccountManager = UserAccountManagerImpl.fromContext(targetContext); | ||
account2 = userAccountManager.getAccountByName(loginName + "@" + baseUrl); | ||
account2Name = loginName + "@" + baseUrl; | ||
account2DisplayName = "User One@" + baseUrl; | ||
} | ||
|
||
@Test | ||
public void switchAccountViaAccountList() { | ||
FileDisplayActivity sut = activityRule.launchActivity(null); | ||
|
||
assertEquals(account, sut.getUser().get().toPlatformAccount()); | ||
|
||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open()); | ||
onView(withId(R.id.drawer_active_user)).perform(click()); | ||
|
||
onView(anyOf(withText(account2Name), withText(account2DisplayName))).perform(click()); | ||
|
||
waitForIdleSync(); | ||
|
||
assertEquals(account2, sut.getUser().get().toPlatformAccount()); | ||
|
||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open()); | ||
onView(withId(R.id.drawer_active_user)).perform(click()); | ||
onView(withText(account.name)).perform(click()); | ||
} | ||
|
||
@Test | ||
public void switchAccountViaAvatar() { | ||
FileDisplayActivity sut = activityRule.launchActivity(null); | ||
|
||
assertEquals(account, sut.getUser().get().toPlatformAccount()); | ||
|
||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open()); | ||
onView(withId(R.id.drawer_account_end)).perform(click()); | ||
|
||
waitForIdleSync(); | ||
|
||
assertEquals(account2, sut.getUser().get().toPlatformAccount()); | ||
|
||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open()); | ||
onView(withId(R.id.drawer_account_end)).perform(click()); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/androidTest/java/com/owncloud/android/ui/helpers/FileOperationsHelperIT.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* | ||
* Nextcloud Android client application | ||
* | ||
* @author Tobias Kaminsky | ||
* Copyright (C) 2020 Tobias Kaminsky | ||
* Copyright (C) 2020 Nextcloud GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package com.owncloud.android.ui.helpers | ||
|
||
import com.owncloud.android.MainApp | ||
import junit.framework.Assert.assertEquals | ||
import junit.framework.Assert.assertTrue | ||
import org.junit.Test | ||
|
||
class FileOperationsHelperIT { | ||
|
||
@Test | ||
fun testNull() { | ||
MainApp.setStoragePath(null) | ||
assertEquals(-1L, FileOperationsHelper.getAvailableSpaceOnDevice()) | ||
} | ||
|
||
@Test | ||
fun testNonExistingPath() { | ||
MainApp.setStoragePath("/123/123") | ||
assertEquals(-1L, FileOperationsHelper.getAvailableSpaceOnDevice()) | ||
} | ||
|
||
@Test | ||
fun testExistingPath() { | ||
MainApp.setStoragePath("/sdcard/") | ||
assertTrue(FileOperationsHelper.getAvailableSpaceOnDevice() > 0L) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.