-
-
Notifications
You must be signed in to change notification settings - Fork 32
Dispatch better disconnect events #39
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -405,8 +405,25 @@ public void testCallbackNotifiedOnDisconnect() throws Exception { | |
parseLiveQueryClient.registerListener(callbacks); | ||
callbacks.transcript.assertNoEventsSoFar(); | ||
|
||
// Unexpected close from the server: | ||
webSocketClientCallback.onClose(); | ||
callbacks.transcript.assertEventsSoFar("onLiveQueryClientDisconnected"); | ||
callbacks.transcript.assertEventsSoFar("onLiveQueryClientDisconnected: false"); | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extra space here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whoops. Will fix |
||
@Test | ||
public void testCallbackNotifiedOnDisconnect_expected() throws Exception { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be camel case There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, ok - I've typically used Looking at the Parse-SDK-Android repo though, I see that does not appear to be the case. Will rename. |
||
LoggingCallbacks callbacks = new LoggingCallbacks(); | ||
parseLiveQueryClient.registerListener(callbacks); | ||
callbacks.transcript.assertNoEventsSoFar(); | ||
|
||
parseLiveQueryClient.disconnect(); | ||
verify(webSocketClient, times(1)).close(); | ||
|
||
callbacks.transcript.assertNoEventsSoFar(); | ||
// the client is a mock, so it won't actually invoke the callback automatically | ||
webSocketClientCallback.onClose(); | ||
callbacks.transcript.assertEventsSoFar("onLiveQueryClientDisconnected: true"); | ||
} | ||
|
||
@Test | ||
|
@@ -548,8 +565,8 @@ public void onLiveQueryClientConnected(ParseLiveQueryClient client) { | |
} | ||
|
||
@Override | ||
public void onLiveQueryClientDisconnected(ParseLiveQueryClient client) { | ||
transcript.add("onLiveQueryClientDisconnected"); | ||
public void onLiveQueryClientDisconnected(ParseLiveQueryClient client, boolean userInitiated) { | ||
transcript.add("onLiveQueryClientDisconnected: " + userInitiated); | ||
} | ||
|
||
@Override | ||
|
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.
This was otherwise being linked to the outer class at runtime, leading to a possible memory leak. The Factory and Client do not need to be tied together for any reason, so this should be declared static.