summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWenyi Wang <wenyiw@google.com>2017-03-24 16:02:44 -0700
committerWenyi Wang <wenyiw@google.com>2017-03-24 16:16:03 -0700
commit57a0e98eed836b72dd3dc3540b9cac029266ed7c (patch)
tree391c5ebb82bd0c1591efae45fe8ca0432112581b /tests
parent1aa5775c6da7cf5d5b7ea521baf71f156c82f8af (diff)
downloadContacts-57a0e98eed836b72dd3dc3540b9cac029266ed7c.tar.gz
Add isLoggable checks to all verbose and debug log outputs (1/2)
Bug: 6813854 Test: built apk and verified log is seen in logcat Change-Id: Ib17cac0d2d9553276c4271221110305ab2d70a46
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/contacts/RunMethodInstrumentation.java14
-rw-r--r--tests/src/com/android/contacts/tests/AdbHelpers.java6
-rw-r--r--tests/src/com/android/contacts/tests/testauth/TestAuthenticationService.java12
-rw-r--r--tests/src/com/android/contacts/tests/testauth/TestAuthenticator.java28
-rw-r--r--tests/src/com/android/contacts/tests/testauth/TestSyncAdapter.java12
5 files changed, 52 insertions, 20 deletions
diff --git a/tests/src/com/android/contacts/RunMethodInstrumentation.java b/tests/src/com/android/contacts/RunMethodInstrumentation.java
index d7ffee936..1e4bcf5f9 100644
--- a/tests/src/com/android/contacts/RunMethodInstrumentation.java
+++ b/tests/src/com/android/contacts/RunMethodInstrumentation.java
@@ -60,8 +60,10 @@ public class RunMethodInstrumentation extends Instrumentation {
methodName = arguments.getString("method");
args = arguments;
- Log.d(TAG, "Running " + className + "." + methodName);
- Log.d(TAG, "args=" + args);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Running " + className + "." + methodName);
+ Log.d(TAG, "args=" + args);
+ }
if (arguments.containsKey("debug") && Boolean.parseBoolean(arguments.getString("debug"))) {
Debug.waitForDebugger();
@@ -71,7 +73,9 @@ public class RunMethodInstrumentation extends Instrumentation {
@Override
public void onStart() {
- Log.d(TAG, "onStart");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "onStart");
+ }
super.onStart();
if (className == null || methodName == null) {
@@ -84,7 +88,9 @@ public class RunMethodInstrumentation extends Instrumentation {
runOnMainSync(new Runnable() {
@Override
public void run() {
- Log.d(TAG, "acquired main thread from instrumentation");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "acquired main thread from instrumentation");
+ }
}
});
diff --git a/tests/src/com/android/contacts/tests/AdbHelpers.java b/tests/src/com/android/contacts/tests/AdbHelpers.java
index 240dbbb97..59fc7231d 100644
--- a/tests/src/com/android/contacts/tests/AdbHelpers.java
+++ b/tests/src/com/android/contacts/tests/AdbHelpers.java
@@ -83,8 +83,10 @@ public class AdbHelpers {
}
public static void dumpPreferences(Context context) {
- Log.d(TAG, "preferences=" + getAppContext().getSharedPreferences(
- getAppContext().getPackageName(), Context.MODE_PRIVATE).getAll());
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "preferences=" + getAppContext().getSharedPreferences(
+ getAppContext().getPackageName(), Context.MODE_PRIVATE).getAll());
+ }
}
public static void clearSimCard(Context context)
diff --git a/tests/src/com/android/contacts/tests/testauth/TestAuthenticationService.java b/tests/src/com/android/contacts/tests/testauth/TestAuthenticationService.java
index 84f3f0f80..bcc3f5441 100644
--- a/tests/src/com/android/contacts/tests/testauth/TestAuthenticationService.java
+++ b/tests/src/com/android/contacts/tests/testauth/TestAuthenticationService.java
@@ -27,18 +27,24 @@ public abstract class TestAuthenticationService extends Service {
@Override
public void onCreate() {
- Log.v(TestauthConstants.LOG_TAG, this + " Service started.");
+ if (Log.isLoggable(TestauthConstants.LOG_TAG, Log.VERBOSE)) {
+ Log.v(TestauthConstants.LOG_TAG, this + " Service started.");
+ }
mAuthenticator = new TestAuthenticator(this);
}
@Override
public void onDestroy() {
- Log.v(TestauthConstants.LOG_TAG, this + " Service stopped.");
+ if (Log.isLoggable(TestauthConstants.LOG_TAG, Log.VERBOSE)) {
+ Log.v(TestauthConstants.LOG_TAG, this + " Service stopped.");
+ }
}
@Override
public IBinder onBind(Intent intent) {
- Log.v(TestauthConstants.LOG_TAG, this + " getBinder() intent=" + intent);
+ if (Log.isLoggable(TestauthConstants.LOG_TAG, Log.VERBOSE)) {
+ Log.v(TestauthConstants.LOG_TAG, this + " getBinder() intent=" + intent);
+ }
return mAuthenticator.getIBinder();
}
diff --git a/tests/src/com/android/contacts/tests/testauth/TestAuthenticator.java b/tests/src/com/android/contacts/tests/testauth/TestAuthenticator.java
index 97e2e4d18..9afcb9ed9 100644
--- a/tests/src/com/android/contacts/tests/testauth/TestAuthenticator.java
+++ b/tests/src/com/android/contacts/tests/testauth/TestAuthenticator.java
@@ -61,7 +61,9 @@ class TestAuthenticator extends AbstractAccountAuthenticator {
@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType,
String authTokenType, String[] requiredFeatures, Bundle options) {
- Log.v(TestauthConstants.LOG_TAG, "addAccount() type=" + accountType);
+ if (Log.isLoggable(TestauthConstants.LOG_TAG, Log.VERBOSE)) {
+ Log.v(TestauthConstants.LOG_TAG, "addAccount() type=" + accountType);
+ }
final Bundle bundle = new Bundle();
final Account account = new Account(newUniqueUserName(), accountType);
@@ -81,7 +83,9 @@ class TestAuthenticator extends AbstractAccountAuthenticator {
@Override
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account,
String authTokenType, Bundle loginOptions) {
- Log.v(TestauthConstants.LOG_TAG, "getAuthToken() account=" + account);
+ if (Log.isLoggable(TestauthConstants.LOG_TAG, Log.VERBOSE)) {
+ Log.v(TestauthConstants.LOG_TAG, "getAuthToken() account=" + account);
+ }
final Bundle bundle = new Bundle();
bundle.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);
@@ -93,20 +97,26 @@ class TestAuthenticator extends AbstractAccountAuthenticator {
@Override
public Bundle confirmCredentials(
AccountAuthenticatorResponse response, Account account, Bundle options) {
- Log.v(TestauthConstants.LOG_TAG, "confirmCredentials()");
+ if (Log.isLoggable(TestauthConstants.LOG_TAG, Log.VERBOSE)) {
+ Log.v(TestauthConstants.LOG_TAG, "confirmCredentials()");
+ }
return null;
}
@Override
public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
- Log.v(TestauthConstants.LOG_TAG, "editProperties()");
+ if (Log.isLoggable(TestauthConstants.LOG_TAG, Log.VERBOSE)) {
+ Log.v(TestauthConstants.LOG_TAG, "editProperties()");
+ }
throw new UnsupportedOperationException();
}
@Override
public String getAuthTokenLabel(String authTokenType) {
// null means we don't support multiple authToken types
- Log.v(TestauthConstants.LOG_TAG, "getAuthTokenLabel()");
+ if (Log.isLoggable(TestauthConstants.LOG_TAG, Log.VERBOSE)) {
+ Log.v(TestauthConstants.LOG_TAG, "getAuthTokenLabel()");
+ }
return null;
}
@@ -116,7 +126,9 @@ class TestAuthenticator extends AbstractAccountAuthenticator {
// This call is used to query whether the Authenticator supports
// specific features. We don't expect to get called, so we always
// return false (no) for any queries.
- Log.v(TestauthConstants.LOG_TAG, "hasFeatures()");
+ if (Log.isLoggable(TestauthConstants.LOG_TAG, Log.VERBOSE)) {
+ Log.v(TestauthConstants.LOG_TAG, "hasFeatures()");
+ }
final Bundle result = new Bundle();
result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, false);
return result;
@@ -125,7 +137,9 @@ class TestAuthenticator extends AbstractAccountAuthenticator {
@Override
public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account,
String authTokenType, Bundle loginOptions) {
- Log.v(TestauthConstants.LOG_TAG, "updateCredentials()");
+ if (Log.isLoggable(TestauthConstants.LOG_TAG, Log.VERBOSE)) {
+ Log.v(TestauthConstants.LOG_TAG, "updateCredentials()");
+ }
return null;
}
}
diff --git a/tests/src/com/android/contacts/tests/testauth/TestSyncAdapter.java b/tests/src/com/android/contacts/tests/testauth/TestSyncAdapter.java
index 076baeae4..859864b13 100644
--- a/tests/src/com/android/contacts/tests/testauth/TestSyncAdapter.java
+++ b/tests/src/com/android/contacts/tests/testauth/TestSyncAdapter.java
@@ -54,7 +54,9 @@ public class TestSyncAdapter extends AbstractThreadedSyncAdapter {
@Override
public void onPerformSync(Account account, Bundle extras, String authority,
ContentProviderClient provider, SyncResult syncResult) {
- Log.v(TestauthConstants.LOG_TAG, "TestSyncAdapter.onPerformSync() account=" + account);
+ if (Log.isLoggable(TestauthConstants.LOG_TAG, Log.VERBOSE)) {
+ Log.v(TestauthConstants.LOG_TAG, "TestSyncAdapter.onPerformSync() account=" + account);
+ }
final ArrayList<ContentProviderOperation> ops = new ArrayList<>();
@@ -93,9 +95,11 @@ public class TestSyncAdapter extends AbstractThreadedSyncAdapter {
// TODO: Clear isDirty flag
// TODO: Remove isDeleted raw contacts
- Log.v(TestauthConstants.LOG_TAG, "Claiming " + ops.size() + " local raw contacts");
- for (ContentProviderOperation op : ops) {
- Log.v(TestauthConstants.LOG_TAG, op.toString());
+ if (Log.isLoggable(TestauthConstants.LOG_TAG, Log.VERBOSE)) {
+ Log.v(TestauthConstants.LOG_TAG, "Claiming " + ops.size() + " local raw contacts");
+ for (ContentProviderOperation op : ops) {
+ Log.v(TestauthConstants.LOG_TAG, op.toString());
+ }
}
try {
contentResolver.applyBatch(ContactsContract.AUTHORITY, ops);