-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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] Improve viewmodel behaviour #2569
Merged
davigonz
merged 11 commits into
new_arch/flow_sharing_tests
from
new_arch/improve_viewmodels
Jun 11, 2019
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d636b6d
Use just one livedata with shares
davigonz 90852cf
Decouple livedatas between get shares operation and other ones
davigonz 47f6d00
Fix unit tests
davigonz 96e4d04
Fix UI tests [WIP]
davigonz 2729988
Fix share creation UI tests using idling resources
davigonz 897f981
Fix UI tests (todo - get rid of Thread.sleep)
davigonz e510a81
Fix UI tests
davigonz 4bf99ad
Delete unused idling resource
davigonz b60c4e0
Uncomment deletPublicLink test
davigonz 420413a
Fix addExpirationDate() test, included in share edition suite
davigonz 34d458f
Apply CR changes
davigonz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
39 changes: 39 additions & 0 deletions
39
...p/src/androidTest/java/com/owncloud/android/shares/ui/FragmentVisibilityIdlingResource.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,39 @@ | ||
package com.owncloud.android.shares.ui | ||
|
||
import android.view.View | ||
import androidx.fragment.app.Fragment | ||
import androidx.test.espresso.IdlingResource | ||
|
||
class FragmentVisibilityIdlingResource(private val fragment: Fragment?, private val expectedVisibility: Int) : | ||
IdlingResource { | ||
private var idle: Boolean = false | ||
private var resourceCallback: IdlingResource.ResourceCallback? = null | ||
|
||
init { | ||
this.idle = false | ||
this.resourceCallback = null | ||
} | ||
|
||
override fun getName(): String { | ||
return FragmentVisibilityIdlingResource::class.java.simpleName | ||
} | ||
|
||
override fun isIdleNow(): Boolean { | ||
if (fragment == null) return false | ||
|
||
idle = idle || (fragment.isVisible && expectedVisibility == View.VISIBLE) || | ||
(!fragment.isVisible && expectedVisibility == View.INVISIBLE) | ||
|
||
if (idle) { | ||
if (resourceCallback != null) { | ||
resourceCallback!!.onTransitionToIdle() | ||
} | ||
} | ||
|
||
return idle | ||
} | ||
|
||
override fun registerIdleTransitionCallback(resourceCallback: IdlingResource.ResourceCallback) { | ||
this.resourceCallback = resourceCallback | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you include this statement in a "@after" method??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the idling resource to unregister is created for each test and not shared between different ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"@before" and "@after" are functions are called before and after running one single test.
My idea would be to have your tests as following:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I know what you mean, I tried that way but the tests were not working fine. Let me recheck it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not using this because I register the idling resources in the middle of the tests, after executing other lines of code.
If you see the Expresso idling resources docs , there's two different ways to implement it (see below), I decided to use the second one and that's why I do not use
@After
method either.