Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1290)

Unified Diff: mojo/public/cpp/bindings/lib/validation_errors.cc

Issue 2448203002: Mojo: Suppress validation error logging in some tests (Closed)
Patch Set: . Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_errors.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/validation_errors.cc
diff --git a/mojo/public/cpp/bindings/lib/validation_errors.cc b/mojo/public/cpp/bindings/lib/validation_errors.cc
index 67106a0fd508dfe2e74a960564319edce92f8a5a..12e6ff73c821f1794a7a72ce22aa08acc1d54edb 100644
--- a/mojo/public/cpp/bindings/lib/validation_errors.cc
+++ b/mojo/public/cpp/bindings/lib/validation_errors.cc
@@ -14,6 +14,7 @@ namespace {
ValidationErrorObserverForTesting* g_validation_error_observer = nullptr;
SerializationWarningObserverForTesting* g_serialization_warning_observer =
nullptr;
+bool g_suppress_logging = false;
} // namespace
@@ -71,8 +72,10 @@ void ReportValidationError(ValidationContext* context,
}
if (description) {
- LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error) << " ("
- << description << ")";
+ if (!g_suppress_logging) {
+ LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error)
+ << " (" << description << ")";
+ }
if (context->message()) {
context->message()->NotifyBadMessage(
base::StringPrintf("Validation failed for %s [%s (%s)]",
@@ -80,7 +83,8 @@ void ReportValidationError(ValidationContext* context,
ValidationErrorToString(error), description));
}
} else {
- LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error);
+ if (!g_suppress_logging)
+ LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error);
if (context->message()) {
context->message()->NotifyBadMessage(
base::StringPrintf("Validation failed for %s [%s]",
@@ -101,6 +105,17 @@ void ReportValidationErrorForMessage(
ReportValidationError(&validation_context, error);
}
+ScopedSuppressValidationErrorLoggingForTests
+ ::ScopedSuppressValidationErrorLoggingForTests()
+ : was_suppressed_(g_suppress_logging) {
+ g_suppress_logging = true;
+}
+
+ScopedSuppressValidationErrorLoggingForTests
+ ::~ScopedSuppressValidationErrorLoggingForTests() {
+ g_suppress_logging = was_suppressed_;
+}
+
ValidationErrorObserverForTesting::ValidationErrorObserverForTesting(
const base::Closure& callback)
: last_error_(VALIDATION_ERROR_NONE), callback_(callback) {
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_errors.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698