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

Unified Diff: mojo/public/cpp/bindings/tests/validation_unittest.cc

Issue 307353009: Mojo cpp bindings: report the reason of validation failure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months 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
Index: mojo/public/cpp/bindings/tests/validation_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/validation_unittest.cc b/mojo/public/cpp/bindings/tests/validation_unittest.cc
index 4384042137fcc999f91af0888ef7f2eace4f6d6e..4bd1cb594fdb07465790a8522418d1ad8feb19c7 100644
--- a/mojo/public/cpp/bindings/tests/validation_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/validation_unittest.cc
@@ -10,6 +10,7 @@
#include <vector>
#include "mojo/public/cpp/bindings/lib/message_header_validator.h"
+#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/test_support/test_support.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -17,6 +18,12 @@ namespace mojo {
namespace test {
namespace {
+std::string ValidationErrorToResultString(internal::ValidationError error) {
+ std::string result = internal::ValidationErrorToString(error);
+ result.push_back('\n');
+ return result;
+}
+
std::vector<std::string> GetMatchingTests(const std::vector<std::string>& names,
const std::string& prefix) {
const std::string suffix = ".data";
@@ -99,11 +106,14 @@ class DummyMessageReceiver : public MessageReceiver {
};
std::string DumpMessageHeader(Message* message) {
+ internal::ValidationErrorObserverForTesting observer;
DummyMessageReceiver not_reached_receiver;
internal::MessageHeaderValidator validator(&not_reached_receiver);
bool rv = validator.Accept(message);
- if (!rv)
- return "ERROR\n";
+ if (!rv) {
+ EXPECT_NE(internal::VALIDATION_ERROR_NONE, observer.last_error());
+ return ValidationErrorToResultString(observer.last_error());
+ }
std::ostringstream os;
os << "num_bytes: " << message->header()->num_bytes << "\n"

Powered by Google App Engine
This is Rietveld 408576698