-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #67
- Loading branch information
Showing
26 changed files
with
787 additions
and
118 deletions.
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
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
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
37 changes: 37 additions & 0 deletions
37
skygear/src/androidTest/java/io/skygear/skygear/RegisterDeviceRequestUnitTest.java
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,37 @@ | ||
package io.skygear.skygear; | ||
|
||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.Map; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class RegisterDeviceRequestUnitTest { | ||
@Test | ||
public void testRegisterDeviceRequestCreateFlow1() throws Exception { | ||
RegisterDeviceRequest request = new RegisterDeviceRequest(); | ||
|
||
assertEquals("device:register", request.action); | ||
|
||
Map<String, Object> data = request.data; | ||
assertEquals("android", data.get("type")); | ||
assertNull(data.get("id")); | ||
assertNull(data.get("device_token")); | ||
} | ||
|
||
@Test | ||
public void testRegisterDeviceRequestCreateFlow2() throws Exception { | ||
RegisterDeviceRequest request = new RegisterDeviceRequest("testing-device", "testing-token"); | ||
|
||
assertEquals("device:register", request.action); | ||
|
||
Map<String, Object> data = request.data; | ||
assertEquals("android", data.get("type")); | ||
assertEquals("testing-device", data.get("id")); | ||
assertEquals("testing-token", data.get("device_token")); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
skygear/src/androidTest/java/io/skygear/skygear/RegisterDeviceResponseHandlerUnitTest.java
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,55 @@ | ||
package io.skygear.skygear; | ||
|
||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.json.JSONObject; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class RegisterDeviceResponseHandlerUnitTest { | ||
@Test | ||
public void testRegisterDeviceResponseHandlerSuccessFlow() throws Exception { | ||
JSONObject result = new JSONObject(); | ||
result.put("id", "test-device-id"); | ||
|
||
final boolean[] checkpoints = new boolean[] { false }; | ||
RegisterDeviceResponseHandler handler = new RegisterDeviceResponseHandler() { | ||
@Override | ||
public void onRegisterSuccess(String deviceId) { | ||
assertEquals("test-device-id", deviceId); | ||
checkpoints[0] = true; | ||
} | ||
|
||
@Override | ||
public void onRegisterError(Error error) { | ||
fail("Should not get fail callback"); | ||
} | ||
}; | ||
|
||
handler.onSuccess(result); | ||
assertTrue(checkpoints[0]); | ||
} | ||
|
||
@Test | ||
public void testRegisterDeviceResponseHandlerFailFlow() throws Exception { | ||
final boolean[] checkpoints = new boolean[] { false }; | ||
RegisterDeviceResponseHandler handler = new RegisterDeviceResponseHandler() { | ||
@Override | ||
public void onRegisterSuccess(String deviceId) { | ||
fail("Should not get success callback"); | ||
} | ||
|
||
@Override | ||
public void onRegisterError(Error error) { | ||
assertEquals("Test error", error.getMessage()); | ||
checkpoints[0] = true; | ||
} | ||
}; | ||
|
||
handler.onFail(new Error("Test error")); | ||
assertTrue(checkpoints[0]); | ||
} | ||
} |
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
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.