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

Side by Side Diff: mojo/public/cpp/bindings/lib/validation_errors.cc

Issue 322003002: Mojo message validation tests: add integration tests and move existing conformance tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/public/cpp/bindings/lib/validation_errors.h" 5 #include "mojo/public/cpp/bindings/lib/validation_errors.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 9
10 namespace mojo { 10 namespace mojo {
(...skipping 13 matching lines...) Expand all
24 case VALIDATION_ERROR_ILLEGAL_MEMORY_RANGE: 24 case VALIDATION_ERROR_ILLEGAL_MEMORY_RANGE:
25 return "VALIDATION_ERROR_ILLEGAL_MEMORY_RANGE"; 25 return "VALIDATION_ERROR_ILLEGAL_MEMORY_RANGE";
26 case VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER: 26 case VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER:
27 return "VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER"; 27 return "VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER";
28 case VALIDATION_ERROR_UNEXPECTED_ARRAY_HEADER: 28 case VALIDATION_ERROR_UNEXPECTED_ARRAY_HEADER:
29 return "VALIDATION_ERROR_UNEXPECTED_ARRAY_HEADER"; 29 return "VALIDATION_ERROR_UNEXPECTED_ARRAY_HEADER";
30 case VALIDATION_ERROR_ILLEGAL_HANDLE: 30 case VALIDATION_ERROR_ILLEGAL_HANDLE:
31 return "VALIDATION_ERROR_ILLEGAL_HANDLE"; 31 return "VALIDATION_ERROR_ILLEGAL_HANDLE";
32 case VALIDATION_ERROR_ILLEGAL_POINTER: 32 case VALIDATION_ERROR_ILLEGAL_POINTER:
33 return "VALIDATION_ERROR_ILLEGAL_POINTER"; 33 return "VALIDATION_ERROR_ILLEGAL_POINTER";
34 case VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAG_COMBINAION: 34 case VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAG_COMBINATION:
35 return "VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAG_COMBINAION"; 35 return "VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAG_COMBINATION";
36 case VALIDATION_ERROR_MESSAGE_HEADER_MISSING_REQUEST_ID: 36 case VALIDATION_ERROR_MESSAGE_HEADER_MISSING_REQUEST_ID:
37 return "VALIDATION_ERROR_MESSAGE_HEADER_MISSING_REQUEST_ID"; 37 return "VALIDATION_ERROR_MESSAGE_HEADER_MISSING_REQUEST_ID";
38 } 38 }
39 39
40 return "Unknown error"; 40 return "Unknown error";
41 } 41 }
42 42
43 void ReportValidationError(ValidationError error) { 43 void ReportValidationError(ValidationError error) {
44 // TODO(yzshen): Consider adding better logging support. 44 if (g_validation_error_observer) {
45 fprintf(stderr, "Invalid message: %s\n", ValidationErrorToString(error));
46 if (g_validation_error_observer)
47 g_validation_error_observer->set_last_error(error); 45 g_validation_error_observer->set_last_error(error);
46 } else {
47 // TODO(yzshen): Consider adding better logging support.
48 fprintf(stderr, "Invalid message: %s\n", ValidationErrorToString(error));
49 }
48 } 50 }
49 51
50 ValidationErrorObserverForTesting::ValidationErrorObserverForTesting() 52 ValidationErrorObserverForTesting::ValidationErrorObserverForTesting()
51 : last_error_(VALIDATION_ERROR_NONE) { 53 : last_error_(VALIDATION_ERROR_NONE) {
52 assert(!g_validation_error_observer); 54 assert(!g_validation_error_observer);
53 g_validation_error_observer = this; 55 g_validation_error_observer = this;
54 } 56 }
55 57
56 ValidationErrorObserverForTesting::~ValidationErrorObserverForTesting() { 58 ValidationErrorObserverForTesting::~ValidationErrorObserverForTesting() {
57 assert(g_validation_error_observer == this); 59 assert(g_validation_error_observer == this);
58 g_validation_error_observer = NULL; 60 g_validation_error_observer = NULL;
59 } 61 }
60 62
61 } // namespace internal 63 } // namespace internal
62 } // namespace mojo 64 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_errors.h ('k') | mojo/public/cpp/bindings/tests/validation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698