Bläddra i källkod

Send crash reports

inorichi 9 år sedan
förälder
incheckning
c3b65d286f

+ 1 - 0
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"

+ 13 - 0
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) {

+ 31 - 0
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);
+    }
+}

+ 40 - 0
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);
+    }
+}

+ 16 - 0
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();
+}