| 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 "components/invalidation/invalidation_logger.h" | 5 #include "components/invalidation/invalidation_logger.h" |
| 6 #include "components/invalidation/invalidation_logger_observer.h" | 6 #include "components/invalidation/invalidation_logger_observer.h" |
| 7 | 7 |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace invalidation { | 10 namespace invalidation { |
| 11 | 11 |
| 12 class InvalidationLoggerObserverTest : public InvalidationLoggerObserver { | 12 class InvalidationLoggerObserverTest : public InvalidationLoggerObserver { |
| 13 public: | 13 public: |
| 14 InvalidationLoggerObserverTest() { ResetStates(); } | 14 InvalidationLoggerObserverTest() { ResetStates(); } |
| 15 | 15 |
| 16 void ResetStates() { | 16 void ResetStates() { |
| 17 registration_change_received = false; | 17 registration_change_received = false; |
| 18 state_received = false; | 18 state_received = false; |
| 19 update_id_received = false; | 19 update_id_received = false; |
| 20 debug_message_received = false; | 20 debug_message_received = false; |
| 21 invalidation_received = false; | 21 invalidation_received = false; |
| 22 detailed_status_received = false; | 22 detailed_status_received = false; |
| 23 update_id_replicated = std::map<std::string, syncer::ObjectIdCountMap>(); | 23 update_id_replicated = std::map<std::string, syncer::ObjectIdCountMap>(); |
| 24 registered_handlers = std::multiset<std::string>(); | 24 registered_handlers = std::multiset<std::string>(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 virtual void OnRegistrationChange(const std::multiset<std::string>& handlers) | 27 virtual void OnRegistrationChange(const std::multiset<std::string>& handlers) |
| 28 OVERRIDE { | 28 override { |
| 29 registered_handlers = handlers; | 29 registered_handlers = handlers; |
| 30 registration_change_received = true; | 30 registration_change_received = true; |
| 31 } | 31 } |
| 32 | 32 |
| 33 virtual void OnStateChange(const syncer::InvalidatorState& new_state, | 33 virtual void OnStateChange(const syncer::InvalidatorState& new_state, |
| 34 const base::Time& last_change_timestamp) | 34 const base::Time& last_change_timestamp) |
| 35 OVERRIDE { | 35 override { |
| 36 state_received = true; | 36 state_received = true; |
| 37 } | 37 } |
| 38 | 38 |
| 39 virtual void OnUpdateIds(const std::string& handler, | 39 virtual void OnUpdateIds(const std::string& handler, |
| 40 const syncer::ObjectIdCountMap& details) OVERRIDE { | 40 const syncer::ObjectIdCountMap& details) override { |
| 41 update_id_received = true; | 41 update_id_received = true; |
| 42 update_id_replicated[handler] = details; | 42 update_id_replicated[handler] = details; |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual void OnDebugMessage(const base::DictionaryValue& details) OVERRIDE { | 45 virtual void OnDebugMessage(const base::DictionaryValue& details) override { |
| 46 debug_message_received = true; | 46 debug_message_received = true; |
| 47 } | 47 } |
| 48 | 48 |
| 49 virtual void OnInvalidation( | 49 virtual void OnInvalidation( |
| 50 const syncer::ObjectIdInvalidationMap& new_invalidations) OVERRIDE { | 50 const syncer::ObjectIdInvalidationMap& new_invalidations) override { |
| 51 invalidation_received = true; | 51 invalidation_received = true; |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual void OnDetailedStatus(const base::DictionaryValue& details) OVERRIDE { | 54 virtual void OnDetailedStatus(const base::DictionaryValue& details) override { |
| 55 detailed_status_received = true; | 55 detailed_status_received = true; |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool registration_change_received; | 58 bool registration_change_received; |
| 59 bool state_received; | 59 bool state_received; |
| 60 bool update_id_received; | 60 bool update_id_received; |
| 61 bool debug_message_received; | 61 bool debug_message_received; |
| 62 bool invalidation_received; | 62 bool invalidation_received; |
| 63 bool detailed_status_received; | 63 bool detailed_status_received; |
| 64 std::map<std::string, syncer::ObjectIdCountMap> update_id_replicated; | 64 std::map<std::string, syncer::ObjectIdCountMap> update_id_replicated; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 277 |
| 278 observer_test.ResetStates(); | 278 observer_test.ResetStates(); |
| 279 log.OnUnregistration(std::string("FakeHandler2")); | 279 log.OnUnregistration(std::string("FakeHandler2")); |
| 280 test_multiset.erase("FakeHandler2"); | 280 test_multiset.erase("FakeHandler2"); |
| 281 EXPECT_TRUE(observer_test.registration_change_received); | 281 EXPECT_TRUE(observer_test.registration_change_received); |
| 282 EXPECT_EQ(observer_test.registered_handlers, test_multiset); | 282 EXPECT_EQ(observer_test.registered_handlers, test_multiset); |
| 283 | 283 |
| 284 log.UnregisterObserver(&observer_test); | 284 log.UnregisterObserver(&observer_test); |
| 285 } | 285 } |
| 286 } // namespace invalidation | 286 } // namespace invalidation |
| OLD | NEW |