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/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/extensions/app_sync_data.h" | 8 #include "chrome/browser/extensions/app_sync_data.h" |
9 #include "chrome/browser/extensions/bookmark_app_helper.h" | 9 #include "chrome/browser/extensions/bookmark_app_helper.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/extension_sync_service.h" | 11 #include "chrome/browser/extensions/extension_sync_service.h" |
12 #include "chrome/browser/extensions/launch_util.h" | 12 #include "chrome/browser/extensions/launch_util.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/sync/test/integration/apps_helper.h" | 14 #include "chrome/browser/sync/test/integration/apps_helper.h" |
15 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 15 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
16 #include "chrome/browser/sync/test/integration/sync_app_helper.h" | 16 #include "chrome/browser/sync/test/integration/sync_app_helper.h" |
17 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 17 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
18 #include "chrome/browser/sync/test/integration/sync_test.h" | 18 #include "chrome/browser/sync/test/integration/sync_test.h" |
19 #include "chrome/common/extensions/extension_constants.h" | |
20 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
21 #include "content/public/test/test_utils.h" | 20 #include "content/public/test/test_utils.h" |
22 #include "extensions/browser/app_sorting.h" | 21 #include "extensions/browser/app_sorting.h" |
23 #include "extensions/browser/extension_prefs.h" | 22 #include "extensions/browser/extension_prefs.h" |
24 #include "extensions/browser/extension_registry.h" | 23 #include "extensions/browser/extension_registry.h" |
25 #include "extensions/browser/extension_system.h" | 24 #include "extensions/browser/extension_system.h" |
| 25 #include "extensions/common/constants.h" |
26 #include "sync/api/string_ordinal.h" | 26 #include "sync/api/string_ordinal.h" |
27 | 27 |
28 using apps_helper::AllProfilesHaveSameAppsAsVerifier; | 28 using apps_helper::AllProfilesHaveSameAppsAsVerifier; |
29 using apps_helper::CopyNTPOrdinals; | 29 using apps_helper::CopyNTPOrdinals; |
30 using apps_helper::DisableApp; | 30 using apps_helper::DisableApp; |
31 using apps_helper::EnableApp; | 31 using apps_helper::EnableApp; |
32 using apps_helper::FixNTPOrdinalCollisions; | 32 using apps_helper::FixNTPOrdinalCollisions; |
33 using apps_helper::GetAppLaunchOrdinalForApp; | 33 using apps_helper::GetAppLaunchOrdinalForApp; |
34 using apps_helper::HasSameAppsAsVerifier; | 34 using apps_helper::HasSameAppsAsVerifier; |
35 using apps_helper::IncognitoDisableApp; | 35 using apps_helper::IncognitoDisableApp; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 // which page the CWS appears on and sync. Both clients should have the same | 328 // which page the CWS appears on and sync. Both clients should have the same |
329 // page and app launch ordinal values for the CWS. | 329 // page and app launch ordinal values for the CWS. |
330 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateCWSOrdinals) { | 330 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateCWSOrdinals) { |
331 ASSERT_TRUE(SetupSync()); | 331 ASSERT_TRUE(SetupSync()); |
332 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | 332 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); |
333 | 333 |
334 // Change the app launch ordinal. | 334 // Change the app launch ordinal. |
335 syncer::StringOrdinal cws_app_launch_ordinal = | 335 syncer::StringOrdinal cws_app_launch_ordinal = |
336 extensions::ExtensionPrefs::Get(GetProfile(0)) | 336 extensions::ExtensionPrefs::Get(GetProfile(0)) |
337 ->app_sorting() | 337 ->app_sorting() |
338 ->GetAppLaunchOrdinal(extension_misc::kWebStoreAppId); | 338 ->GetAppLaunchOrdinal(extensions::kWebStoreAppId); |
339 extensions::ExtensionPrefs::Get(GetProfile(0)) | 339 extensions::ExtensionPrefs::Get(GetProfile(0)) |
340 ->app_sorting() | 340 ->app_sorting() |
341 ->SetAppLaunchOrdinal(extension_misc::kWebStoreAppId, | 341 ->SetAppLaunchOrdinal(extensions::kWebStoreAppId, |
342 cws_app_launch_ordinal.CreateAfter()); | 342 cws_app_launch_ordinal.CreateAfter()); |
343 extensions::ExtensionPrefs::Get(verifier()) | 343 extensions::ExtensionPrefs::Get(verifier()) |
344 ->app_sorting() | 344 ->app_sorting() |
345 ->SetAppLaunchOrdinal(extension_misc::kWebStoreAppId, | 345 ->SetAppLaunchOrdinal(extensions::kWebStoreAppId, |
346 cws_app_launch_ordinal.CreateAfter()); | 346 cws_app_launch_ordinal.CreateAfter()); |
347 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); | 347 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); |
348 | 348 |
349 // Change the page ordinal. | 349 // Change the page ordinal. |
350 syncer::StringOrdinal cws_page_ordinal = | 350 syncer::StringOrdinal cws_page_ordinal = |
351 extensions::ExtensionPrefs::Get(GetProfile(1)) | 351 extensions::ExtensionPrefs::Get(GetProfile(1)) |
352 ->app_sorting() | 352 ->app_sorting() |
353 ->GetPageOrdinal(extension_misc::kWebStoreAppId); | 353 ->GetPageOrdinal(extensions::kWebStoreAppId); |
354 extensions::ExtensionPrefs::Get(GetProfile(1))->app_sorting()->SetPageOrdinal( | 354 extensions::ExtensionPrefs::Get(GetProfile(1))->app_sorting()->SetPageOrdinal( |
355 extension_misc::kWebStoreAppId, cws_page_ordinal.CreateAfter()); | 355 extensions::kWebStoreAppId, cws_page_ordinal.CreateAfter()); |
356 extensions::ExtensionPrefs::Get(verifier())->app_sorting()->SetPageOrdinal( | 356 extensions::ExtensionPrefs::Get(verifier())->app_sorting()->SetPageOrdinal( |
357 extension_misc::kWebStoreAppId, cws_page_ordinal.CreateAfter()); | 357 extensions::kWebStoreAppId, cws_page_ordinal.CreateAfter()); |
358 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); | 358 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); |
359 } | 359 } |
360 | 360 |
361 // Adjust the launch type on the first client and sync. Both clients should | 361 // Adjust the launch type on the first client and sync. Both clients should |
362 // have the same launch type values for the CWS. | 362 // have the same launch type values for the CWS. |
363 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateLaunchType) { | 363 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateLaunchType) { |
364 ASSERT_TRUE(SetupSync()); | 364 ASSERT_TRUE(SetupSync()); |
365 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | 365 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); |
366 | 366 |
367 // Change the launch type to window. | 367 // Change the launch type to window. |
368 extensions::SetLaunchType(GetExtensionService(GetProfile(1)), | 368 extensions::SetLaunchType(GetExtensionService(GetProfile(1)), |
369 extension_misc::kWebStoreAppId, | 369 extensions::kWebStoreAppId, |
370 extensions::LAUNCH_TYPE_WINDOW); | 370 extensions::LAUNCH_TYPE_WINDOW); |
371 extensions::SetLaunchType(GetExtensionService(verifier()), | 371 extensions::SetLaunchType(GetExtensionService(verifier()), |
372 extension_misc::kWebStoreAppId, | 372 extensions::kWebStoreAppId, |
373 extensions::LAUNCH_TYPE_WINDOW); | 373 extensions::LAUNCH_TYPE_WINDOW); |
374 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); | 374 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); |
375 | 375 |
376 // Change the launch type to regular tab. | 376 // Change the launch type to regular tab. |
377 extensions::SetLaunchType(GetExtensionService(GetProfile(1)), | 377 extensions::SetLaunchType(GetExtensionService(GetProfile(1)), |
378 extension_misc::kWebStoreAppId, | 378 extensions::kWebStoreAppId, |
379 extensions::LAUNCH_TYPE_REGULAR); | 379 extensions::LAUNCH_TYPE_REGULAR); |
380 ASSERT_FALSE(HasSameAppsAsVerifier(1)); | 380 ASSERT_FALSE(HasSameAppsAsVerifier(1)); |
381 extensions::SetLaunchType(GetExtensionService(verifier()), | 381 extensions::SetLaunchType(GetExtensionService(verifier()), |
382 extension_misc::kWebStoreAppId, | 382 extensions::kWebStoreAppId, |
383 extensions::LAUNCH_TYPE_REGULAR); | 383 extensions::LAUNCH_TYPE_REGULAR); |
384 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); | 384 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); |
385 } | 385 } |
386 | 386 |
387 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UnexpectedLaunchType) { | 387 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UnexpectedLaunchType) { |
388 ASSERT_TRUE(SetupSync()); | 388 ASSERT_TRUE(SetupSync()); |
389 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | 389 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); |
390 | 390 |
391 extensions::SetLaunchType(GetExtensionService(GetProfile(1)), | 391 extensions::SetLaunchType(GetExtensionService(GetProfile(1)), |
392 extension_misc::kWebStoreAppId, | 392 extensions::kWebStoreAppId, |
393 extensions::LAUNCH_TYPE_REGULAR); | 393 extensions::LAUNCH_TYPE_REGULAR); |
394 extensions::SetLaunchType(GetExtensionService(verifier()), | 394 extensions::SetLaunchType(GetExtensionService(verifier()), |
395 extension_misc::kWebStoreAppId, | 395 extensions::kWebStoreAppId, |
396 extensions::LAUNCH_TYPE_REGULAR); | 396 extensions::LAUNCH_TYPE_REGULAR); |
397 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); | 397 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); |
398 | 398 |
399 const extensions::Extension* extension = | 399 const extensions::Extension* extension = |
400 GetExtensionRegistry(GetProfile(1))->GetExtensionById( | 400 GetExtensionRegistry(GetProfile(1))->GetExtensionById( |
401 extension_misc::kWebStoreAppId, | 401 extensions::kWebStoreAppId, |
402 extensions::ExtensionRegistry::EVERYTHING); | 402 extensions::ExtensionRegistry::EVERYTHING); |
403 ASSERT_TRUE(extension); | 403 ASSERT_TRUE(extension); |
404 | 404 |
405 ExtensionSyncService* extension_sync_service = | 405 ExtensionSyncService* extension_sync_service = |
406 ExtensionSyncService::Get(GetProfile(1)); | 406 ExtensionSyncService::Get(GetProfile(1)); |
407 | 407 |
408 extensions::AppSyncData original_data( | 408 extensions::AppSyncData original_data( |
409 extension_sync_service->GetAppSyncData(*extension)); | 409 extension_sync_service->GetAppSyncData(*extension)); |
410 | 410 |
411 // Create an invalid launch type and ensure it doesn't get down-synced. This | 411 // Create an invalid launch type and ensure it doesn't get down-synced. This |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 content::WindowedNotificationObserver windowed_observer( | 462 content::WindowedNotificationObserver windowed_observer( |
463 extensions::NOTIFICATION_CRX_INSTALLER_DONE, | 463 extensions::NOTIFICATION_CRX_INSTALLER_DONE, |
464 base::Bind(&AllProfilesHaveSameAppsAsVerifier)); | 464 base::Bind(&AllProfilesHaveSameAppsAsVerifier)); |
465 windowed_observer.Wait(); | 465 windowed_observer.Wait(); |
466 } | 466 } |
467 } | 467 } |
468 | 468 |
469 // TODO(akalin): Add tests exercising: | 469 // TODO(akalin): Add tests exercising: |
470 // - Offline installation/uninstallation behavior | 470 // - Offline installation/uninstallation behavior |
471 // - App-specific properties | 471 // - App-specific properties |
OLD | NEW |