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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 CreateService(browser_sync::AUTO_START); | 288 CreateService(browser_sync::AUTO_START); |
289 Initialize(); | 289 Initialize(); |
290 const std::string& url = service()->sync_service_url().spec(); | 290 const std::string& url = service()->sync_service_url().spec(); |
291 EXPECT_TRUE(url == ProfileSyncService::kSyncServerUrl || | 291 EXPECT_TRUE(url == ProfileSyncService::kSyncServerUrl || |
292 url == ProfileSyncService::kDevServerUrl); | 292 url == ProfileSyncService::kDevServerUrl); |
293 } | 293 } |
294 | 294 |
295 // Verify a successful initialization. | 295 // Verify a successful initialization. |
296 TEST_F(ProfileSyncServiceTest, SuccessfulInitialization) { | 296 TEST_F(ProfileSyncServiceTest, SuccessfulInitialization) { |
297 profile()->GetTestingPrefService()->SetManagedPref( | 297 profile()->GetTestingPrefService()->SetManagedPref( |
298 sync_driver::prefs::kSyncManaged, base::Value::CreateBooleanValue(false)); | 298 sync_driver::prefs::kSyncManaged, new base::FundamentalValue(false)); |
299 IssueTestTokens(); | 299 IssueTestTokens(); |
300 CreateService(browser_sync::AUTO_START); | 300 CreateService(browser_sync::AUTO_START); |
301 ExpectDataTypeManagerCreation(1); | 301 ExpectDataTypeManagerCreation(1); |
302 ExpectSyncBackendHostCreation(1); | 302 ExpectSyncBackendHostCreation(1); |
303 Initialize(); | 303 Initialize(); |
304 EXPECT_FALSE(service()->IsManaged()); | 304 EXPECT_FALSE(service()->IsManaged()); |
305 EXPECT_TRUE(service()->sync_initialized()); | 305 EXPECT_TRUE(service()->sync_initialized()); |
306 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode()); | 306 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode()); |
307 } | 307 } |
308 | 308 |
(...skipping 11 matching lines...) Expand all Loading... |
320 EXPECT_TRUE(observer.first_setup_in_progress()); | 320 EXPECT_TRUE(observer.first_setup_in_progress()); |
321 service()->SetSetupInProgress(false); | 321 service()->SetSetupInProgress(false); |
322 EXPECT_FALSE(observer.first_setup_in_progress()); | 322 EXPECT_FALSE(observer.first_setup_in_progress()); |
323 | 323 |
324 service()->RemoveObserver(&observer); | 324 service()->RemoveObserver(&observer); |
325 } | 325 } |
326 | 326 |
327 // Verify that disable by enterprise policy works. | 327 // Verify that disable by enterprise policy works. |
328 TEST_F(ProfileSyncServiceTest, DisabledByPolicyBeforeInit) { | 328 TEST_F(ProfileSyncServiceTest, DisabledByPolicyBeforeInit) { |
329 profile()->GetTestingPrefService()->SetManagedPref( | 329 profile()->GetTestingPrefService()->SetManagedPref( |
330 sync_driver::prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); | 330 sync_driver::prefs::kSyncManaged, new base::FundamentalValue(true)); |
331 IssueTestTokens(); | 331 IssueTestTokens(); |
332 CreateService(browser_sync::AUTO_START); | 332 CreateService(browser_sync::AUTO_START); |
333 Initialize(); | 333 Initialize(); |
334 EXPECT_TRUE(service()->IsManaged()); | 334 EXPECT_TRUE(service()->IsManaged()); |
335 EXPECT_FALSE(service()->sync_initialized()); | 335 EXPECT_FALSE(service()->sync_initialized()); |
336 } | 336 } |
337 | 337 |
338 // Verify that disable by enterprise policy works even after the backend has | 338 // Verify that disable by enterprise policy works even after the backend has |
339 // been initialized. | 339 // been initialized. |
340 TEST_F(ProfileSyncServiceTest, DisabledByPolicyAfterInit) { | 340 TEST_F(ProfileSyncServiceTest, DisabledByPolicyAfterInit) { |
341 IssueTestTokens(); | 341 IssueTestTokens(); |
342 CreateService(browser_sync::AUTO_START); | 342 CreateService(browser_sync::AUTO_START); |
343 ExpectDataTypeManagerCreation(1); | 343 ExpectDataTypeManagerCreation(1); |
344 ExpectSyncBackendHostCreation(1); | 344 ExpectSyncBackendHostCreation(1); |
345 Initialize(); | 345 Initialize(); |
346 | 346 |
347 EXPECT_FALSE(service()->IsManaged()); | 347 EXPECT_FALSE(service()->IsManaged()); |
348 EXPECT_TRUE(service()->sync_initialized()); | 348 EXPECT_TRUE(service()->sync_initialized()); |
349 | 349 |
350 profile()->GetTestingPrefService()->SetManagedPref( | 350 profile()->GetTestingPrefService()->SetManagedPref( |
351 sync_driver::prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); | 351 sync_driver::prefs::kSyncManaged, new base::FundamentalValue(true)); |
352 | 352 |
353 EXPECT_TRUE(service()->IsManaged()); | 353 EXPECT_TRUE(service()->IsManaged()); |
354 EXPECT_FALSE(service()->sync_initialized()); | 354 EXPECT_FALSE(service()->sync_initialized()); |
355 } | 355 } |
356 | 356 |
357 // Exercies the ProfileSyncService's code paths related to getting shut down | 357 // Exercies the ProfileSyncService's code paths related to getting shut down |
358 // before the backend initialize call returns. | 358 // before the backend initialize call returns. |
359 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) { | 359 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) { |
360 CreateService(browser_sync::AUTO_START); | 360 CreateService(browser_sync::AUTO_START); |
361 PrepareDelayedInitSyncBackendHost(); | 361 PrepareDelayedInitSyncBackendHost(); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 // See that we can override the URL with a flag. | 615 // See that we can override the URL with a flag. |
616 CommandLine command_line( | 616 CommandLine command_line( |
617 base::FilePath(base::FilePath(FILE_PATH_LITERAL("chrome.exe")))); | 617 base::FilePath(base::FilePath(FILE_PATH_LITERAL("chrome.exe")))); |
618 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar"); | 618 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar"); |
619 EXPECT_EQ("https://foo/bar", | 619 EXPECT_EQ("https://foo/bar", |
620 ProfileSyncService::GetSyncServiceURL(command_line).spec()); | 620 ProfileSyncService::GetSyncServiceURL(command_line).spec()); |
621 } | 621 } |
622 | 622 |
623 } // namespace | 623 } // namespace |
624 } // namespace browser_sync | 624 } // namespace browser_sync |
OLD | NEW |