| 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_TEST_SYNC_ENGINE_PROTO_EXTENSION_VALIDATOR_H_ |
| 20 #define CHROME_TEST_SYNC_ENGINE_PROTO_EXTENSION_VALIDATOR_H_ | 20 #define CHROME_TEST_SYNC_ENGINE_PROTO_EXTENSION_VALIDATOR_H_ |
| 21 #pragma once | 21 #pragma once |
| 22 | 22 |
| 23 #include <vector> | |
| 24 | |
| 25 #include "base/string_util.h" | 23 #include "base/string_util.h" |
| 26 #include "chrome/test/sync/engine/syncer_command_test.h" | 24 #include "chrome/test/sync/engine/syncer_command_test.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 26 |
| 29 namespace browser_sync { | 27 namespace browser_sync { |
| 30 | 28 |
| 31 template<typename MessageType> | 29 template<typename MessageType> |
| 32 class ProtoExtensionValidator { | 30 class ProtoExtensionValidator { |
| 33 public: | 31 public: |
| 34 explicit ProtoExtensionValidator(const MessageType& proto) | 32 explicit ProtoExtensionValidator(const MessageType& proto) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 48 } | 46 } |
| 49 | 47 |
| 50 private: | 48 private: |
| 51 MessageType proto_; | 49 MessageType proto_; |
| 52 DISALLOW_COPY_AND_ASSIGN(ProtoExtensionValidator); | 50 DISALLOW_COPY_AND_ASSIGN(ProtoExtensionValidator); |
| 53 }; | 51 }; |
| 54 | 52 |
| 55 } // namespace browser_sync | 53 } // namespace browser_sync |
| 56 | 54 |
| 57 #endif // CHROME_TEST_SYNC_ENGINE_PROTO_EXTENSION_VALIDATOR_H_ | 55 #endif // CHROME_TEST_SYNC_ENGINE_PROTO_EXTENSION_VALIDATOR_H_ |
| OLD | NEW |