| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This class defines tests that implementations of InvalidationService should | 5 // This class defines tests that implementations of InvalidationService should |
| 6 // pass in order to be conformant. Here's how you use it to test your | 6 // pass in order to be conformant. Here's how you use it to test your |
| 7 // implementation. | 7 // implementation. |
| 8 // | 8 // |
| 9 // Say your class is called MyInvalidationService. Then you need to define a | 9 // Say your class is called MyInvalidationService. Then you need to define a |
| 10 // class called MyInvalidationServiceTestDelegate in | 10 // class called MyInvalidationServiceTestDelegate in |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // Then you simply #include this file as well as gtest.h and add the | 61 // Then you simply #include this file as well as gtest.h and add the |
| 62 // following statement to my_sync_notifier_unittest.cc: | 62 // following statement to my_sync_notifier_unittest.cc: |
| 63 // | 63 // |
| 64 // INSTANTIATE_TYPED_TEST_CASE_P( | 64 // INSTANTIATE_TYPED_TEST_CASE_P( |
| 65 // MyInvalidationService, | 65 // MyInvalidationService, |
| 66 // InvalidationServiceTest, | 66 // InvalidationServiceTest, |
| 67 // MyInvalidatorTestDelegate); | 67 // MyInvalidatorTestDelegate); |
| 68 // | 68 // |
| 69 // Easy! | 69 // Easy! |
| 70 | 70 |
| 71 #ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_TEST_TEMPLATE_H_ | 71 #ifndef COMPONENTS_INVALIDATION_INVALIDATION_SERVICE_TEST_TEMPLATE_H_ |
| 72 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_TEST_TEMPLATE_H_ | 72 #define COMPONENTS_INVALIDATION_INVALIDATION_SERVICE_TEST_TEMPLATE_H_ |
| 73 | 73 |
| 74 #include "base/basictypes.h" | 74 #include "base/basictypes.h" |
| 75 #include "base/compiler_specific.h" | 75 #include "base/compiler_specific.h" |
| 76 #include "components/invalidation/fake_invalidation_handler.h" | 76 #include "components/invalidation/fake_invalidation_handler.h" |
| 77 #include "components/invalidation/invalidation_service.h" | 77 #include "components/invalidation/invalidation_service.h" |
| 78 #include "content/public/test/test_browser_thread_bundle.h" | |
| 79 #include "google/cacheinvalidation/include/types.h" | 78 #include "google/cacheinvalidation/include/types.h" |
| 80 #include "google/cacheinvalidation/types.pb.h" | 79 #include "google/cacheinvalidation/types.pb.h" |
| 81 #include "sync/internal_api/public/base/ack_handle.h" | 80 #include "sync/internal_api/public/base/ack_handle.h" |
| 82 #include "sync/internal_api/public/base/invalidation.h" | 81 #include "sync/internal_api/public/base/invalidation.h" |
| 83 #include "sync/internal_api/public/base/object_id_invalidation_map_test_util.h" | 82 #include "sync/internal_api/public/base/object_id_invalidation_map_test_util.h" |
| 84 #include "sync/notifier/object_id_invalidation_map.h" | 83 #include "sync/notifier/object_id_invalidation_map.h" |
| 85 #include "testing/gtest/include/gtest/gtest.h" | 84 #include "testing/gtest/include/gtest/gtest.h" |
| 86 | 85 |
| 87 template <typename InvalidatorTestDelegate> | 86 template <typename InvalidatorTestDelegate> |
| 88 class InvalidationServiceTest : public testing::Test { | 87 class InvalidationServiceTest : public testing::Test { |
| 89 protected: | 88 protected: |
| 90 InvalidationServiceTest() | 89 InvalidationServiceTest() |
| 91 : id1(ipc::invalidation::ObjectSource::CHROME_SYNC, "BOOKMARK"), | 90 : id1(ipc::invalidation::ObjectSource::CHROME_SYNC, "BOOKMARK"), |
| 92 id2(ipc::invalidation::ObjectSource::CHROME_SYNC, "PREFERENCE"), | 91 id2(ipc::invalidation::ObjectSource::CHROME_SYNC, "PREFERENCE"), |
| 93 id3(ipc::invalidation::ObjectSource::CHROME_SYNC, "AUTOFILL"), | 92 id3(ipc::invalidation::ObjectSource::CHROME_SYNC, "AUTOFILL"), |
| 94 id4(ipc::invalidation::ObjectSource::CHROME_PUSH_MESSAGING, | 93 id4(ipc::invalidation::ObjectSource::CHROME_PUSH_MESSAGING, |
| 95 "PUSH_MESSAGE") { | 94 "PUSH_MESSAGE") { |
| 96 } | 95 } |
| 97 | 96 |
| 98 invalidation::InvalidationService* | 97 invalidation::InvalidationService* |
| 99 CreateAndInitializeInvalidationService() { | 98 CreateAndInitializeInvalidationService() { |
| 100 this->delegate_.CreateInvalidationService(); | 99 this->delegate_.CreateInvalidationService(); |
| 101 return this->delegate_.GetInvalidationService(); | 100 return this->delegate_.GetInvalidationService(); |
| 102 } | 101 } |
| 103 | 102 |
| 104 content::TestBrowserThreadBundle thread_bundle_; | |
| 105 InvalidatorTestDelegate delegate_; | 103 InvalidatorTestDelegate delegate_; |
| 106 | 104 |
| 107 const invalidation::ObjectId id1; | 105 const invalidation::ObjectId id1; |
| 108 const invalidation::ObjectId id2; | 106 const invalidation::ObjectId id2; |
| 109 const invalidation::ObjectId id3; | 107 const invalidation::ObjectId id3; |
| 110 const invalidation::ObjectId id4; | 108 const invalidation::ObjectId id4; |
| 111 }; | 109 }; |
| 112 | 110 |
| 113 TYPED_TEST_CASE_P(InvalidationServiceTest); | 111 TYPED_TEST_CASE_P(InvalidationServiceTest); |
| 114 | 112 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 EXPECT_EQ(syncer::TRANSIENT_INVALIDATION_ERROR, | 378 EXPECT_EQ(syncer::TRANSIENT_INVALIDATION_ERROR, |
| 381 handler.GetLastRetrievedState()); | 379 handler.GetLastRetrievedState()); |
| 382 | 380 |
| 383 invalidator->UnregisterInvalidationHandler(&handler); | 381 invalidator->UnregisterInvalidationHandler(&handler); |
| 384 } | 382 } |
| 385 | 383 |
| 386 REGISTER_TYPED_TEST_CASE_P(InvalidationServiceTest, | 384 REGISTER_TYPED_TEST_CASE_P(InvalidationServiceTest, |
| 387 Basic, MultipleHandlers, EmptySetUnregisters, | 385 Basic, MultipleHandlers, EmptySetUnregisters, |
| 388 GetInvalidatorStateAlwaysCurrent); | 386 GetInvalidatorStateAlwaysCurrent); |
| 389 | 387 |
| 390 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_TEST_TEMPLATE_H_ | 388 #endif // COMPONENTS_INVALIDATION_INVALIDATION_SERVICE_TEST_TEMPLATE_H_ |
| OLD | NEW |