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

Espresso idling resource for Apollo GraphQL client #469

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
7a1664d
Add apollo-idling-resource module
VisheshVadhera Apr 19, 2017
3ad4610
Restructuring of the module
VisheshVadhera Apr 19, 2017
1210f32
Add IdlingResource class
VisheshVadhera Apr 19, 2017
0dda9b8
Add dispatcher
VisheshVadhera Apr 20, 2017
51817a7
Add ApolloTracker for tracking the requests
VisheshVadhera Apr 22, 2017
76780b3
Execute callback on calls finished
VisheshVadhera Apr 24, 2017
0af44d1
Register espresso callback with apolloTracker
VisheshVadhera Apr 24, 2017
989e102
Add basic test to check that idlingResource is being created properly
VisheshVadhera Apr 24, 2017
b68e8e5
Add test for idleNow
VisheshVadhera Apr 25, 2017
ff6fa0d
Add test for registerCallBack
VisheshVadhera Apr 26, 2017
7158335
Rename variables
VisheshVadhera Apr 26, 2017
873f393
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera Apr 28, 2017
5525529
Change variable names
VisheshVadhera Apr 28, 2017
43a90b6
Add tests for apolloCallTracker
VisheshVadhera Apr 28, 2017
53801bf
Hide usage of apolloTracker in apolloClient
VisheshVadhera Apr 28, 2017
4483920
Fix tests in apolloCallTracker
VisheshVadhera Apr 28, 2017
190ae11
Add tests for syncCalls
VisheshVadhera Apr 28, 2017
664b033
Add test for checking that idleCallback is invoked
VisheshVadhera Apr 28, 2017
41dcb1d
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera Apr 28, 2017
72484ae
Cleanup
VisheshVadhera Apr 28, 2017
cbf6574
Add docs for ApolloCallTracker
VisheshVadhera Apr 28, 2017
de9a829
Checkstyle
VisheshVadhera May 1, 2017
1cc6187
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 2, 2017
07d4b91
Merge branch 'feature-espresso-idling-resource' of github.com:Vishesh…
VisheshVadhera May 2, 2017
5d23a9f
Temp fix for apollo-sample module
VisheshVadhera May 2, 2017
69a28d5
Revert the change made in last commit
VisheshVadhera May 3, 2017
d934cc0
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 3, 2017
8d1a6d6
Fix the assertionError in ApolloPrefetchCallbackTest
VisheshVadhera May 3, 2017
7610a67
Move the test class to idling-resource package
VisheshVadhera May 3, 2017
c75d4c4
Add docs for new methods in apolloClient
VisheshVadhera May 3, 2017
79d2f99
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 4, 2017
f5ba765
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 9, 2017
85581e0
Change method names
VisheshVadhera May 11, 2017
7471952
Move the private method to the last
VisheshVadhera May 11, 2017
f3f1e48
Change method names
VisheshVadhera May 11, 2017
fa598f1
Change Deque with LinkedHashSet
VisheshVadhera May 11, 2017
0d495e1
Remove synchronized from setIdleCallback
VisheshVadhera May 11, 2017
8133815
Rename idleCallback to idleResourceCallback
VisheshVadhera May 12, 2017
1860193
Merge branch 'feature-espresso-idling-resource' of github.com:Vishesh…
VisheshVadhera May 12, 2017
f47672b
Fix checkstyle
VisheshVadhera May 12, 2017
c8102ba
Fix checkstyle
VisheshVadhera May 12, 2017
dd3cb51
Fix failing test
VisheshVadhera May 13, 2017
95c9383
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 13, 2017
f9d36a8
Change package & module name
VisheshVadhera May 13, 2017
ac1e4a8
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 13, 2017
516615b
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 23, 2017
4fab454
Code review
VisheshVadhera May 24, 2017
57c401d
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 29, 2017
c4e5ab5
Change the order of methods in the class
VisheshVadhera May 29, 2017
3dad93e
Add missing tracker to builder in RealApolloCall
VisheshVadhera May 29, 2017
9820c66
Fix tests in queryFetcher
VisheshVadhera May 30, 2017
2096424
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 30, 2017
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
Prev Previous commit
Next Next commit
Checkstyle
  • Loading branch information
