| OLD | NEW |
| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "components/invalidation/fake_invalidation_handler.h" | 8 #include "components/invalidation/fake_invalidation_handler.h" |
| 9 #include "components/invalidation/invalidator_registrar.h" | 9 #include "components/invalidation/invalidator_registrar.h" |
| 10 #include "components/invalidation/invalidator_test_template.h" | 10 #include "components/invalidation/invalidator_test_template.h" |
| 11 #include "google/cacheinvalidation/types.pb.h" | 11 #include "google/cacheinvalidation/types.pb.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace syncer { | 14 namespace syncer { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // We test InvalidatorRegistrar by wrapping it in an Invalidator and | 18 // We test InvalidatorRegistrar by wrapping it in an Invalidator and |
| 19 // running the usual Invalidator tests. | 19 // running the usual Invalidator tests. |
| 20 | 20 |
| 21 // Thin Invalidator wrapper around InvalidatorRegistrar. | 21 // Thin Invalidator wrapper around InvalidatorRegistrar. |
| 22 class RegistrarInvalidator : public Invalidator { | 22 class RegistrarInvalidator : public Invalidator { |
| 23 public: | 23 public: |
| 24 RegistrarInvalidator() {} | 24 RegistrarInvalidator() {} |
| 25 virtual ~RegistrarInvalidator() {} | 25 ~RegistrarInvalidator() override {} |
| 26 | 26 |
| 27 InvalidatorRegistrar* GetRegistrar() { | 27 InvalidatorRegistrar* GetRegistrar() { |
| 28 return ®istrar_; | 28 return ®istrar_; |
| 29 } | 29 } |
| 30 | 30 |
| 31 // Invalidator implementation. | 31 // Invalidator implementation. |
| 32 virtual void RegisterHandler(InvalidationHandler* handler) override { | 32 void RegisterHandler(InvalidationHandler* handler) override { |
| 33 registrar_.RegisterHandler(handler); | 33 registrar_.RegisterHandler(handler); |
| 34 } | 34 } |
| 35 | 35 |
| 36 virtual void UpdateRegisteredIds(InvalidationHandler* handler, | 36 void UpdateRegisteredIds(InvalidationHandler* handler, |
| 37 const ObjectIdSet& ids) override { | 37 const ObjectIdSet& ids) override { |
| 38 registrar_.UpdateRegisteredIds(handler, ids); | 38 registrar_.UpdateRegisteredIds(handler, ids); |
| 39 } | 39 } |
| 40 | 40 |
| 41 virtual void UnregisterHandler(InvalidationHandler* handler) override { | 41 void UnregisterHandler(InvalidationHandler* handler) override { |
| 42 registrar_.UnregisterHandler(handler); | 42 registrar_.UnregisterHandler(handler); |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual InvalidatorState GetInvalidatorState() const override { | 45 InvalidatorState GetInvalidatorState() const override { |
| 46 return registrar_.GetInvalidatorState(); | 46 return registrar_.GetInvalidatorState(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 virtual void UpdateCredentials( | 49 void UpdateCredentials(const std::string& email, |
| 50 const std::string& email, const std::string& token) override { | 50 const std::string& token) override { |
| 51 // Do nothing. | 51 // Do nothing. |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual void RequestDetailedStatus( | 54 void RequestDetailedStatus( |
| 55 base::Callback<void(const base::DictionaryValue&)> call) const override { | 55 base::Callback<void(const base::DictionaryValue&)> call) const override { |
| 56 // Do nothing. | 56 // Do nothing. |
| 57 } | 57 } |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 InvalidatorRegistrar registrar_; | 60 InvalidatorRegistrar registrar_; |
| 61 | 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(RegistrarInvalidator); | 62 DISALLOW_COPY_AND_ASSIGN(RegistrarInvalidator); |
| 63 }; | 63 }; |
| 64 | 64 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 EXPECT_DEATH({ registrar.UpdateRegisteredIds(&handler2, ids); }, ""); | 142 EXPECT_DEATH({ registrar.UpdateRegisteredIds(&handler2, ids); }, ""); |
| 143 | 143 |
| 144 registrar.UnregisterHandler(&handler2); | 144 registrar.UnregisterHandler(&handler2); |
| 145 registrar.UnregisterHandler(&handler1); | 145 registrar.UnregisterHandler(&handler1); |
| 146 } | 146 } |
| 147 #endif // GTEST_HAS_DEATH_TEST | 147 #endif // GTEST_HAS_DEATH_TEST |
| 148 | 148 |
| 149 } // namespace | 149 } // namespace |
| 150 | 150 |
| 151 } // namespace syncer | 151 } // namespace syncer |
| OLD | NEW |