| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "google/cacheinvalidation/types.pb.h" | 8 #include "google/cacheinvalidation/types.pb.h" |
| 9 #include "sync/notifier/fake_invalidation_handler.h" | 9 #include "sync/notifier/fake_invalidation_handler.h" |
| 10 #include "sync/notifier/invalidator_registrar.h" | 10 #include "sync/notifier/invalidator_registrar.h" |
| 11 #include "sync/notifier/invalidator_test_template.h" | 11 #include "sync/notifier/invalidator_test_template.h" |
| 12 #include "sync/notifier/object_id_state_map_test_util.h" | 12 #include "sync/notifier/object_id_invalidation_map_test_util.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace syncer { | 15 namespace syncer { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // We test InvalidatorRegistrar by wrapping it in an Invalidator and | 19 // We test InvalidatorRegistrar by wrapping it in an Invalidator and |
| 20 // running the usual Invalidator tests. | 20 // running the usual Invalidator tests. |
| 21 | 21 |
| 22 // Thin Invalidator wrapper around InvalidatorRegistrar. | 22 // Thin Invalidator wrapper around InvalidatorRegistrar. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 53 | 53 |
| 54 virtual void SetStateDeprecated(const std::string& state) OVERRIDE { | 54 virtual void SetStateDeprecated(const std::string& state) OVERRIDE { |
| 55 // Do nothing. | 55 // Do nothing. |
| 56 } | 56 } |
| 57 | 57 |
| 58 virtual void UpdateCredentials( | 58 virtual void UpdateCredentials( |
| 59 const std::string& email, const std::string& token) OVERRIDE { | 59 const std::string& email, const std::string& token) OVERRIDE { |
| 60 // Do nothing. | 60 // Do nothing. |
| 61 } | 61 } |
| 62 | 62 |
| 63 virtual void SendInvalidation(const ObjectIdStateMap& id_state_map) OVERRIDE { | 63 virtual void SendInvalidation( |
| 64 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE { |
| 64 // Do nothing. | 65 // Do nothing. |
| 65 } | 66 } |
| 66 | 67 |
| 67 private: | 68 private: |
| 68 InvalidatorRegistrar registrar_; | 69 InvalidatorRegistrar registrar_; |
| 69 | 70 |
| 70 DISALLOW_COPY_AND_ASSIGN(RegistrarInvalidator); | 71 DISALLOW_COPY_AND_ASSIGN(RegistrarInvalidator); |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 class RegistrarInvalidatorTestDelegate { | 74 class RegistrarInvalidatorTestDelegate { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 95 } | 96 } |
| 96 | 97 |
| 97 void WaitForInvalidator() { | 98 void WaitForInvalidator() { |
| 98 // Do nothing. | 99 // Do nothing. |
| 99 } | 100 } |
| 100 | 101 |
| 101 void TriggerOnInvalidatorStateChange(InvalidatorState state) { | 102 void TriggerOnInvalidatorStateChange(InvalidatorState state) { |
| 102 invalidator_->GetRegistrar()->UpdateInvalidatorState(state); | 103 invalidator_->GetRegistrar()->UpdateInvalidatorState(state); |
| 103 } | 104 } |
| 104 | 105 |
| 105 void TriggerOnIncomingInvalidation(const ObjectIdStateMap& id_state_map, | 106 void TriggerOnIncomingInvalidation( |
| 106 IncomingInvalidationSource source) { | 107 const ObjectIdInvalidationMap& invalidation_map, |
| 108 IncomingInvalidationSource source) { |
| 107 invalidator_->GetRegistrar()->DispatchInvalidationsToHandlers( | 109 invalidator_->GetRegistrar()->DispatchInvalidationsToHandlers( |
| 108 id_state_map, source); | 110 invalidation_map, source); |
| 109 } | 111 } |
| 110 | 112 |
| 111 static bool InvalidatorHandlesDeprecatedState() { | 113 static bool InvalidatorHandlesDeprecatedState() { |
| 112 return false; | 114 return false; |
| 113 } | 115 } |
| 114 | 116 |
| 115 private: | 117 private: |
| 116 scoped_ptr<RegistrarInvalidator> invalidator_; | 118 scoped_ptr<RegistrarInvalidator> invalidator_; |
| 117 }; | 119 }; |
| 118 | 120 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 146 | 148 |
| 147 registrar.DetachFromThreadForTest(); | 149 registrar.DetachFromThreadForTest(); |
| 148 // We expect a death via CHECK(). We can't match against the CHECK() message | 150 // We expect a death via CHECK(). We can't match against the CHECK() message |
| 149 // though since they are removed in official builds. | 151 // though since they are removed in official builds. |
| 150 EXPECT_DEATH({ registrar.UpdateRegisteredIds(&handler2, ids); }, ""); | 152 EXPECT_DEATH({ registrar.UpdateRegisteredIds(&handler2, ids); }, ""); |
| 151 } | 153 } |
| 152 | 154 |
| 153 } // namespace | 155 } // namespace |
| 154 | 156 |
| 155 } // namespace syncer | 157 } // namespace syncer |
| OLD | NEW |