| 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/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // A test harness that uses a real ProfileSyncService and in most cases a | 164 // A test harness that uses a real ProfileSyncService and in most cases a |
| 165 // MockSyncBackendHost. | 165 // MockSyncBackendHost. |
| 166 // | 166 // |
| 167 // This is useful if we want to test the ProfileSyncService and don't care about | 167 // This is useful if we want to test the ProfileSyncService and don't care about |
| 168 // testing the SyncBackendHost. | 168 // testing the SyncBackendHost. |
| 169 class ProfileSyncServiceTest : public ::testing::Test { | 169 class ProfileSyncServiceTest : public ::testing::Test { |
| 170 protected: | 170 protected: |
| 171 ProfileSyncServiceTest() | 171 ProfileSyncServiceTest() |
| 172 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 172 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
| 173 profile_manager_(TestingBrowserProcess::GetGlobal()) {} | 173 profile_manager_(TestingBrowserProcess::GetGlobal()) {} |
| 174 virtual ~ProfileSyncServiceTest() {} | 174 ~ProfileSyncServiceTest() override {} |
| 175 | 175 |
| 176 virtual void SetUp() override { | 176 void SetUp() override { |
| 177 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 177 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 178 switches::kSyncDeferredStartupTimeoutSeconds, "0"); | 178 switches::kSyncDeferredStartupTimeoutSeconds, "0"); |
| 179 | 179 |
| 180 CHECK(profile_manager_.SetUp()); | 180 CHECK(profile_manager_.SetUp()); |
| 181 | 181 |
| 182 TestingProfile::TestingFactories testing_facotries; | 182 TestingProfile::TestingFactories testing_facotries; |
| 183 testing_facotries.push_back( | 183 testing_facotries.push_back( |
| 184 std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(), | 184 std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(), |
| 185 BuildAutoIssuingFakeProfileOAuth2TokenService)); | 185 BuildAutoIssuingFakeProfileOAuth2TokenService)); |
| 186 testing_facotries.push_back( | 186 testing_facotries.push_back( |
| 187 std::make_pair( | 187 std::make_pair( |
| 188 invalidation::ProfileInvalidationProviderFactory::GetInstance(), | 188 invalidation::ProfileInvalidationProviderFactory::GetInstance(), |
| 189 BuildFakeProfileInvalidationProvider)); | 189 BuildFakeProfileInvalidationProvider)); |
| 190 | 190 |
| 191 profile_ = profile_manager_.CreateTestingProfile( | 191 profile_ = profile_manager_.CreateTestingProfile( |
| 192 "sync-service-test", scoped_ptr<PrefServiceSyncable>(), | 192 "sync-service-test", scoped_ptr<PrefServiceSyncable>(), |
| 193 base::UTF8ToUTF16("sync-service-test"), 0, std::string(), | 193 base::UTF8ToUTF16("sync-service-test"), 0, std::string(), |
| 194 testing_facotries); | 194 testing_facotries); |
| 195 } | 195 } |
| 196 | 196 |
| 197 virtual void TearDown() override { | 197 void TearDown() override { |
| 198 // Kill the service before the profile. | 198 // Kill the service before the profile. |
| 199 if (service_) | 199 if (service_) |
| 200 service_->Shutdown(); | 200 service_->Shutdown(); |
| 201 | 201 |
| 202 service_.reset(); | 202 service_.reset(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void IssueTestTokens() { | 205 void IssueTestTokens() { |
| 206 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_) | 206 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_) |
| 207 ->UpdateCredentials("test", "oauth2_login_token"); | 207 ->UpdateCredentials("test", "oauth2_login_token"); |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 // See that we can override the URL with a flag. | 613 // See that we can override the URL with a flag. |
| 614 CommandLine command_line( | 614 CommandLine command_line( |
| 615 base::FilePath(base::FilePath(FILE_PATH_LITERAL("chrome.exe")))); | 615 base::FilePath(base::FilePath(FILE_PATH_LITERAL("chrome.exe")))); |
| 616 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar"); | 616 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar"); |
| 617 EXPECT_EQ("https://foo/bar", | 617 EXPECT_EQ("https://foo/bar", |
| 618 ProfileSyncService::GetSyncServiceURL(command_line).spec()); | 618 ProfileSyncService::GetSyncServiceURL(command_line).spec()); |
| 619 } | 619 } |
| 620 | 620 |
| 621 } // namespace | 621 } // namespace |
| 622 } // namespace browser_sync | 622 } // namespace browser_sync |
| OLD | NEW |