VisheshVadhera committed May 1, 2017
commit de9a829c9698df1f89dfa6e530d5663a3cef960b
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import com.apollographql.apollo.cache.normalized.NormalizedCacheFactory;
import com.apollographql.apollo.cache.normalized.RecordFieldAdapter;
import com.apollographql.apollo.interceptor.ApolloInterceptor;
import com.apollographql.apollo.internal.*;
import com.apollographql.apollo.internal.ApolloCallTracker;
import com.apollographql.apollo.internal.RealApolloCall;
import com.apollographql.apollo.internal.RealApolloPrefetch;
import com.apollographql.apollo.internal.cache.http.HttpCache;
import com.apollographql.apollo.internal.cache.normalized.RealApolloStore;
import com.apollographql.apollo.internal.util.ApolloLogger;
Expand Down Expand Up @@ -118,7 +120,8 @@ public <D extends Operation.Data, T, V extends Operation.Variables> ApolloCall<T
@Override
public <D extends Operation.Data, T, V extends Operation.Variables> ApolloPrefetch prefetch(
@Nonnull Operation<D, T, V> operation) {
return new RealApolloPrefetch(operation, serverUrl, httpCallFactory, httpCache, moshi, dispatcher, logger, callTracker);
return new RealApolloPrefetch(operation, serverUrl, httpCallFactory,
httpCache, moshi, dispatcher, logger, callTracker);
}

void clearHttpCache() {
Expand Down Expand Up @@ -312,8 +315,8 @@ public Builder logger(@Nullable Logger logger) {
* after the response source is selected (either the server, cache or both). This method can be called multiple
* times for adding multiple application interceptors. </p>
*
* <p>Note: Interceptors will be called <b>in the order in which they are added to the list of interceptors</b>
* and if any of the interceptors tries to short circuit the responses, then subsequent interceptors <b>won't</b> be
* <p>Note: Interceptors will be called <b>in the order in which they are added to the list of interceptors</b> and
* if any of the interceptors tries to short circuit the responses, then subsequent interceptors <b>won't</b> be
* called.</p>
*
* @param interceptor Application level interceptor to add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ApolloCallTracker {
private Runnable idleCallback;

private final Deque<ApolloCall> runningSyncCalls = new ArrayDeque<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why Deque can we use LinkedHashSet I guess it will be better for performance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think yeah, a LinkedHashSet makes more sense here and would give us better performance over a Deque

private final Deque<RealApolloCall<?>.AsyncCall> runningAsyncCalls = new ArrayDeque<>();
private final Deque<RealApolloCall.AsyncCall> runningAsyncCalls = new ArrayDeque<>();
private final Deque<ApolloPrefetch> runningSyncPrefetches = new ArrayDeque<>();
private final Deque<RealApolloPrefetch.AsyncCall> runningAsyncPrefetches = new ArrayDeque<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to track async and sync separately ?

Copy link
Contributor Author

@VisheshVadhera VisheshVadhera May 11, 2017

Choose a reason for hiding this comment

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

I guess so. Don't really have a strong opinion here but I felt that even though sync and async refer to the same object type, it's better to have different deques for tracking async and sync calls, just to keep concerns separate. We don't have a use case right now though wherein we only need to track all the async operations or only the sync operations.

If you feel otherwise I'll just go ahead and make the change.


Expand Down Expand Up @@ -166,9 +166,9 @@ private void executeCallBackIfCallsAreFinished(int runningCallsCount, Runnable i
* Returns a total count of in progress {@link ApolloCall} & {@link ApolloPrefetch} objects.
*/
public int getRunningCallsCount() {
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to activeCallCount()

return runningAsyncCalls.size() +
runningSyncCalls.size() +
runningSyncPrefetches.size() +
runningAsyncPrefetches.size();
return runningAsyncCalls.size()
+ runningSyncCalls.size()
+ runningSyncPrefetches.size()
+ runningAsyncPrefetches.size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
public RealApolloCall(Operation operation, HttpUrl serverUrl, Call.Factory httpCallFactory, HttpCache httpCache,
HttpCacheControl httpCacheControl, Moshi moshi, ResponseFieldMapper responseFieldMapper,
Map<ScalarType, CustomTypeAdapter> customTypeAdapters, ApolloStore apolloStore, CacheControl cacheControl,
ExecutorService dispatcher, ApolloLogger logger, List<ApolloInterceptor> applicationInterceptors, ApolloCallTracker tracker) {
ExecutorService dispatcher, ApolloLogger logger, List<ApolloInterceptor> applicationInterceptors,
ApolloCallTracker tracker) {
this.operation = operation;
this.serverUrl = serverUrl;
this.httpCallFactory = httpCallFactory;
Expand Down