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 architecture] Whole flow tests for sharing #2558

Merged
merged 26 commits into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
588567a
Use Koin to inject viewmodel dependencies on ShareActivity
davigonz May 28, 2019
d25c774
First tests using Koin and account creation to make flow tests possible
davigonz May 29, 2019
255e9fe
Include createPublicShareWithNoPublicSharesYet and createPublicShareW…
davigonz May 29, 2019
c18afb1
Finish share creation tests
davigonz May 29, 2019
4fbdc5e
Share edition tests (files)
davigonz May 29, 2019
4aa9439
extend use cases UI tests in public sharing
jesmrec May 31, 2019
c4becd4
add loading tests to every operation on public shares
jesmrec May 31, 2019
a85e6a0
Remove loading tests
davigonz Jun 3, 2019
d636b6d
Use just one livedata with shares
davigonz Jun 6, 2019
90852cf
Decouple livedatas between get shares operation and other ones
davigonz Jun 7, 2019
47f6d00
Fix unit tests
davigonz Jun 7, 2019
96e4d04
Fix UI tests [WIP]
davigonz Jun 7, 2019
2729988
Fix share creation UI tests using idling resources
davigonz Jun 10, 2019
897f981
Fix UI tests (todo - get rid of Thread.sleep)
davigonz Jun 10, 2019
e510a81
Fix UI tests
davigonz Jun 10, 2019
4bf99ad
Delete unused idling resource
davigonz Jun 10, 2019
b60c4e0
Uncomment deletPublicLink test
davigonz Jun 10, 2019
420413a
Fix addExpirationDate() test, included in share edition suite
davigonz Jun 11, 2019
34d458f
Apply CR changes
davigonz Jun 11, 2019
1e4480f
Merge pull request #2569 from owncloud/new_arch/improve_viewmodels
davigonz Jun 11, 2019
deeb89c
Polish addExpirationDate test
davigonz Jun 11, 2019
cc049d4
Loading and error tests when creating, editing and deleting shares
davigonz Jun 11, 2019
24d5b5b
Remove no longer needed idling resources
davigonz Jun 11, 2019
ddfdf75
Apply CR changes
davigonz Jun 14, 2019
d43bcc3
Create koin_version constant
davigonz Jun 17, 2019
ee4d2da
add a scrollTo in order to be safe, in case the Save button is not re…
jesmrec Jun 17, 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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ buildscript {
kotlinVersion = '1.3.21'
archLifecycleVersion = '2.0.0'
roomVersion = '2.0.0'
koinVersion = '2.0.1'

// Testing
junitVersion = "4.12"
Expand Down
9 changes: 6 additions & 3 deletions owncloudApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ dependencies {
androidTestImplementation 'androidx.test:runner:1.1.1'
// Espresso core
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
// Espresso contrib
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.1'
// Espresso intents
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.1'
// Espresso web
androidTestImplementation 'androidx.test.espresso:espresso-web:3.1.1'
// Espresso intents
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'
// UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
// fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
Expand Down Expand Up @@ -76,6 +76,9 @@ dependencies {
// Room
implementation "androidx.room:room-runtime:$roomVersion"
kapt "androidx.room:room-compiler:$roomVersion"

// Koin dependency injector
implementation "org.koin:koin-androidx-viewmodel:$koinVersion"
}

tasks.withType(Test) {
Expand Down Expand Up @@ -172,7 +175,7 @@ android {

testOptions {
unitTests.returnDefaultValues = true
animationsDisabled = false
animationsDisabled = true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package com.owncloud.android.capabilities.datasource

import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import androidx.lifecycle.MutableLiveData
import androidx.test.platform.app.InstrumentationRegistry
import com.owncloud.android.capabilities.db.OCCapability
import com.owncloud.android.capabilities.db.OCCapabilityDao
import com.owncloud.android.db.OwncloudDatabase
Expand Down Expand Up @@ -73,7 +74,9 @@ class OCLocalCapabilitiesDataSourceTest {
newCapabilityAsLiveData
)

ocLocalCapabilitiesDataSource = OCLocalCapabilitiesDataSource(ocCapabilityDao)
val context = InstrumentationRegistry.getInstrumentation().targetContext

ocLocalCapabilitiesDataSource = OCLocalCapabilitiesDataSource(context, ocCapabilityDao)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package com.owncloud.android.capabilities.viewmodel
import android.accounts.Account
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import androidx.lifecycle.MutableLiveData
import androidx.test.platform.app.InstrumentationRegistry
import com.owncloud.android.capabilities.db.OCCapability
import com.owncloud.android.capabilities.repository.OCCapabilityRepository
import com.owncloud.android.utils.TestUtil
Expand All @@ -38,7 +39,6 @@ import org.mockito.Mockito.mock
@RunWith(JUnit4::class)
class OCCapabilityViewModelTest {
private var testAccount: Account = TestUtil.createAccount("admin@server", "test")

private lateinit var capability: OCCapability

@Rule
Expand All @@ -54,18 +54,20 @@ class OCCapabilityViewModelTest {
fun loadCapability() {
val ocCapabilityRepository = mock(OCCapabilityRepository::class.java)

val capabilityResourceAsLiveData: MutableLiveData<Resource<OCCapability>> = MutableLiveData()
capabilityResourceAsLiveData.value = Resource.success(capability)

`when`(
ocCapabilityRepository.loadCapabilityForAccount(
"admin@server"
)
).thenReturn(
capabilityResourceAsLiveData
MutableLiveData<Resource<OCCapability>>().apply {
value = Resource.success(capability)
}
)

val context = InstrumentationRegistry.getInstrumentation().targetContext

val ocCapabilityViewModel = OCCapabilityViewModel(
context,
account = testAccount,
capabilityRepository = ocCapabilityRepository
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package com.owncloud.android.shares.datasource

import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import androidx.lifecycle.MutableLiveData
import androidx.test.platform.app.InstrumentationRegistry
import com.owncloud.android.db.OwncloudDatabase
import com.owncloud.android.lib.resources.shares.ShareType
import com.owncloud.android.shares.db.OCShare
Expand Down Expand Up @@ -115,7 +116,9 @@ class OCLocalDataSourceTest {
1
)

ocLocalSharesDataSource = OCLocalSharesDataSource(ocSharesDao)
val context = InstrumentationRegistry.getInstrumentation().targetContext

ocLocalSharesDataSource = OCLocalSharesDataSource(context, ocSharesDao)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ 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.shares.db.OCShareDao
import com.owncloud.android.utils.LiveDataTestUtil.getValue
import com.owncloud.android.utils.TestUtil
import junit.framework.Assert.assertEquals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import android.accounts.Account
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.hasSibling
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
Expand Down Expand Up @@ -102,6 +103,12 @@ class ShareFileFragmentTest {
fun showPublicShares() {
loadShareFileFragment()
onView(withText("Image link")).check(matches(isDisplayed()))
onView(withText("Image link")).check(matches(hasSibling(withId(R.id.getPublicLinkButton))))
.check(matches(isDisplayed()))
onView(withText("Image link")).check(matches(hasSibling(withId(R.id.deletePublicLinkButton))))
.check(matches(isDisplayed()))
onView(withText("Image link")).check(matches(hasSibling(withId(R.id.editPublicLinkButton))))
.check(matches(isDisplayed()))
onView(withText("Image link 2")).check(matches(isDisplayed()))
onView(withText("Image link 3")).check(matches(isDisplayed()))
}
Expand Down
Loading