diff --git a/app/build.gradle b/app/build.gradle index fda16632a..492781a29 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -67,6 +67,7 @@ dependencies { compile 'com.jakewharton:butterknife:7.0.1' compile 'com.jakewharton.timber:timber:3.1.0' compile 'uk.co.ribot:easyadapter:1.5.0@aar' + compile 'ch.acra:acra:4.6.2' compile "com.google.dagger:dagger:$DAGGER_VERSION" apt "com.google.dagger:dagger-compiler:$DAGGER_VERSION" diff --git a/app/src/main/java/eu/kanade/mangafeed/App.java b/app/src/main/java/eu/kanade/mangafeed/App.java index 60fcbd186..2b67fd6a5 100644 --- a/app/src/main/java/eu/kanade/mangafeed/App.java +++ b/app/src/main/java/eu/kanade/mangafeed/App.java @@ -3,8 +3,19 @@ package eu.kanade.mangafeed; import android.app.Application; import android.content.Context; +import org.acra.ACRA; +import org.acra.ReportingInteractionMode; +import org.acra.annotation.ReportsCrashes; + import timber.log.Timber; +@ReportsCrashes( + formUri = "http://couch.kanade.eu/acra-manga/_design/acra-storage/_update/report", + reportType = org.acra.sender.HttpSender.Type.JSON, + httpMethod = org.acra.sender.HttpSender.Method.PUT, + formUriBasicAuthLogin="test", + formUriBasicAuthPassword="test" +) public class App extends Application { AppComponent mApplicationComponent; @@ -17,6 +28,8 @@ public class App extends Application { mApplicationComponent = DaggerAppComponent.builder() .appModule(new AppModule(this)) .build(); + + ACRA.init(this); } public static App get(Context context) { diff --git a/app/src/test/java/eu/kanade/mangafeed/LibraryFragmentTest.java b/app/src/test/java/eu/kanade/mangafeed/LibraryFragmentTest.java new file mode 100644 index 000000000..456734381 --- /dev/null +++ b/app/src/test/java/eu/kanade/mangafeed/LibraryFragmentTest.java @@ -0,0 +1,31 @@ +package eu.kanade.mangafeed; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricGradleTestRunner; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; + + +import static org.robolectric.util.FragmentTestUtil.startFragment; +import static org.junit.Assert.assertNotNull; + +import eu.kanade.mangafeed.BuildConfig; +import eu.kanade.mangafeed.ui.fragment.LibraryFragment; +import eu.kanade.mangafeed.util.DefaultConfig; + +/** + * Created by len on 1/10/15. + */ + +@RunWith(RobolectricGradleTestRunner.class) +@Config(constants = BuildConfig.class, sdk = DefaultConfig.EMULATE_SDK) +public class LibraryFragmentTest { + + @Test + public void mangaList_shouldNotBeEmpty() { + LibraryFragment fragment = LibraryFragment.newInstance(); + startFragment(fragment); + assertNotNull(fragment); + } +} diff --git a/app/src/test/java/eu/kanade/mangafeed/MainActivityTest.java b/app/src/test/java/eu/kanade/mangafeed/MainActivityTest.java new file mode 100644 index 000000000..d24bb2dba --- /dev/null +++ b/app/src/test/java/eu/kanade/mangafeed/MainActivityTest.java @@ -0,0 +1,40 @@ +package eu.kanade.mangafeed; + +/** + * Created by len on 1/10/15. + */ +import android.os.Build; +import android.support.v7.widget.Toolbar; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.Robolectric; +import org.robolectric.RobolectricGradleTestRunner; +import org.robolectric.annotation.Config; + +import eu.kanade.mangafeed.ui.activity.MainActivity; + +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertTrue; + +@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP) +@RunWith(RobolectricGradleTestRunner.class) +public class MainActivityTest { + private MainActivity activity; + + // @Before => JUnit 4 annotation that specifies this method should run before each test is run + // Useful to do setup for objects that are needed in the test + @Before + public void setup() { + // Convenience method to run MainActivity through the Activity Lifecycle methods: + // onCreate(...) => onStart() => onPostCreate(...) => onResume() + activity = Robolectric.setupActivity(MainActivity.class); + } + + @Test + public void validate() { + Toolbar toolbar = (Toolbar)activity.findViewById(R.id.toolbar); + assertNotNull(toolbar); + } +} diff --git a/app/src/test/java/eu/kanade/mangafeed/UseModule.java b/app/src/test/java/eu/kanade/mangafeed/UseModule.java new file mode 100644 index 000000000..384911708 --- /dev/null +++ b/app/src/test/java/eu/kanade/mangafeed/UseModule.java @@ -0,0 +1,16 @@ +package eu.kanade.mangafeed; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Created by len on 1/10/15. + */ + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface UseModule { + Class value(); +} \ No newline at end of file