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/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/invalidation/fake_invalidation_service.h" | 12 #include "chrome/browser/invalidation/fake_invalidation_service.h" |
13 #include "chrome/browser/invalidation/invalidation_service_factory.h" | 13 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
14 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 14 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
15 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 15 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
17 #include "chrome/browser/signin/signin_manager_factory.h" | 17 #include "chrome/browser/signin/signin_manager_factory.h" |
18 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" | 18 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" |
19 #include "chrome/browser/sync/managed_user_signin_manager_wrapper.h" | 19 #include "chrome/browser/sync/managed_user_signin_manager_wrapper.h" |
20 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" | 20 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
23 #include "chrome/test/base/testing_browser_process.h" | 23 #include "chrome/test/base/testing_browser_process.h" |
24 #include "chrome/test/base/testing_pref_service_syncable.h" | 24 #include "chrome/test/base/testing_pref_service_syncable.h" |
25 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
26 #include "chrome/test/base/testing_profile_manager.h" | 26 #include "chrome/test/base/testing_profile_manager.h" |
| 27 #include "components/invalidation/invalidation_service.h" |
| 28 #include "components/invalidation/profile_invalidation_provider.h" |
27 #include "components/signin/core/browser/signin_manager.h" | 29 #include "components/signin/core/browser/signin_manager.h" |
28 #include "components/sync_driver/data_type_manager_impl.h" | 30 #include "components/sync_driver/data_type_manager_impl.h" |
29 #include "components/sync_driver/pref_names.h" | 31 #include "components/sync_driver/pref_names.h" |
30 #include "components/sync_driver/sync_prefs.h" | 32 #include "components/sync_driver/sync_prefs.h" |
31 #include "content/public/test/test_browser_thread_bundle.h" | 33 #include "content/public/test/test_browser_thread_bundle.h" |
32 #include "google_apis/gaia/gaia_constants.h" | 34 #include "google_apis/gaia/gaia_constants.h" |
33 #include "testing/gmock/include/gmock/gmock.h" | 35 #include "testing/gmock/include/gmock/gmock.h" |
34 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
35 | 37 |
| 38 namespace content { |
| 39 class BrowserContext; |
| 40 } |
| 41 |
36 namespace browser_sync { | 42 namespace browser_sync { |
37 | 43 |
38 namespace { | 44 namespace { |
39 | 45 |
40 ACTION(ReturnNewDataTypeManager) { | 46 ACTION(ReturnNewDataTypeManager) { |
41 return new browser_sync::DataTypeManagerImpl(base::Closure(), | 47 return new browser_sync::DataTypeManagerImpl(base::Closure(), |
42 arg0, | 48 arg0, |
43 arg1, | 49 arg1, |
44 arg2, | 50 arg2, |
45 arg3, | 51 arg3, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 126 |
121 ACTION(ReturnNewSyncBackendHostNoReturn) { | 127 ACTION(ReturnNewSyncBackendHostNoReturn) { |
122 return new browser_sync::SyncBackendHostNoReturn(); | 128 return new browser_sync::SyncBackendHostNoReturn(); |
123 } | 129 } |
124 | 130 |
125 ACTION_P(ReturnNewMockHostCollectDeleteDirParam, delete_dir_param) { | 131 ACTION_P(ReturnNewMockHostCollectDeleteDirParam, delete_dir_param) { |
126 return new browser_sync::SyncBackendHostMockCollectDeleteDirParam( | 132 return new browser_sync::SyncBackendHostMockCollectDeleteDirParam( |
127 delete_dir_param); | 133 delete_dir_param); |
128 } | 134 } |
129 | 135 |
| 136 KeyedService* BuildFakeProfileInvalidationProvider( |
| 137 content::BrowserContext* context) { |
| 138 return new invalidation::ProfileInvalidationProvider( |
| 139 scoped_ptr<invalidation::InvalidationService>( |
| 140 new invalidation::FakeInvalidationService)); |
| 141 } |
| 142 |
130 // A test harness that uses a real ProfileSyncService and in most cases a | 143 // A test harness that uses a real ProfileSyncService and in most cases a |
131 // MockSyncBackendHost. | 144 // MockSyncBackendHost. |
132 // | 145 // |
133 // This is useful if we want to test the ProfileSyncService and don't care about | 146 // This is useful if we want to test the ProfileSyncService and don't care about |
134 // testing the SyncBackendHost. | 147 // testing the SyncBackendHost. |
135 class ProfileSyncServiceTest : public ::testing::Test { | 148 class ProfileSyncServiceTest : public ::testing::Test { |
136 protected: | 149 protected: |
137 ProfileSyncServiceTest() | 150 ProfileSyncServiceTest() |
138 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 151 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
139 profile_manager_(TestingBrowserProcess::GetGlobal()) {} | 152 profile_manager_(TestingBrowserProcess::GetGlobal()) {} |
140 virtual ~ProfileSyncServiceTest() {} | 153 virtual ~ProfileSyncServiceTest() {} |
141 | 154 |
142 virtual void SetUp() OVERRIDE { | 155 virtual void SetUp() OVERRIDE { |
143 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 156 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
144 switches::kSyncDeferredStartupTimeoutSeconds, "0"); | 157 switches::kSyncDeferredStartupTimeoutSeconds, "0"); |
145 | 158 |
146 CHECK(profile_manager_.SetUp()); | 159 CHECK(profile_manager_.SetUp()); |
147 | 160 |
148 TestingProfile::TestingFactories testing_facotries; | 161 TestingProfile::TestingFactories testing_facotries; |
149 testing_facotries.push_back( | 162 testing_facotries.push_back( |
150 std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(), | 163 std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(), |
151 BuildAutoIssuingFakeProfileOAuth2TokenService)); | 164 BuildAutoIssuingFakeProfileOAuth2TokenService)); |
152 testing_facotries.push_back( | 165 testing_facotries.push_back( |
153 std::make_pair( | 166 std::make_pair( |
154 invalidation::InvalidationServiceFactory::GetInstance(), | 167 invalidation::ProfileInvalidationProviderFactory::GetInstance(), |
155 invalidation::FakeInvalidationService::Build)); | 168 BuildFakeProfileInvalidationProvider)); |
156 | 169 |
157 profile_ = profile_manager_.CreateTestingProfile( | 170 profile_ = profile_manager_.CreateTestingProfile( |
158 "sync-service-test", scoped_ptr<PrefServiceSyncable>(), | 171 "sync-service-test", scoped_ptr<PrefServiceSyncable>(), |
159 base::UTF8ToUTF16("sync-service-test"), 0, std::string(), | 172 base::UTF8ToUTF16("sync-service-test"), 0, std::string(), |
160 testing_facotries); | 173 testing_facotries); |
161 } | 174 } |
162 | 175 |
163 virtual void TearDown() OVERRIDE { | 176 virtual void TearDown() OVERRIDE { |
164 // Kill the service before the profile. | 177 // Kill the service before the profile. |
165 if (service_) | 178 if (service_) |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 | 580 |
568 EXPECT_EQ(3u, delete_dir_param.size()); | 581 EXPECT_EQ(3u, delete_dir_param.size()); |
569 EXPECT_FALSE(delete_dir_param[0]); | 582 EXPECT_FALSE(delete_dir_param[0]); |
570 EXPECT_FALSE(delete_dir_param[1]); | 583 EXPECT_FALSE(delete_dir_param[1]); |
571 EXPECT_TRUE(delete_dir_param[2]); | 584 EXPECT_TRUE(delete_dir_param[2]); |
572 } | 585 } |
573 #endif | 586 #endif |
574 | 587 |
575 } // namespace | 588 } // namespace |
576 } // namespace browser_sync | 589 } // namespace browser_sync |
OLD | NEW |