Skip to content

Commit

Permalink
Merge pull request #354 from bugsnag/next
Browse files Browse the repository at this point in the history
v4.6.0
  • Loading branch information
fractalwrench authored Aug 2, 2018
2 parents 7f47131 + 22bd56d commit 0390356
Show file tree
Hide file tree
Showing 97 changed files with 1,470 additions and 796 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ proguard/

# Javadoc
docs/
infer-out/
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 4.6.0 (2018-08-02)

* Android P compatibility fixes - ensure available information on StrictMode violations is collected [#350](https://github.com/bugsnag/bugsnag-android/pull/350)

* Disable BuildConfig generation [#343](https://github.com/bugsnag/bugsnag-android/pull/343)

* Add consumer proguard rules for automatic ProGuard configuration without the Bugsnag gradle plugin [#345](https://github.com/bugsnag/bugsnag-android/pull/345)

* Internal refactor of app/device data serialisation

## 4.5.0 (2018-06-18)

This release alters the behaviour of the notifier to track sessions automatically.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build status](https://travis-ci.org/bugsnag/bugsnag-android.svg?branch=master)](https://travis-ci.org/bugsnag/bugsnag-android)
[![Coverage Status](https://coveralls.io/repos/github/bugsnag/bugsnag-android/badge.svg?branch=master)](https://coveralls.io/github/bugsnag/bugsnag-android?branch=master)
<!-- Auto-generated line below: -->
![Method count and size](https://img.shields.io/badge/Methods%20and%20size-79%20classes%20|%20630%20methods%20|%20312%20fields%20|%20112%20KB-e91e63.svg)
![Method count and size](https://img.shields.io/badge/Methods%20and%20size-78%20classes%20|%20635%20methods%20|%20312%20fields%20|%20112%20KB-e91e63.svg)

Get comprehensive [Android crash reports](https://www.bugsnag.com/platforms/android/) to quickly debug errors.

Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ buildscript {
google()
jcenter()
}
ext.kotlin_version = '1.2.30'

dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
Expand Down
3 changes: 1 addition & 2 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ buildscript {
}
dependencies {
classpath 'com.bugsnag:bugsnag-android-gradle-plugin:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$project.KOTLIN_VERSION"
}
}

Expand Down Expand Up @@ -90,7 +89,7 @@ dependencies {
implementation project(":sdk")
implementation "com.android.support:appcompat-v7:$supportLibVersion"
implementation "com.android.support:support-v4:$supportLibVersion"
kotlinExampleImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$project.KOTLIN_VERSION"
kotlinExampleImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

androidTestImplementation "com.android.support.test:runner:$supportTestVersion", {
exclude group: 'com.android.support', module: 'support-annotations'
Expand Down
2 changes: 1 addition & 1 deletion example/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<application
android:name=".ExampleApplication"
android:icon="@drawable/ic_launcher"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
<activity
android:name=".ExampleActivity"
Expand Down
Binary file added example/src/main/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed example/src/main/res/drawable-xhdpi/ic_launcher.png
Binary file not shown.
13 changes: 10 additions & 3 deletions example/src/main/res/drawable/ic_bugsnag_svg.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<vector android:height="24dp" android:viewportHeight="45.0"
android:viewportWidth="230.9" android:width="120dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFFFF" android:pathData="M79.6,23.1c0,7 -4.9,12.4 -11.3,12.4 -2.7,0.1 -5.3,-1.1 -7,-3.2v2.6h-6.2L55.1,0h6.3v13.9c1.7,-2 4.2,-3.2 6.9,-3.1 6.4,0 11.3,5.3 11.3,12.3zM61.1,23.1c0,3.7 2.4,6.5 6,6.5s6.1,-2.9 6.1,-6.5 -2.3,-6.5 -6.1,-6.5 -6,2.8 -6,6.5zM103.9,24.9c0,7.4 -5.2,10.6 -11.1,10.6s-11.1,-3.2 -11.1,-10.6L81.7,11.4L88,11.4v12.9c0,3.8 2.1,5.3 4.8,5.3s4.8,-1.5 4.8,-5.3L97.6,11.4h6.3v13.5zM124,14v-2.6h6.2v21.5c0,7.5 -4.9,12.1 -12.7,12.1 -3.6,0.1 -7.2,-0.9 -10.3,-2.8l2.3,-5.2c2.3,1.6 5,2.4 7.8,2.4 3.9,0 6.7,-2.2 6.7,-6.2v-1.6c-1.8,2.1 -4.4,3.3 -7.2,3.2 -5.7,0 -10.8,-4.8 -10.8,-12s5.1,-12 10.8,-12c2.8,-0.2 5.4,1 7.2,3.2zM112.4,22.7c-0.1,3.3 2.4,6 5.7,6.1 3.3,0.1 6,-2.4 6.1,-5.7v-0.5c0,-3.5 -2.4,-6.2 -5.9,-6.2 -3.2,0 -5.9,2.5 -5.9,5.8v0.5zM150.8,17.9c-2.3,-1.1 -4.9,-1.8 -7.5,-1.9 -2.4,0 -3.6,0.9 -3.6,2.1s1.7,1.7 3.8,2l2.1,0.3c5.1,0.8 7.9,3 7.9,7 0,4.8 -4,8 -10.8,8 -3.2,0 -7.4,-0.6 -10.4,-2.8l2.5,-4.8c2.4,1.6 5.2,2.4 8,2.3 2.9,0 4.3,-0.8 4.3,-2.2 0,-1.1 -1.2,-1.8 -3.9,-2.1l-1.9,-0.3c-5.4,-0.8 -8.1,-3.1 -8.1,-7.1 0,-4.8 3.7,-7.7 9.9,-7.7 3.4,-0.1 6.8,0.7 9.8,2.2l-2.1,5zM177.8,19.9v14.9h-6.3L171.5,22c0,-3.4 -1.7,-5.2 -4.6,-5.2 -2.7,0 -5,1.8 -5,5.3v12.8h-6.3L155.6,11.4h6.1v2.8c1.6,-2.3 4.2,-3.5 6.9,-3.4 4.8,-0.2 8.9,3.5 9.2,8.3v0.8zM204.4,34.9h-6.2v-2.6c-1.7,2.1 -4.3,3.3 -7,3.2 -6.5,0 -11.4,-5.3 -11.4,-12.4s4.9,-12.4 11.4,-12.4c2.7,-0.1 5.3,1.1 7,3.2v-2.6h6.2v23.6zM186.3,23.1c0,3.6 2.4,6.5 6.1,6.5s6.1,-2.8 6.1,-6.5 -2.4,-6.5 -6.1,-6.5 -6.1,2.9 -6.1,6.5zM224.7,14v-2.6h6.2v21.5c0,7.5 -4.9,12.1 -12.7,12.1 -3.6,0.1 -7.2,-0.9 -10.3,-2.8l2.2,-5.2c2.3,1.6 5,2.4 7.8,2.4 3.9,0 6.7,-2.2 6.7,-6.2v-1.6c-1.8,2.1 -4.4,3.3 -7.2,3.2 -5.7,0 -10.8,-4.8 -10.8,-12s5.1,-12 10.8,-12c2.9,-0.2 5.6,1 7.3,3.2zM213.1,22.7c-0.1,3.3 2.4,6 5.7,6.1 3.3,0.1 6,-2.4 6.1,-5.7v-0.5c0,-3.5 -2.4,-6.2 -5.9,-6.2 -3.2,-0.1 -5.9,2.5 -5.9,5.7v0.6zM28.8,34.9h-8.9c0,-7.6 -3.4,-14.9 -9.2,-19.9l5.7,-6.7c7.9,6.7 12.4,16.4 12.4,26.6zM23.8,13.1c4.6,6.3 7.2,14 7.1,21.9h8.8c0,-9.7 -3.1,-19.2 -8.9,-27.1l-7,5.2zM0,21.1c5.5,2.4 9,7.8 9,13.8h8.9c0,-9.5 -5.6,-18.1 -14.2,-21.9L0,21.1z"/>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="2000dp"
android:height="800dp"
android:viewportWidth="2000"
android:viewportHeight="800">

<path
android:fillColor="#FFFFFF"
android:pathData="M1208.3,274.2c-51,1.5-91,44.7-91,95.8v116.6c0,2.8,2.2,5,5,5h28.3c2.8,0,5-2.2,5-5v-117 c0-30,22.9-55.7,52.8-57.1c30.7-1.5,56.8,22.1,58.3,52.8c0,0.9,0.1,1.8,0.1,2.8v118.6c0,2.8,2.2,5,5,5h28.3c2.8,0,5-2.2,5-5V368 c-0.1-51.9-42.2-93.9-94.1-93.9C1210,274.1,1209.1,274.1,1208.3,274.2z M1446.8,275.2c-59.9-2.7-110.6,43.7-113.3,103.6 c-2.7,59.9,43.7,110.6,103.6,113.3c27.5,1.2,54.4-8,75.3-25.8v20.2c0,2.8,2.2,5,5,5h28.3c2.8,0,5-2.2,5-5V385.9 C1550.6,327.4,1505.2,277.7,1446.8,275.2z M1442.1,454c-38.8,0-70.3-31.5-70.4-70.3c0-38.8,31.5-70.3,70.3-70.4 c38.8,0,70.3,31.5,70.4,70.3c0,0,0,0,0,0C1512.3,422.5,1480.9,453.9,1442.1,454z M1696.1,275.2c-59.9-2.7-110.6,43.7-113.3,103.6 c-2.7,59.9,43.7,110.6,103.6,113.3c27.5,1.2,54.4-8,75.3-25.8v42.9c0,39.4-32.3,72.9-71.7,72.2c-22.3-0.4-43.1-11.4-56-29.6 c-1.5-2.1-4.4-2.7-6.6-1.3l-24,14.9c-2.4,1.5-3.1,4.6-1.6,6.9c0,0.1,0.1,0.1,0.1,0.2c19.7,29,52.3,46.5,87.4,47.1 c60.9,1.2,110.7-49.9,110.7-110.7V386C1799.9,327.4,1754.5,277.7,1696.1,275.2z M1691.4,454c-38.8,0-70.3-31.5-70.3-70.3 c0-38.8,31.5-70.3,70.3-70.3c38.8,0,70.3,31.5,70.3,70.3c0,0,0,0,0,0C1761.7,422.5,1730.2,453.9,1691.4,454z M784.9,275.2 C725,272.6,674.3,319,671.6,378.8s43.7,110.6,103.6,113.3c27.5,1.2,54.3-8,75.3-25.8v42.9c0,39.4-32.3,73-71.7,72.2 c-22.3-0.4-43.1-11.4-56-29.6c-1.5-2.1-4.4-2.7-6.6-1.3l-24,14.9c-2.4,1.5-3.1,4.6-1.6,6.9c0,0.1,0.1,0.1,0.1,0.2 c19.7,28.9,52.2,46.5,87.2,47.1c60.9,1.2,110.7-49.9,110.7-110.7V386C888.7,327.4,843.4,277.7,784.9,275.2z M780.2,454 c-38.8,0-70.3-31.5-70.3-70.3c0-38.8,31.5-70.3,70.3-70.3c38.8,0,70.3,31.5,70.3,70.3c0,0,0,0,0,0C850.5,422.5,819,453.9,780.2,454z M631.2,276.6l-28.3,0.4c-2.7,0-4.9,2.2-4.9,4.9v112.8c0,30.7-25,55.6-55.7,55.6c-0.9,0-1.8,0-2.7-0.1 c-29.9-1.5-52.8-27.2-52.8-57.1V282.1c0-2.8-2.2-5-5-5l0,0h-28.3c-2.8,0-5,2.2-5,5v110.7c0,51,40,94.3,91,95.8 c51.9,1.5,95.1-39.4,96.6-91.3c0-0.8,0-1.7,0-2.5V281.6C636.2,278.8,634,276.6,631.2,276.6C631.2,276.6,631.2,276.6,631.2,276.6z M1010.3,365.4c-27.7-7.7-44.5-13.4-44.5-28.4c0-21.7,23.7-29.6,39.7-29.6c18.2,0,29.2,4.2,43.5,13c2.3,1.4,5.3,0.7,6.8-1.6 l13.1-20.4c1.5-2.3,0.8-5.4-1.5-6.9c-0.1,0-0.1-0.1-0.2-0.1c-19-11.5-40.8-17.5-63.1-17.5c-36,0-73.1,23.7-73.1,63.4 c0,40.5,36,50.2,67.7,58.8c30,8.1,48.2,14.4,48.2,33.3c0,17.4-17.8,30.5-41.5,30.5c-22.8,0-41.4-10.3-54-20 c-2.1-1.7-5.2-1.3-6.9,0.8l-15.6,19c-1.7,2.1-1.4,5.3,0.7,7c20.5,17.2,47.8,26.6,77.4,26.6c43.1,0,74.4-27.4,74.4-65.1 C1081.6,385.3,1042,374.3,1010.3,365.4z M321.3,275.8c-30-3.5-60.1,5.6-83,25.2V185.3c0-2.8-2.2-5-5-5c-0.9,0-1.8,0.3-2.6,0.7 l-28.3,17.2c-1.5,0.9-2.4,2.5-2.4,4.3v178.9c0,58.5,45.4,108.2,103.8,110.7c59.9,2.5,110.5-44,113.1-103.9 C419.3,331.5,377.6,282.6,321.3,275.8z M308.6,454c-38.8,0-70.3-31.5-70.3-70.3s31.5-70.3,70.3-70.3s70.3,31.5,70.3,70.3 C378.8,422.5,347.4,453.9,308.6,454z" />
</vector>
5 changes: 5 additions & 0 deletions example/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
5 changes: 5 additions & 0 deletions example/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file added example/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions example/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#313139</color>
<color name="colorPrimaryDark">#212129</color>
<color name="colorAccent">#336ba4</color>
<color name="headingColor">#071c3b</color>
<color name="colorPrimary">#010E44</color>
<color name="colorPrimaryDark">#20212C</color>
<color name="colorAccent">#5BB6CB</color>
<color name="headingColor">#010E44</color>
</resources>
4 changes: 4 additions & 0 deletions example/src/main/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#010E44</color>
</resources>
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
VERSION_NAME=4.5.0
VERSION_NAME=4.6.0
GROUP=com.bugsnag
POM_SCM_URL=https://github.com/bugsnag/bugsnag-android
POM_SCM_CONNECTION=scm:[email protected]:bugsnag/bugsnag-android.git
Expand Down
3 changes: 3 additions & 0 deletions infer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
./gradlew clean && infer --disable-issue-type "NULL_DEREFERENCE" \
--disable-issue-type "RESOURCE_LEAK" -- ./gradlew sdk:build
10 changes: 0 additions & 10 deletions mazerunner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@ repositories {
jcenter()
}

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$project.KOTLIN_VERSION"
}
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

Expand Down
18 changes: 18 additions & 0 deletions sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'kotlin-android'

repositories {
google()
Expand All @@ -16,6 +17,7 @@ android {
defaultConfig {
minSdkVersion Integer.parseInt(project.ANDROID_MIN_SDK_VERSION)
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'proguard-rules.pro'
}

buildTypes {
Expand All @@ -29,13 +31,27 @@ android {
warningsAsErrors true
checkAllWarnings true
}

// TODO replace with https://issuetracker.google.com/issues/72050365 once released.
libraryVariants.all {
it.generateBuildConfig.enabled = false
}
}

gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:all" << "-Werror"
}
}

coveralls {
jacocoReportPath = "$buildDir/reports/coverage/debug/report.xml"
}
dependencies {
api "com.android.support:support-annotations:$supportLibVersion"

androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

testImplementation "junit:junit:$junitVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"

Expand All @@ -49,6 +65,7 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
}

compile "com.facebook.infer.annotation:infer-annotation:0.11.2"
}

// Disable doclint:
Expand Down Expand Up @@ -160,3 +177,4 @@ dexcount {
orderByMethodCount = true
verbose true
}

32 changes: 7 additions & 25 deletions sdk/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/jamielynch/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-keepattributes LineNumberTable,SourceFile
-keep class com.bugsnag.android.NativeInterface { *; }
-keep class com.bugsnag.android.Breadcrumb { *; }
-keep class com.bugsnag.android.Breadcrumbs { *; }
-keep class com.bugsnag.android.BreadcrumbType { *; }
-keep class com.bugsnag.android.Severity { *; }
-keep class com.bugsnag.android.ndk.BugsnagObserver { *; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.bugsnag.android;

import static com.bugsnag.android.BugsnagTestUtils.generateClient;
import static com.bugsnag.android.BugsnagTestUtils.mapToJson;
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;
import java.util.Map;

@RunWith(AndroidJUnit4.class)
@SmallTest
public class AppDataSummaryTest {

private Map<String, Object> appData;

/**
* Configures a new AppDataSummary for testing accessors + serialisation
*
* @throws Exception if setup failed
*/
@Before
public void setUp() throws Exception {
AppData appData = new AppData(generateClient());
this.appData = appData.getAppDataSummary();
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testVersionCode() {
assertEquals(1, appData.get("versionCode"));
}

@Test
public void testVersionName() {
assertEquals("1.0", appData.get("version"));
}

@Test
public void testReleaseStage() {
assertEquals("development", appData.get("releaseStage"));
}

@Test
public void testNotifierType() {
assertEquals("android", appData.get("type"));
}

@Test
public void testCodeBundleId() {
assertNull(appData.get("codeBundleId"));
}

@Test
public void testJsonSerialisation() throws JSONException {
JSONObject appDataJson = mapToJson(appData);
assertEquals(1, appDataJson.getInt("versionCode"));
assertEquals("1.0", appDataJson.get("version"));
assertEquals("development", appDataJson.get("releaseStage"));
assertEquals("android", appDataJson.get("type"));
}

}
Loading

0 comments on commit 0390356

Please sign in to comment.