Loading services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupReporter.java +1 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ import java.util.List; public class KeyValueBackupReporter { @VisibleForTesting static final String TAG = "KeyValueBackupTask"; private static final boolean DEBUG = BackupManagerService.DEBUG; @VisibleForTesting static final boolean MORE_DEBUG = BackupManagerService.MORE_DEBUG || true; @VisibleForTesting static final boolean MORE_DEBUG = BackupManagerService.MORE_DEBUG || false; static void onNewThread(String threadName) { if (DEBUG) { Loading services/robotests/src/com/android/server/backup/BackupManagerServiceTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,13 @@ public class BackupManagerServiceTest { ShadowAppBackupUtils.reset(); } @Test public void testMoreDebug_isFalse() throws Exception { boolean moreDebug = BackupManagerService.MORE_DEBUG; assertThat(moreDebug).isFalse(); } /* Tests for destination string */ @Test Loading services/robotests/src/com/android/server/backup/keyvalue/KeyValueBackupReporterTest.java +7 −35 Original line number Diff line number Diff line Loading @@ -61,6 +61,13 @@ public class KeyValueBackupReporterTest { mReporter = new KeyValueBackupReporter(mBackupManagerService, mObserver, mMonitor); } @Test public void testMoreDebug_isFalse() throws Exception { boolean moreDebug = KeyValueBackupReporter.MORE_DEBUG; assertThat(moreDebug).isFalse(); } @Test public void testOnNewThread_logsCorrectly() throws Exception { KeyValueBackupReporter.onNewThread("foo"); Loading @@ -81,39 +88,4 @@ public class KeyValueBackupReporterTest { assertThat(observer).isEqualTo(mObserver); } @Test public void testOnRevertTask_logsCorrectly() throws Exception { setMoreDebug(true); mReporter.onRevertTask(); assertLogcat(TAG, Log.INFO); } @Test public void testOnRemoteCallReturned_logsCorrectly() throws Exception { setMoreDebug(true); mReporter.onRemoteCallReturned(RemoteResult.of(3), "onFoo()"); assertLogcat(TAG, Log.VERBOSE); ShadowLog.LogItem log = ShadowLog.getLogsForTag(TAG).get(0); assertThat(log.msg).contains("onFoo()"); assertThat(log.msg).contains("3"); } /** * HACK: We actually want {@link KeyValueBackupReporter#MORE_DEBUG} to be a constant to be able * to strip those lines at build time. So, we have to do this to test :( */ private static void setMoreDebug(boolean value) throws NoSuchFieldException, IllegalAccessException { if (KeyValueBackupReporter.MORE_DEBUG == value) { return; } Field moreDebugField = KeyValueBackupReporter.class.getDeclaredField("MORE_DEBUG"); moreDebugField.setAccessible(true); moreDebugField.set(null, value); } } Loading
services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupReporter.java +1 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ import java.util.List; public class KeyValueBackupReporter { @VisibleForTesting static final String TAG = "KeyValueBackupTask"; private static final boolean DEBUG = BackupManagerService.DEBUG; @VisibleForTesting static final boolean MORE_DEBUG = BackupManagerService.MORE_DEBUG || true; @VisibleForTesting static final boolean MORE_DEBUG = BackupManagerService.MORE_DEBUG || false; static void onNewThread(String threadName) { if (DEBUG) { Loading
services/robotests/src/com/android/server/backup/BackupManagerServiceTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,13 @@ public class BackupManagerServiceTest { ShadowAppBackupUtils.reset(); } @Test public void testMoreDebug_isFalse() throws Exception { boolean moreDebug = BackupManagerService.MORE_DEBUG; assertThat(moreDebug).isFalse(); } /* Tests for destination string */ @Test Loading
services/robotests/src/com/android/server/backup/keyvalue/KeyValueBackupReporterTest.java +7 −35 Original line number Diff line number Diff line Loading @@ -61,6 +61,13 @@ public class KeyValueBackupReporterTest { mReporter = new KeyValueBackupReporter(mBackupManagerService, mObserver, mMonitor); } @Test public void testMoreDebug_isFalse() throws Exception { boolean moreDebug = KeyValueBackupReporter.MORE_DEBUG; assertThat(moreDebug).isFalse(); } @Test public void testOnNewThread_logsCorrectly() throws Exception { KeyValueBackupReporter.onNewThread("foo"); Loading @@ -81,39 +88,4 @@ public class KeyValueBackupReporterTest { assertThat(observer).isEqualTo(mObserver); } @Test public void testOnRevertTask_logsCorrectly() throws Exception { setMoreDebug(true); mReporter.onRevertTask(); assertLogcat(TAG, Log.INFO); } @Test public void testOnRemoteCallReturned_logsCorrectly() throws Exception { setMoreDebug(true); mReporter.onRemoteCallReturned(RemoteResult.of(3), "onFoo()"); assertLogcat(TAG, Log.VERBOSE); ShadowLog.LogItem log = ShadowLog.getLogsForTag(TAG).get(0); assertThat(log.msg).contains("onFoo()"); assertThat(log.msg).contains("3"); } /** * HACK: We actually want {@link KeyValueBackupReporter#MORE_DEBUG} to be a constant to be able * to strip those lines at build time. So, we have to do this to test :( */ private static void setMoreDebug(boolean value) throws NoSuchFieldException, IllegalAccessException { if (KeyValueBackupReporter.MORE_DEBUG == value) { return; } Field moreDebugField = KeyValueBackupReporter.class.getDeclaredField("MORE_DEBUG"); moreDebugField.setAccessible(true); moreDebugField.set(null, value); } }