OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // A test utility that makes it easy to assert the exact presence of | 5 // A test utility that makes it easy to assert the exact presence of |
6 // protobuf extensions in an extensible message. Example code: | 6 // protobuf extensions in an extensible message. Example code: |
7 // | 7 // |
8 // sync_pb::EntitySpecifics value; // Set up a test value. | 8 // sync_pb::EntitySpecifics value; // Set up a test value. |
9 // value.MutableExtension(sync_pb::bookmark); | 9 // value.MutableExtension(sync_pb::bookmark); |
10 // | 10 // |
11 // ProtoExtensionValidator<sync_pb::EntitySpecifics> good_expectation(value); | 11 // ProtoExtensionValidator<sync_pb::EntitySpecifics> good_expectation(value); |
12 // good_expectation.ExpectHasExtension(sync_pb::bookmark); | 12 // good_expectation.ExpectHasExtension(sync_pb::bookmark); |
13 // good_expectation.ExpectHasNoOtherFieldsOrExtensions(); | 13 // good_expectation.ExpectHasNoOtherFieldsOrExtensions(); |
14 // | 14 // |
15 // ProtoExtensionValidator<sync_pb::EntitySpecifics> bad_expectation(value); | 15 // ProtoExtensionValidator<sync_pb::EntitySpecifics> bad_expectation(value); |
16 // bad_expectation.ExpectHasExtension(sync_pb::preference); // Fails, no pref | 16 // bad_expectation.ExpectHasExtension(sync_pb::preference); // Fails, no pref |
17 // bad_expectation.ExpectHasNoOtherFieldsOrExtensions(); // Fails, bookmark | 17 // bad_expectation.ExpectHasNoOtherFieldsOrExtensions(); // Fails, bookmark |
18 | 18 |
19 #ifndef CHROME_TEST_SYNC_ENGINE_PROTO_EXTENSION_VALIDATOR_H_ | 19 #ifndef CHROME_BROWSER_SYNC_TEST_ENGINE_PROTO_EXTENSION_VALIDATOR_H_ |
20 #define CHROME_TEST_SYNC_ENGINE_PROTO_EXTENSION_VALIDATOR_H_ | 20 #define CHROME_BROWSER_SYNC_TEST_ENGINE_PROTO_EXTENSION_VALIDATOR_H_ |
21 #pragma once | 21 #pragma once |
22 | 22 |
23 #include "base/string_util.h" | 23 #include "base/string_util.h" |
24 #include "chrome/test/sync/engine/syncer_command_test.h" | 24 #include "chrome/browser/sync/test/engine/syncer_command_test.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
26 | 26 |
27 namespace browser_sync { | 27 namespace browser_sync { |
28 | 28 |
29 template<typename MessageType> | 29 template<typename MessageType> |
30 class ProtoExtensionValidator { | 30 class ProtoExtensionValidator { |
31 public: | 31 public: |
32 explicit ProtoExtensionValidator(const MessageType& proto) | 32 explicit ProtoExtensionValidator(const MessageType& proto) |
33 : proto_(proto) { | 33 : proto_(proto) { |
34 } | 34 } |
(...skipping 10 matching lines...) Expand all Loading... |
45 << "Proto contained additional unexpected extensions."; | 45 << "Proto contained additional unexpected extensions."; |
46 } | 46 } |
47 | 47 |
48 private: | 48 private: |
49 MessageType proto_; | 49 MessageType proto_; |
50 DISALLOW_COPY_AND_ASSIGN(ProtoExtensionValidator); | 50 DISALLOW_COPY_AND_ASSIGN(ProtoExtensionValidator); |
51 }; | 51 }; |
52 | 52 |
53 } // namespace browser_sync | 53 } // namespace browser_sync |
54 | 54 |
55 #endif // CHROME_TEST_SYNC_ENGINE_PROTO_EXTENSION_VALIDATOR_H_ | 55 #endif // CHROME_BROWSER_SYNC_TEST_ENGINE_PROTO_EXTENSION_VALIDATOR_H_ |
OLD | NEW |