11/*
22 * Nextcloud - Android Client
33 *
4+ * SPDX-FileCopyrightText: 2025 Philipp Hasper <vcs@hasper.info>
45 * SPDX-FileCopyrightText: 2025 Alper Ozturk <alper.ozturk@nextcloud.com>
56 * SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me>
67 * SPDX-FileCopyrightText: 2020 Chris Narkiewicz <hello@ezaquarii.com>
@@ -12,19 +13,31 @@ package com.owncloud.android.ui.fragment
1213import androidx.test.core.app.launchActivity
1314import androidx.test.espresso.Espresso.onView
1415import androidx.test.espresso.assertion.ViewAssertions.matches
16+ import androidx.test.espresso.intent.Intents
17+ import androidx.test.espresso.intent.Intents.intended
18+ import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent
19+ import androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA
1520import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
21+ import androidx.test.espresso.matcher.ViewMatchers.isEnabled
1622import androidx.test.espresso.matcher.ViewMatchers.isRoot
23+ import androidx.test.espresso.matcher.ViewMatchers.withId
24+ import androidx.test.espresso.matcher.ViewMatchers.withText
1725import com.nextcloud.test.GrantStoragePermissionRule.Companion.grant
1826import com.nextcloud.test.TestActivity
1927import com.owncloud.android.AbstractIT
28+ import com.owncloud.android.R
2029import com.owncloud.android.datamodel.OCFile
2130import com.owncloud.android.lib.resources.shares.ShareType
2231import com.owncloud.android.lib.resources.shares.ShareeUser
2332import com.owncloud.android.lib.resources.tags.Tag
33+ import com.owncloud.android.ui.activity.FolderPickerActivity
2434import com.owncloud.android.utils.EspressoIdlingResource
2535import com.owncloud.android.utils.MimeType
2636import com.owncloud.android.utils.ScreenshotTest
37+ import org.hamcrest.Matchers.allOf
38+ import org.hamcrest.Matchers.not
2739import org.junit.Assert
40+ import org.junit.Before
2841import org.junit.Rule
2942import org.junit.Test
3043import org.junit.rules.TestRule
@@ -35,6 +48,11 @@ class OCFileListFragmentStaticServerIT : AbstractIT() {
3548 @get:Rule
3649 var storagePermissionRule: TestRule = grant()
3750
51+ @Before
52+ fun initIntentRecording () {
53+ Intents .init ()
54+ }
55+
3856 @Test
3957 @ScreenshotTest
4058 @Suppress(" MagicNumber" )
@@ -397,4 +415,50 @@ class OCFileListFragmentStaticServerIT : AbstractIT() {
397415 Assert .assertTrue(sut.adapter.shouldShowHeader())
398416 }
399417 }
418+
419+ @Test
420+ fun shouldStartMoveInParentFolder () {
421+ launchActivity<TestActivity >().use { scenario ->
422+ val fragment = OCFileListFragment ()
423+ var testFolder: OCFile ? = null
424+
425+ scenario.onActivity { activity ->
426+ testFolder = OCFile (" /folder/" ).apply {
427+ setFolder()
428+ }
429+ activity.storageManager.saveNewFile(testFolder)
430+
431+ val testFile = OCFile (" ${testFolder.remotePath} myImage.png" ).apply {
432+ parentId = testFolder.fileId
433+ activity.storageManager.saveNewFile(this )
434+ }
435+
436+ activity.addFragment(fragment)
437+ activity.supportFragmentManager.executePendingTransactions()
438+
439+ fragment.listDirectory(testFolder, false )
440+ activity.supportFragmentManager.executePendingTransactions()
441+ fragment.onFileActionChosen(R .id.action_move_or_copy, setOf (testFile))
442+ activity.supportFragmentManager.executePendingTransactions()
443+ }
444+ // Check that the FolderPickerActivity was opened
445+ intended(hasComponent(FolderPickerActivity ::class .java.canonicalName))
446+
447+ // Check that the Action Bar shows the current folder name as title
448+ onView(
449+ allOf(
450+ isDescendantOfA(withId(R .id.toolbar)),
451+ withText(testFolder!! .fileName)
452+ )
453+ ).check(matches(isDisplayed()))
454+
455+ // Test the button's enabled status. "Move" should not be enabled, but the rest should.
456+ onView(allOf(withId(R .id.folder_picker_btn_cancel), isDisplayed()))
457+ .check(matches(isEnabled()))
458+ onView(allOf(withId(R .id.folder_picker_btn_copy), isDisplayed()))
459+ .check(matches(isEnabled()))
460+ onView(allOf(withId(R .id.folder_picker_btn_move), isDisplayed()))
461+ .check(matches(not (isEnabled())))
462+ }
463+ }
400464}
0 commit comments