| Index: chrome/android/javatests/src/org/chromium/chrome/browser/crash/MinidumpUploadCallableTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/crash/MinidumpUploadCallableTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/crash/MinidumpUploadCallableTest.java
|
| index 8bfcb301d688aa3677869e79d3a15ee731a70120..7498fe4e54940c4792c0b3f307a2891e835cf18e 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/crash/MinidumpUploadCallableTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/crash/MinidumpUploadCallableTest.java
|
| @@ -113,19 +113,18 @@ public class MinidumpUploadCallableTest extends CrashTestCase {
|
|
|
| private static class MockCrashReportingPermissionManager
|
| implements CrashReportingPermissionManager {
|
| - private final boolean mIsPermitted;
|
| - private final boolean mIsUserPermitted;
|
| - private final boolean mIsCommandLineDisabled;
|
| - private final boolean mIsLimited;
|
| - private final boolean mIsEnabledForTests;
|
| -
|
| - MockCrashReportingPermissionManager(boolean isPermitted, boolean isUserPermitted,
|
| - boolean isCommandLineDisabled, boolean isLimited, boolean isEnabledForTests) {
|
| - mIsPermitted = isPermitted;
|
| - mIsUserPermitted = isUserPermitted;
|
| - mIsCommandLineDisabled = isCommandLineDisabled;
|
| - mIsLimited = isLimited;
|
| - mIsEnabledForTests = isEnabledForTests;
|
| + protected boolean mIsInSample;
|
| + protected boolean mIsPermitted;
|
| + protected boolean mIsUserPermitted;
|
| + protected boolean mIsCommandLineDisabled;
|
| + protected boolean mIsLimited;
|
| + protected boolean mIsEnabledForTests;
|
| +
|
| + MockCrashReportingPermissionManager() {}
|
| +
|
| + @Override
|
| + public boolean isClientInMetricsSample() {
|
| + return mIsInSample;
|
| }
|
|
|
| @Override
|
| @@ -200,7 +199,16 @@ public class MinidumpUploadCallableTest extends CrashTestCase {
|
| @Feature({"Android-AppBase"})
|
| public void testCallWhenCurrentlyPermitted() throws Exception {
|
| CrashReportingPermissionManager testPermManager =
|
| - new MockCrashReportingPermissionManager(true, true, false, false, false);
|
| + new MockCrashReportingPermissionManager() {
|
| + {
|
| + mIsInSample = true;
|
| + mIsPermitted = true;
|
| + mIsUserPermitted = true;
|
| + mIsCommandLineDisabled = false;
|
| + mIsLimited = false;
|
| + mIsEnabledForTests = false;
|
| + }
|
| + };
|
|
|
| HttpURLConnectionFactory httpURLConnectionFactory = new TestHttpURLConnectionFactory();
|
|
|
| @@ -216,7 +224,16 @@ public class MinidumpUploadCallableTest extends CrashTestCase {
|
| @Feature({"Android-AppBase"})
|
| public void testCallNotPermittedByUser() throws Exception {
|
| CrashReportingPermissionManager testPermManager =
|
| - new MockCrashReportingPermissionManager(false, false, false, false, false);
|
| + new MockCrashReportingPermissionManager() {
|
| + {
|
| + mIsInSample = true;
|
| + mIsPermitted = false;
|
| + mIsUserPermitted = false;
|
| + mIsCommandLineDisabled = false;
|
| + mIsLimited = false;
|
| + mIsEnabledForTests = false;
|
| + }
|
| + };
|
|
|
| HttpURLConnectionFactory httpURLConnectionFactory = new FailHttpURLConnectionFactory();
|
|
|
| @@ -231,7 +248,16 @@ public class MinidumpUploadCallableTest extends CrashTestCase {
|
| @Feature({"Android-AppBase"})
|
| public void testCallNotPermittedByCommandLine() throws Exception {
|
| CrashReportingPermissionManager testPermManager =
|
| - new MockCrashReportingPermissionManager(true, true, true, false, false);
|
| + new MockCrashReportingPermissionManager() {
|
| + {
|
| + mIsInSample = true;
|
| + mIsPermitted = true;
|
| + mIsUserPermitted = true;
|
| + mIsCommandLineDisabled = true;
|
| + mIsLimited = false;
|
| + mIsEnabledForTests = false;
|
| + }
|
| + };
|
|
|
| HttpURLConnectionFactory httpURLConnectionFactory = new FailHttpURLConnectionFactory();
|
|
|
| @@ -244,9 +270,42 @@ public class MinidumpUploadCallableTest extends CrashTestCase {
|
|
|
| @SmallTest
|
| @Feature({"Android-AppBase"})
|
| + public void testCallPermittedButNotInSample() throws Exception {
|
| + CrashReportingPermissionManager testPermManager =
|
| + new MockCrashReportingPermissionManager() {
|
| + {
|
| + mIsInSample = false;
|
| + mIsPermitted = true;
|
| + mIsUserPermitted = true;
|
| + mIsCommandLineDisabled = false;
|
| + mIsLimited = false;
|
| + mIsEnabledForTests = false;
|
| + }
|
| + };
|
| +
|
| + HttpURLConnectionFactory httpURLConnectionFactory = new TestHttpURLConnectionFactory();
|
| +
|
| + MinidumpUploadCallable minidumpUploadCallable =
|
| + new MockMinidumpUploadCallable(httpURLConnectionFactory, testPermManager);
|
| + assertEquals(MinidumpUploadCallable.UPLOAD_DISABLED_BY_SAMPLING,
|
| + minidumpUploadCallable.call().intValue());
|
| + assertTrue(mExpectedFileAfterUpload.exists());
|
| + }
|
| +
|
| + @SmallTest
|
| + @Feature({"Android-AppBase"})
|
| public void testCallPermittedButNotUnderCurrentCircumstances() throws Exception {
|
| CrashReportingPermissionManager testPermManager =
|
| - new MockCrashReportingPermissionManager(false, true, false, false, false);
|
| + new MockCrashReportingPermissionManager() {
|
| + {
|
| + mIsInSample = true;
|
| + mIsPermitted = false;
|
| + mIsUserPermitted = true;
|
| + mIsCommandLineDisabled = false;
|
| + mIsLimited = false;
|
| + mIsEnabledForTests = false;
|
| + }
|
| + };
|
|
|
| HttpURLConnectionFactory httpURLConnectionFactory = new FailHttpURLConnectionFactory();
|
|
|
| @@ -261,7 +320,16 @@ public class MinidumpUploadCallableTest extends CrashTestCase {
|
| @Feature({"Android-AppBase"})
|
| public void testCrashUploadConstrainted() throws Exception {
|
| CrashReportingPermissionManager testPermManager =
|
| - new MockCrashReportingPermissionManager(true, true, false, true, false);
|
| + new MockCrashReportingPermissionManager() {
|
| + {
|
| + mIsInSample = true;
|
| + mIsPermitted = true;
|
| + mIsUserPermitted = true;
|
| + mIsCommandLineDisabled = false;
|
| + mIsLimited = true;
|
| + mIsEnabledForTests = false;
|
| + }
|
| + };
|
|
|
| HttpURLConnectionFactory httpURLConnectionFactory = new TestHttpURLConnectionFactory();
|
|
|
| @@ -276,7 +344,16 @@ public class MinidumpUploadCallableTest extends CrashTestCase {
|
| @Feature({"Android-AppBase"})
|
| public void testCrashUploadEnabledForTestsDespiteConstraints() throws Exception {
|
| CrashReportingPermissionManager testPermManager =
|
| - new MockCrashReportingPermissionManager(false, false, false, true, true);
|
| + new MockCrashReportingPermissionManager() {
|
| + {
|
| + mIsInSample = true;
|
| + mIsPermitted = false;
|
| + mIsUserPermitted = false;
|
| + mIsCommandLineDisabled = false;
|
| + mIsLimited = true;
|
| + mIsEnabledForTests = true;
|
| + }
|
| + };
|
|
|
| HttpURLConnectionFactory httpURLConnectionFactory = new TestHttpURLConnectionFactory();
|
|
|
|
|