OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "chrome/browser/invalidation/ticl_invalidation_service.h" | 5 #include "chrome/browser/invalidation/ticl_invalidation_service.h" |
6 | 6 |
7 #include "chrome/browser/invalidation/invalidation_service_factory.h" | 7 #include "chrome/browser/invalidation/invalidation_service_factory.h" |
8 #include "chrome/browser/invalidation/invalidation_service_test_template.h" | 8 #include "chrome/browser/invalidation/invalidation_service_test_template.h" |
9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
| 10 #include "content/public/test/test_browser_thread_bundle.h" |
10 #include "sync/notifier/fake_invalidation_handler.h" | 11 #include "sync/notifier/fake_invalidation_handler.h" |
11 #include "sync/notifier/fake_invalidator.h" | 12 #include "sync/notifier/fake_invalidator.h" |
12 #include "sync/notifier/invalidation_util.h" | 13 #include "sync/notifier/invalidation_util.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace invalidation { | 16 namespace invalidation { |
16 | 17 |
17 class TiclInvalidationServiceTestDelegate { | 18 class TiclInvalidationServiceTestDelegate { |
18 public: | 19 public: |
19 TiclInvalidationServiceTestDelegate() { } | 20 TiclInvalidationServiceTestDelegate() { } |
20 | 21 |
21 ~TiclInvalidationServiceTestDelegate() { | 22 ~TiclInvalidationServiceTestDelegate() { |
22 DestroyInvalidationService(); | 23 DestroyInvalidationService(); |
23 } | 24 } |
24 | 25 |
25 void CreateInvalidationService() { | 26 void CreateInvalidationService() { |
| 27 thread_bundle_.reset(new content::TestBrowserThreadBundle()); |
26 fake_invalidator_ = new syncer::FakeInvalidator(); | 28 fake_invalidator_ = new syncer::FakeInvalidator(); |
27 profile_.reset(new TestingProfile()); | 29 profile_.reset(new TestingProfile()); |
28 invalidation_service_.reset( | 30 invalidation_service_.reset( |
29 new TiclInvalidationService(NULL, NULL, NULL, profile_.get())); | 31 new TiclInvalidationService(NULL, NULL, NULL, profile_.get())); |
30 invalidation_service_->InitForTest(fake_invalidator_); | 32 invalidation_service_->InitForTest(fake_invalidator_); |
31 } | 33 } |
32 | 34 |
33 InvalidationService* GetInvalidationService() { | 35 InvalidationService* GetInvalidationService() { |
34 return invalidation_service_.get(); | 36 return invalidation_service_.get(); |
35 } | 37 } |
36 | 38 |
37 void DestroyInvalidationService() { | 39 void DestroyInvalidationService() { |
38 invalidation_service_->Shutdown(); | 40 invalidation_service_->Shutdown(); |
39 } | 41 } |
40 | 42 |
41 void TriggerOnInvalidatorStateChange(syncer::InvalidatorState state) { | 43 void TriggerOnInvalidatorStateChange(syncer::InvalidatorState state) { |
42 fake_invalidator_->EmitOnInvalidatorStateChange(state); | 44 fake_invalidator_->EmitOnInvalidatorStateChange(state); |
43 } | 45 } |
44 | 46 |
45 void TriggerOnIncomingInvalidation( | 47 void TriggerOnIncomingInvalidation( |
46 const syncer::ObjectIdInvalidationMap& invalidation_map) { | 48 const syncer::ObjectIdInvalidationMap& invalidation_map) { |
47 fake_invalidator_->EmitOnIncomingInvalidation(invalidation_map); | 49 fake_invalidator_->EmitOnIncomingInvalidation(invalidation_map); |
48 } | 50 } |
49 | 51 |
50 syncer::FakeInvalidator* fake_invalidator_; // owned by the service. | 52 syncer::FakeInvalidator* fake_invalidator_; // owned by the service. |
| 53 scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_; |
51 scoped_ptr<TiclInvalidationService> invalidation_service_; | 54 scoped_ptr<TiclInvalidationService> invalidation_service_; |
52 scoped_ptr<TestingProfile> profile_; | 55 scoped_ptr<TestingProfile> profile_; |
53 }; | 56 }; |
54 | 57 |
55 INSTANTIATE_TYPED_TEST_CASE_P( | 58 INSTANTIATE_TYPED_TEST_CASE_P( |
56 TiclInvalidationServiceTest, InvalidationServiceTest, | 59 TiclInvalidationServiceTest, InvalidationServiceTest, |
57 TiclInvalidationServiceTestDelegate); | 60 TiclInvalidationServiceTestDelegate); |
58 | 61 |
59 } // namespace invalidation | 62 } // namespace invalidation |
OLD | NEW |