-
Notifications
You must be signed in to change notification settings - Fork 660
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
Espresso idling resource for Apollo GraphQL client #469
Espresso idling resource for Apollo GraphQL client #469
Conversation
… feature-espresso-idling-resource Conflicts: apollo-integration/build.gradle apollo-integration/src/test/java/com/apollographql/apollo/IntegrationTest.java apollo-runtime/src/main/java/com/apollographql/apollo/ApolloClient.java apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloCall.java
Not exposing apolloTracker to the clients. Instead they have to call apolloClient's getRunningCount method and setIdleCallback method which then delegates these calls to the apolloTracker
… feature-espresso-idling-resource
Please put the review on hold. I just found a flaky test. Will fix it and we can then review this one. |
|
… feature-espresso-idling-resource Conflicts: apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloCall.java
…Vadhera/apollo-android into feature-espresso-idling-resource
@sav007 Fixing it. |
…Vadhera/apollo-android into feature-espresso-idling-resource Conflicts: apollo-runtime/src/main/java/com/apollographql/apollo/internal/ApolloCallTracker.java
… feature-espresso-idling-resource Conflicts: gradle/dependencies.gradle
@@ -0,0 +1,4 @@ | |||
POM_ARTIFACT_ID=apollo-idling-resource |
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.
should we call it then apollo-espresso-support
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.
Hmm, yeah adding espresso makes it clear that this module is about supporting espresso testing. apollo-idling-resource
sounds vague.
@@ -0,0 +1,61 @@ | |||
package com.apollographql.apollo.espresso; |
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.
com.apollographql.apollo.test.espresso
?
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.
Right
@@ -0,0 +1,4 @@ | |||
POM_ARTIFACT_ID=apollo-idling-resource | |||
POM_NAME=Apollo GraphQL Idling Resource |
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.
Apollo GraphQL Espresso Support
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.
Done
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.
LGTM.
Only question about the naming of this module.
And I feel we need to publish jars instead of aars for all our android libs: http://stackoverflow.com/questions/19307341/android-library-gradle-release-jar
… feature-espresso-idling-resource
@sav007 I think it makes sense to publish jars only as we don't really have any resources in our android modules. Should I open a new issue, so that this can be tackled in another PR? |
Ok, looks like the build failed because the CI server was unable to download guava :| A problem occurred configuring project ':apollo-android-support'.
|
@digitalbuddha @BenSchwab @marwanad any comments? |
I'll take a look tomorrow. edit: srry got swamped with other stuff. I'll get back to it in a day or two. |
… feature-espresso-idling-resource Conflicts: apollo-runtime/src/main/java/com/apollographql/apollo/ApolloClient.java apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloCall.java
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.
👍 some minor nits.
Apologies for the delay, I'll finish up the rest of the review later.
I'm not a fan of the eager initialization of the ApolloTracker
but it seems inevitable for now. Would combining both the dispatcher and tracker under one extensible class make sense for this?
Last thing, I think it's not worth creating a module for the EspressoIdlingResource
under this repo though. Though unlikely, it would guard us against having to maintain that module if Espresso changes in the future.
We should, however, provide the API for an idle callback.
@@ -0,0 +1 @@ | |||
/build |
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.
is this needed?
The top-level .gitignore
has build/
already I believe.
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.
Not sure if the top level .gitignore ignores the module specific build directories, so yeah this is indeed required.
* Creates a new {@link IdlingResource} from {@link ApolloClient} with a given name. Register this instance using | ||
* Espresso class's registerIdlingResource in your test suite's setup method. | ||
* | ||
* @param name name of this idlingResource instance. |
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.
nit:spacing
@@ -0,0 +1,4 @@ | |||
POM_ARTIFACT_ID=apollo-espress-support |
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.
espresso
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.
Nice catch!
@@ -0,0 +1,4 @@ | |||
POM_ARTIFACT_ID=apollo-espress-support | |||
POM_NAME=Apollo GraphQL Espresso Support | |||
POM_DESCRIPTION=An EspressoIdlingResource for Apollo GraphQL Client. |
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.
EspressoIdlingResource
-> Espresso Idling Resource
?
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.
Alright
/** | ||
* An Espresso {@link IdlingResource} for {@link com.apollographql.apollo.ApolloClient}. | ||
*/ | ||
public class ApolloIdlingResource implements IdlingResource { |
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.
make final?
*/ | ||
public final class ApolloCallTracker { | ||
|
||
private IdleResourceCallback idleResourceCallback; |
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.
Do we really need a class for that? Can't we just take a Runnable
?
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 would not use Runnable for this as this is really callback not some runnable action that we need to run.
@marwanad Well that was the first thought which came to my mind to combine dispatcher and tracker in one class, but decided against it, because I wanted to keep the concerns separate and have a class whose only concern is to track calls and do nothing more. |
@VisheshVadhera I see all tests related to cache are failing could you pls fix that we can merge this PR |
On it.
…On 26 May 2017 3:21 am, "Ivan Savytskyi" ***@***.***> wrote:
@VisheshVadhera <https://github.com/visheshvadhera> I see all tests
related to cache are failing could you pls fix that we can merge this PR
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#469 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AD1DEMaZSeMQP_k9BI0LBCYrzMnBlXt7ks5r9ffUgaJpZM4NL6j->
.
|
… feature-espresso-idling-resource
Rename callTracker to tracker in ApolloClient
… feature-espresso-idling-resource
@sav007 Fixed the failing tests. Feel free to merge this PR. |
Closes #429
Added a new ApolloTracker class which keeps track of the running ApolloCall & ApolloPrefetch objects. ApolloIdlingResource basically uses this class (indirectly) to keep a count of the running call objects. When the count becomes zero it changes its state from active to idle.
ApolloTracker is very similar to the Dispatcher class in okHttpClient, but without the ExecutorService encapsulated inside.