Skip to content

Commit

Permalink
Merge pull request #424 from Microsoft/develop
Browse files Browse the repository at this point in the history
v0.8.0 merge
  • Loading branch information
guperrot authored May 4, 2017
2 parents 16946a2 + 0912f10 commit 673bd6c
Show file tree
Hide file tree
Showing 51 changed files with 2,638 additions and 74 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ The Mobile Center SDK uses a modular architecture so you can use any or all of t

3. **Mobile Center Distribute**: Mobile Center Distribute will let your users install a new version of the app when you distribute it via the Mobile Center. With a new version of the app available, the SDK will present an update dialog to the users to either download or postpone the new version. Once they choose to update, the SDK will start to update your application. This feature will NOT work if your app is deployed to the app store.

4. **Mobile Center Push**: Mobile Center Push enables you to send push notifications to users of your app from the Mobile Center portal. To do that the Mobile Center SDK and portal integrate with [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/).

## 1. Get started
It is super easy to use Mobile Center. Have a look at our [get started documentation](https://docs.microsoft.com/en-us/mobile-center/sdk/getting-started/android) and onboard your app within minutes. Our [detailed documentation](https://docs.microsoft.com/en-us/mobile-center/sdk/) is available as well.

Expand Down
1 change: 1 addition & 0 deletions apps/sasquatch/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
google-services.json
5 changes: 4 additions & 1 deletion apps/sasquatch/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies {
projectDependencyCompile project(':sdk:mobile-center-analytics')
projectDependencyCompile project(':sdk:mobile-center-crashes')
projectDependencyCompile project(':sdk:mobile-center-distribute')
projectDependencyCompile project(':sdk:mobile-center-push')
jcenterDependencyCompile "com.microsoft.azure.mobile:mobile-center-analytics:${version}"
jcenterDependencyCompile "com.microsoft.azure.mobile:mobile-center-crashes:${version}"
jcenterDependencyCompile "com.microsoft.azure.mobile:mobile-center-distribute:${version}"
Expand All @@ -35,4 +36,6 @@ dependencies {
androidTestCompile "com.android.support:support-annotations:${rootProject.ext.supportLibVersion}"
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
compile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2'
}
}

apply plugin: 'com.google.gms.google-services'
8 changes: 8 additions & 0 deletions apps/sasquatch/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>

<!-- Ignore the UnusedResources issue for the given ids -->
<issue id="UnusedResources">
<ignore regexp="google_crash_reporting_api_key" />
</issue>
</lint>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.microsoft.azure.mobile.MobileCenter;
import com.microsoft.azure.mobile.crashes.Crashes;
import com.microsoft.azure.mobile.crashes.CrashesPrivateHelper;
import com.microsoft.azure.mobile.crashes.model.ErrorReport;
import com.microsoft.azure.mobile.crashes.utils.ErrorLogHelper;
import com.microsoft.azure.mobile.sasquatch.R;
import com.microsoft.azure.mobile.utils.storage.StorageHelper;
Expand All @@ -30,6 +31,7 @@

import java.io.File;
import java.lang.reflect.Method;
import java.util.Date;

import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static android.support.test.espresso.Espresso.onData;
Expand All @@ -49,6 +51,11 @@
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

@SuppressWarnings("unused")
Expand Down Expand Up @@ -131,13 +138,27 @@ private void crashTest(@StringRes int titleId) throws InterruptedException {
withChild(withText(R.string.title_crashes)),
withChild(withText(R.string.description_crashes))))
.perform(click());

CrashFailureHandler failureHandler = new CrashFailureHandler();
onCrash(titleId)
.withFailureHandler(new CrashFailureHandler())
.withFailureHandler(failureHandler)
.perform(click());

/* Check error report. */
assertTrue(Crashes.hasCrashedInLastSession());
ErrorReport errorReport = CrashesPrivateHelper.getLastSessionCrashReport();
assertNotNull(errorReport);
assertNotNull(errorReport.getId());
assertEquals(mContext.getMainLooper().getThread().getName(), errorReport.getThreadName());
assertThat("AppStartTime",
new Date().getTime() - errorReport.getAppStartTime().getTime(),
lessThan(60000L));
assertThat("AppErrorTime",
new Date().getTime() - errorReport.getAppErrorTime().getTime(),
lessThan(10000L));
assertNotNull(errorReport.getDevice());
assertEquals(failureHandler.uncaughtException.getClass(), errorReport.getThrowable().getClass());
assertEquals(failureHandler.uncaughtException.getMessage(), errorReport.getThrowable().getMessage());
assertArrayEquals(failureHandler.uncaughtException.getStackTrace(), errorReport.getThrowable().getStackTrace());

/* Send report. */
waitFor(onView(withText(R.string.crash_confirmation_dialog_send_button))
Expand Down Expand Up @@ -180,14 +201,20 @@ public void describeTo(Description description) {

private class CrashFailureHandler implements FailureHandler {

Throwable uncaughtException;

@Override
public void handle(Throwable error, Matcher<View> viewMatcher) {
Throwable uncaughtException = error instanceof EspressoException ? error.getCause() : error;
uncaughtException = error instanceof EspressoException ? error.getCause() : error;

/* Save exception. */
CrashesPrivateHelper.saveUncaughtException(mContext.getMainLooper().getThread(), uncaughtException);

/* Relaunch. */
relaunchActivity();
}

private void relaunchActivity() {
ActivityCompat.finishAffinity(mActivityTestRule.getActivity());
unsetInstance(MobileCenter.class);
unsetInstance(Crashes.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.microsoft.azure.mobile.sasquatch.features;

public class PushListenerHelper {

public static void setup() {

/* Not available in jCenter yet. See project build flavour class file. */
}
}

This file was deleted.

1 change: 1 addition & 0 deletions apps/sasquatch/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<activity
android:name=".activities.ManagedErrorActivity"
android:label="@string/title_error"/>
<activity android:name=".activities.CustomPropertiesActivity"></activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.microsoft.azure.mobile.crashes;

import com.microsoft.azure.mobile.crashes.model.ErrorReport;

public final class CrashesPrivateHelper {

private CrashesPrivateHelper() {
Expand All @@ -12,4 +14,8 @@ public static void trackException(Throwable throwable) {
public static void saveUncaughtException(Thread thread, Throwable exception) {
Crashes.getInstance().saveUncaughtException(thread, exception);
}

public static ErrorReport getLastSessionCrashReport() {
return Crashes.getLastSessionCrashReport();
}
}
Loading

0 comments on commit 673bd6c

Please sign in to comment.