-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,787 additions
and
653 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
sdk/src/androidTest/java/com/bugsnag/android/AppDataSummaryTest.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,91 @@ | ||
package com.bugsnag.android; | ||
|
||
import static com.bugsnag.android.BugsnagTestUtils.generateClient; | ||
import static com.bugsnag.android.BugsnagTestUtils.streamableToJson; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNull; | ||
|
||
import android.support.test.filters.SmallTest; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.io.IOException; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
@SmallTest | ||
public class AppDataSummaryTest { | ||
|
||
private AppDataSummary appData; | ||
|
||
/** | ||
* Configures a new AppDataSummary for testing accessors + serialisation | ||
* | ||
* @throws Exception if setup failed | ||
*/ | ||
@Before | ||
public void setUp() throws Exception { | ||
AppDataCollector appDataCollector = new AppDataCollector(generateClient()); | ||
appData = appDataCollector.generateAppDataSummary(); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
Async.cancelTasks(); | ||
} | ||
|
||
@Test | ||
public void testVersionCode() { | ||
assertEquals(Integer.valueOf(1), appData.getVersionCode()); | ||
int expected = 15; | ||
appData.setVersionCode(expected); | ||
assertEquals(Integer.valueOf(expected), appData.getVersionCode()); | ||
} | ||
|
||
@Test | ||
public void testVersionName() { | ||
assertEquals("1.0", appData.getVersionName()); | ||
String expected = "1.2.3"; | ||
appData.setVersionName(expected); | ||
assertEquals(expected, appData.getVersionName()); | ||
} | ||
|
||
@Test | ||
public void testReleaseStage() { | ||
assertEquals("development", appData.getReleaseStage()); | ||
String expected = "beta"; | ||
appData.setReleaseStage(expected); | ||
assertEquals(expected, appData.getReleaseStage()); | ||
} | ||
|
||
@Test | ||
public void testNotifierType() { | ||
assertEquals("android", appData.getNotifierType()); | ||
String expected = "custom"; | ||
appData.setNotifierType(expected); | ||
assertEquals(expected, appData.getNotifierType()); | ||
} | ||
|
||
@Test | ||
public void testCodeBundleId() { | ||
assertNull(appData.getCodeBundleId()); | ||
String expected = "123"; | ||
appData.setCodeBundleId(expected); | ||
assertEquals(expected, appData.getCodeBundleId()); | ||
} | ||
|
||
@Test | ||
public void testJsonSerialisation() throws IOException, JSONException { | ||
JSONObject appDataJson = streamableToJson(appData); | ||
assertEquals(1, appDataJson.getInt("versionCode")); | ||
assertEquals("1.0", appDataJson.get("version")); | ||
assertEquals("development", appDataJson.get("releaseStage")); | ||
assertEquals("android", appDataJson.get("type")); | ||
} | ||
|
||
} |
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.