Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New arch] Delete public share #2544

Merged
merged 23 commits into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
db8d4f7
Include delete share operation in dao and datasources
davigonz May 9, 2019
4a914c3
Convert RemoveShareDialogFragment into Kotlin and include some more c…
davigonz May 9, 2019
4b6c4dc
Use listeners to properly show remove share fragment
davigonz May 10, 2019
2b1badb
Delete share from ShareActivity
davigonz May 14, 2019
818ad27
Clean up some dependencies when getting public shares and capabilities
davigonz May 14, 2019
9911cec
Clean up dependencies when creating/editing shares
davigonz May 15, 2019
0faf095
Dismiss dialog to edit shares
davigonz May 15, 2019
8ea1bd4
Get rid of account dependency in PublicShareDialogFragment
davigonz May 15, 2019
3cc62ae
Fix unit tests
davigonz May 15, 2019
291f174
Fixing UI tests after some dependencies cleanup[WIP]
davigonz May 15, 2019
ad23338
Fix ShareFileFragmentTest UI tests
davigonz May 16, 2019
aa6f5ae
Fix crash when getting shares the first time
davigonz May 16, 2019
302d8d1
Fix PublicShareCreationDialogFragmentTest UI tests
davigonz May 17, 2019
60eaaed
Fix UI tests in PublicShareEditionDialogFragmentTest and ShareFolderF…
davigonz May 17, 2019
993ddf6
Use room implementation in Content Provider to delete shares + test f…
davigonz May 17, 2019
64d34ed
Refactor share repository tests
davigonz May 20, 2019
0e37f98
Include tests for public sharing deletion in repository
davigonz May 20, 2019
ef99a02
Move filePath and account variables to ShareRepository creation
davigonz May 20, 2019
fe8723f
Tests for sharing deletion within OCShareViewmodel and OCShareDao
davigonz May 20, 2019
6e01457
Swap expected and actual parameters for every assertEquals call
davigonz May 20, 2019
4482591
Delete unused list
davigonz May 27, 2019
3d3669b
Apply CR changes
davigonz May 30, 2019
27fe03c
Apply additional changes requested in CR
davigonz May 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.platform.app.InstrumentationRegistry
import com.owncloud.android.db.OwncloudDatabase
import com.owncloud.android.lib.resources.shares.ShareType
import com.owncloud.android.lib.resources.status.CapabilityBooleanType
import com.owncloud.android.utils.LiveDataTestUtil.getValue
import com.owncloud.android.utils.TestUtil
Expand Down Expand Up @@ -68,44 +67,38 @@ class OCCapabilityDaoTest {
"user2@server"
)
)

assertThat(capability, notNullValue())
assertEquals(capability.accountName, "user2@server")
assertEquals(capability.versionMayor, 6)
assertEquals(capability.versionMinor, 5)
assertEquals(capability.versionMicro, 4)
assertEquals(capability.versionString, "6.0")
assertEquals("user2@server", capability.accountName)
assertEquals(6, capability.versionMayor)
assertEquals(5, capability.versionMinor)
assertEquals(4, capability.versionMicro)
assertEquals("6.0", capability.versionString)
}

@Test
fun getNonExistingCapabilities() {
ocCapabilityDao.insert(
listOf(
TestUtil.createCapability("user@server", 10, 9, 8, "10.1.4")
)
TestUtil.createCapability("user@server", 10, 9, 8, "10.1.4")
)

val capability = getValue(
ocCapabilityDao.getCapabilityForAccount(
"user@server2"
)
)

assertThat(capability, nullValue())
}

@Test
fun replaceCapabilityIfAlreadyExists_exists() {
ocCapabilityDao.insert(
listOf(
TestUtil.createCapability(
"admin@server",
3,
2,
1,
"3.7.5",
sharingPublicPasswordEnforced = CapabilityBooleanType.FALSE.value
)
TestUtil.createCapability(
"admin@server",
3,
2,
1,
"3.7.5",
sharingPublicPasswordEnforced = CapabilityBooleanType.FALSE.value
)
)

Expand All @@ -127,28 +120,25 @@ class OCCapabilityDaoTest {
"admin@server"
)
)

assertThat(capability, notNullValue())
assertEquals(capability.accountName, "admin@server")
assertEquals(capability.versionMayor, 3)
assertEquals(capability.versionMinor, 2)
assertEquals(capability.versionMicro, 1)
assertEquals(capability.versionString, "3.7.5")
assertEquals(capability.filesSharingPublicPasswordEnforced, 1)
assertEquals("admin@server", capability.accountName)
assertEquals(3, capability.versionMayor)
assertEquals(2, capability.versionMinor)
assertEquals(1, capability.versionMicro)
assertEquals("3.7.5", capability.versionString)
assertEquals(1, capability.filesSharingPublicPasswordEnforced)
}

@Test
fun replacePublicShareIfAlreadyExists_doesNotExist() {
ocCapabilityDao.insert(
listOf(
TestUtil.createCapability(
"cto@server",
10,
8,
6,
"10.0.2",
sharingPublicPasswordEnforcedReadOnly = CapabilityBooleanType.FALSE.value
)
TestUtil.createCapability(
"cto@server",
10,
8,
6,
"10.0.2",
sharingPublicPasswordEnforcedReadOnly = CapabilityBooleanType.FALSE.value
)
)

Expand All @@ -170,28 +160,26 @@ class OCCapabilityDaoTest {
"cto@server"
)
)

assertThat(capability1, notNullValue())
assertEquals(capability1.accountName, "cto@server")
assertEquals(capability1.versionMayor, 10)
assertEquals(capability1.versionMinor, 8)
assertEquals(capability1.versionMicro, 6)
assertEquals(capability1.versionString, "10.0.2")
assertEquals(capability1.filesSharingPublicPasswordEnforcedReadOnly, CapabilityBooleanType.FALSE.value)
assertEquals("cto@server", capability1.accountName)
assertEquals(10, capability1.versionMayor)
assertEquals(8, capability1.versionMinor)
assertEquals(6, capability1.versionMicro)
assertEquals("10.0.2", capability1.versionString)
assertEquals(CapabilityBooleanType.FALSE.value, capability1.filesSharingPublicPasswordEnforcedReadOnly)

// capability2 didn't exist before, it should not replace the old one but got created
val capability2 = getValue(
ocCapabilityDao.getCapabilityForAccount(
"seo@server"
)
)

assertThat(capability2, notNullValue())
assertEquals(capability2.accountName, "seo@server")
assertEquals(capability2.versionMayor, 14)
assertEquals(capability2.versionMinor, 13)
assertEquals(capability2.versionMicro, 12)
assertEquals(capability2.versionString, "14.3.8")
assertEquals(capability2.filesSharingPublicPasswordEnforcedReadOnly, CapabilityBooleanType.TRUE.value)
assertEquals("seo@server", capability2.accountName)
assertEquals(14, capability2.versionMayor)
assertEquals(13, capability2.versionMinor)
assertEquals(12, capability2.versionMicro)
assertEquals("14.3.8", capability2.versionString)
assertEquals(CapabilityBooleanType.TRUE.value, capability2.filesSharingPublicPasswordEnforcedReadOnly)
}
}
Loading