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] Improve viewmodel behaviour #2569

Merged
merged 11 commits into from
Jun 11, 2019

Conversation

davigonz
Copy link
Contributor

Implements #2565

@davigonz davigonz changed the base branch from master to new_arch/flow_sharing_tests June 10, 2019 13:09
@davigonz davigonz requested review from jesmrec and hosy June 10, 2019 13:19

// Check whether the dialog to create the public share has been properly closed
onView(withText(R.string.share_via_link_create_title)).check(doesNotExist())
onView(withText(newPublicShare.name)).check(matches(isDisplayed()))

unregisterCreateShareFragmentAsIdlingResource(createShareFragmentIdlingResource)

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??

Copy link
Contributor Author

@davigonz davigonz Jun 11, 2019

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.

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:

private lateinit var idlingResource: <Your type>

@Before
fun setUp() {
    idlingResource = // call constructor
    //register ...
}

@After  
fun tearDown() {
    // unregister
}

Copy link
Contributor Author

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@before
fun setUp() {
idlingResource = // call constructor
//register ...
}

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.

Screenshot 2019-06-11 at 14 27 11

)
IdlingPolicies.setIdlingResourceTimeout(1, TimeUnit.HOURS);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 hour???? really???

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ups, I forgot to change this

@@ -74,11 +78,11 @@ class OCShareViewModel(
expirationDateInMillis: Long,
permissions: Int,
publicUpload: Boolean
): LiveData<Resource<List<OCShare>>> = shareRepository.updatePublicShareForFile(
): LiveData<Resource<Void>> = shareRepository.updatePublicShareForFile(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use Void? Shouldn't it be better use Unit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link

@jcmontesmartos jcmontesmartos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@davigonz
Copy link
Contributor Author

Since we are merging this branch into new_arch/flow_sharing_tests, QA will be directly passed within #2558

@davigonz davigonz self-assigned this Jun 11, 2019
@davigonz davigonz merged commit 1e4480f into new_arch/flow_sharing_tests Jun 11, 2019
@delete-merged-branch delete-merged-branch bot deleted the new_arch/improve_viewmodels branch June 11, 2019 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants