Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasKaminsky committed Nov 18, 2022
2 parents aacd486 + aa355e7 commit b52cf18
Show file tree
Hide file tree
Showing 52 changed files with 1,554 additions and 1,350 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ configurations.configureEach {

// semantic versioning for version code
def versionMajor = 3
def versionMinor = 23
def versionMinor = 24
def versionPatch = 0
def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
*/
package com.owncloud.android.files

import android.view.Menu
import androidx.appcompat.view.menu.MenuBuilder
import androidx.test.core.app.launchActivity
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.nextcloud.client.TestActivity
import com.nextcloud.client.account.User
import com.nextcloud.utils.EditorUtils
import com.owncloud.android.AbstractIT
import com.owncloud.android.R
import com.owncloud.android.datamodel.ArbitraryDataProvider
import com.owncloud.android.datamodel.FileDataStorageManager
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.files.services.FileDownloader
Expand Down Expand Up @@ -67,6 +67,11 @@ class FileMenuFilterIT : AbstractIT() {
@MockK
private lateinit var mockOperationsServiceBinder: OperationsService.OperationsServiceBinder

@MockK
private lateinit var mockArbitraryDataProvider: ArbitraryDataProvider

private lateinit var editorUtils: EditorUtils

@Before
fun setup() {
MockKAnnotations.init(this)
Expand All @@ -78,6 +83,8 @@ class FileMenuFilterIT : AbstractIT() {
every { mockComponentsGetter.operationsServiceBinder } returns mockOperationsServiceBinder
every { mockStorageManager.getFileById(any()) } returns OCFile("/")
every { mockStorageManager.getFolderContent(any(), any()) } returns ArrayList<OCFile>()
every { mockArbitraryDataProvider.getValue(any<User>(), any()) } returns ""
editorUtils = EditorUtils(mockArbitraryDataProvider)
}

@Test
Expand All @@ -91,7 +98,7 @@ class FileMenuFilterIT : AbstractIT() {
testLockingVisibilities(
capability,
file,
ExpectedLockVisibilities(lockFile = false, unlockFile = false, lockedBy = false, lockedUntil = false)
ExpectedLockVisibilities(lockFile = false, unlockFile = false)
)
}

Expand All @@ -107,7 +114,7 @@ class FileMenuFilterIT : AbstractIT() {
testLockingVisibilities(
capability,
file,
ExpectedLockVisibilities(lockFile = true, unlockFile = false, lockedBy = false, lockedUntil = false)
ExpectedLockVisibilities(lockFile = true, unlockFile = false)
)
}

Expand All @@ -130,7 +137,7 @@ class FileMenuFilterIT : AbstractIT() {
testLockingVisibilities(
capability,
file,
ExpectedLockVisibilities(lockFile = false, unlockFile = true, lockedBy = true, lockedUntil = true)
ExpectedLockVisibilities(lockFile = false, unlockFile = true)
)
}

Expand All @@ -152,7 +159,7 @@ class FileMenuFilterIT : AbstractIT() {
testLockingVisibilities(
capability,
file,
ExpectedLockVisibilities(lockFile = false, unlockFile = false, lockedBy = true, lockedUntil = true)
ExpectedLockVisibilities(lockFile = false, unlockFile = false)
)
}

Expand Down Expand Up @@ -186,57 +193,48 @@ class FileMenuFilterIT : AbstractIT() {

launchActivity<TestActivity>().use {
it.onActivity { activity ->
val menu = getMenu(activity)
val filterFactory =
FileMenuFilter.Factory(mockStorageManager, activity, editorUtils)

var sut = FileMenuFilter(encryptedFolder, mockComponentsGetter, activity, true, user)
sut.filter(menu, false)
var sut = filterFactory.newInstance(encryptedFolder, mockComponentsGetter, true, user)
var toHide = sut.getToHide(false)

// encrypted folder, with content
assertFalse(menu.findItem(R.id.action_unset_encrypted).isVisible)
assertFalse(menu.findItem(R.id.action_encrypted).isVisible)
assertTrue(toHide.contains(R.id.action_unset_encrypted))
assertTrue(toHide.contains(R.id.action_encrypted))

// encrypted, but empty folder
sut = FileMenuFilter(encryptedEmptyFolder, mockComponentsGetter, activity, true, user)
sut.filter(menu, false)
sut = filterFactory.newInstance(encryptedEmptyFolder, mockComponentsGetter, true, user)
toHide = sut.getToHide(false)

assertTrue(menu.findItem(R.id.action_unset_encrypted).isVisible)
assertFalse(menu.findItem(R.id.action_encrypted).isVisible)
assertFalse(toHide.contains(R.id.action_unset_encrypted))
assertTrue(toHide.contains(R.id.action_encrypted))

// regular folder, with content
sut = FileMenuFilter(normalFolder, mockComponentsGetter, activity, true, user)
sut.filter(menu, false)
sut = filterFactory.newInstance(normalFolder, mockComponentsGetter, true, user)
toHide = sut.getToHide(false)

assertFalse(menu.findItem(R.id.action_unset_encrypted).isVisible)
assertFalse(menu.findItem(R.id.action_encrypted).isVisible)
assertTrue(toHide.contains(R.id.action_unset_encrypted))
assertTrue(toHide.contains(R.id.action_encrypted))

// regular folder, without content
sut = FileMenuFilter(normalEmptyFolder, mockComponentsGetter, activity, true, user)
sut.filter(menu, false)
sut = filterFactory.newInstance(normalEmptyFolder, mockComponentsGetter, true, user)
toHide = sut.getToHide(false)

assertFalse(menu.findItem(R.id.action_unset_encrypted).isVisible)
assertTrue(menu.findItem(R.id.action_encrypted).isVisible)
assertTrue(toHide.contains(R.id.action_unset_encrypted))
assertFalse(toHide.contains(R.id.action_encrypted))
}
}
}

private data class ExpectedLockVisibilities(
val lockFile: Boolean,
val unlockFile: Boolean,
val lockedBy: Boolean,
val lockedUntil: Boolean
val unlockFile: Boolean
)

private fun configureCapability(capability: OCCapability) {
every { mockStorageManager.getCapability(any<User>()) } returns capability
every { mockStorageManager.getCapability(any<String>()) } returns capability
every { mockComponentsGetter.storageManager } returns mockStorageManager
}

private fun getMenu(activity: TestActivity): Menu {
val inflater = activity.menuInflater
val menu = MenuBuilder(activity)
inflater.inflate(R.menu.item_file, menu)
return menu
}

private fun testLockingVisibilities(
Expand All @@ -248,32 +246,20 @@ class FileMenuFilterIT : AbstractIT() {

launchActivity<TestActivity>().use {
it.onActivity { activity ->
val menu = getMenu(activity)

val sut = FileMenuFilter(file, mockComponentsGetter, activity, true, user)
val filterFactory =
FileMenuFilter.Factory(mockStorageManager, activity, editorUtils)
val sut = filterFactory.newInstance(file, mockComponentsGetter, true, user)

sut.filter(menu, false)
val toHide = sut.getToHide(false)

assertEquals(
expectedLockVisibilities.lockFile,
menu.findItem(R.id.action_lock_file).isVisible
!toHide.contains(R.id.action_lock_file)
)
assertEquals(
expectedLockVisibilities.unlockFile,
menu.findItem(R.id.action_unlock_file).isVisible
!toHide.contains(R.id.action_unlock_file)
)
assertEquals(
expectedLockVisibilities.lockedBy,
menu.findItem(R.id.action_locked_by).isVisible
)
assertEquals(
expectedLockVisibilities.lockedUntil,
menu.findItem(R.id.action_locked_until).isVisible
)

// locked by and until should always be disabled, they're not real actions
assertFalse(menu.findItem(R.id.action_locked_by).isEnabled)
assertFalse(menu.findItem(R.id.action_locked_until).isEnabled)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.device.DeviceInfo;
import com.nextcloud.ui.ChooseAccountDialogFragment;
import com.nextcloud.ui.fileactions.FileActionsBottomSheet;
import com.owncloud.android.AbstractIT;
import com.owncloud.android.MainApp;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
Expand Down Expand Up @@ -496,6 +497,18 @@ public void testStoragePermissionDialog() {
showDialog(sut);
}

@Test
@ScreenshotTest
public void testFileActionsBottomSheet() {
if (Looper.myLooper() == null) {
Looper.prepare();
}

OCFile ocFile = new OCFile("/test.md");
final FileActionsBottomSheet sut = FileActionsBottomSheet.newInstance(ocFile, false);
showDialog(sut);
}

private FileDisplayActivity showDialog(DialogFragment dialog) {
Intent intent = new Intent(targetContext, FileDisplayActivity.class);

Expand Down
4 changes: 3 additions & 1 deletion app/src/debug/java/com/nextcloud/client/TestActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ import androidx.fragment.app.Fragment
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.nextcloud.client.network.Connectivity
import com.nextcloud.client.network.ConnectivityService
import com.nextcloud.utils.EditorUtils
import com.owncloud.android.R
import com.owncloud.android.databinding.TestLayoutBinding
import com.owncloud.android.datamodel.ArbitraryDataProvider
import com.owncloud.android.datamodel.FileDataStorageManager
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.files.services.FileDownloader
Expand Down Expand Up @@ -144,7 +146,7 @@ class TestActivity :

override fun getFileOperationsHelper(): FileOperationsHelper {
if (!this::fileOperation.isInitialized) {
fileOperation = FileOperationsHelper(this, userAccountManager, connectivityServiceMock)
fileOperation = FileOperationsHelper(this, userAccountManager, connectivityServiceMock, EditorUtils(ArbitraryDataProvider(contentResolver)))
}

return fileOperation
Expand Down

This file was deleted.

42 changes: 0 additions & 42 deletions app/src/main/java/com/nextcloud/android/files/ThemedPopupMenu.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DatabaseModule {
fun database(context: Context, clock: Clock): NextcloudDatabase {
return Room
.databaseBuilder(context, NextcloudDatabase::class.java, ProviderMeta.DB_NAME)
.addLegacyMigrations(context, clock)
.addLegacyMigrations(clock)
.addMigrations(RoomMigration())
.fallbackToDestructiveMigration()
.build()
Expand Down
Loading

0 comments on commit b52cf18

Please sign in to comment.