Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: chrome/browser/sync/test/integration/two_client_apps_sync_test.cc

Issue 515563003: Remove dependency of chrome in WebRequestPermissions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move KWebStoreAppId to extensions. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 19 #include "chrome/common/extensions/extension_constants.h"
Fady Samuel 2014/08/29 19:39:47 Do you need this?
Xi Han 2014/08/29 19:52:54 Removed.
20 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
21 #include "content/public/test/test_utils.h" 21 #include "content/public/test/test_utils.h"
22 #include "extensions/browser/app_sorting.h" 22 #include "extensions/browser/app_sorting.h"
23 #include "extensions/browser/extension_prefs.h" 23 #include "extensions/browser/extension_prefs.h"
24 #include "extensions/browser/extension_registry.h" 24 #include "extensions/browser/extension_registry.h"
25 #include "extensions/browser/extension_system.h" 25 #include "extensions/browser/extension_system.h"
26 #include "extensions/common/constants.h"
26 #include "sync/api/string_ordinal.h" 27 #include "sync/api/string_ordinal.h"
27 28
28 using apps_helper::AllProfilesHaveSameAppsAsVerifier; 29 using apps_helper::AllProfilesHaveSameAppsAsVerifier;
29 using apps_helper::CopyNTPOrdinals; 30 using apps_helper::CopyNTPOrdinals;
30 using apps_helper::DisableApp; 31 using apps_helper::DisableApp;
31 using apps_helper::EnableApp; 32 using apps_helper::EnableApp;
32 using apps_helper::FixNTPOrdinalCollisions; 33 using apps_helper::FixNTPOrdinalCollisions;
33 using apps_helper::GetAppLaunchOrdinalForApp; 34 using apps_helper::GetAppLaunchOrdinalForApp;
34 using apps_helper::HasSameAppsAsVerifier; 35 using apps_helper::HasSameAppsAsVerifier;
35 using apps_helper::IncognitoDisableApp; 36 using apps_helper::IncognitoDisableApp;
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 // which page the CWS appears on and sync. Both clients should have the same 329 // which page the CWS appears on and sync. Both clients should have the same
329 // page and app launch ordinal values for the CWS. 330 // page and app launch ordinal values for the CWS.
330 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateCWSOrdinals) { 331 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateCWSOrdinals) {
331 ASSERT_TRUE(SetupSync()); 332 ASSERT_TRUE(SetupSync());
332 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); 333 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
333 334
334 // Change the app launch ordinal. 335 // Change the app launch ordinal.
335 syncer::StringOrdinal cws_app_launch_ordinal = 336 syncer::StringOrdinal cws_app_launch_ordinal =
336 extensions::ExtensionPrefs::Get(GetProfile(0)) 337 extensions::ExtensionPrefs::Get(GetProfile(0))
337 ->app_sorting() 338 ->app_sorting()
338 ->GetAppLaunchOrdinal(extension_misc::kWebStoreAppId); 339 ->GetAppLaunchOrdinal(extensions::kWebStoreAppId);
339 extensions::ExtensionPrefs::Get(GetProfile(0)) 340 extensions::ExtensionPrefs::Get(GetProfile(0))
340 ->app_sorting() 341 ->app_sorting()
341 ->SetAppLaunchOrdinal(extension_misc::kWebStoreAppId, 342 ->SetAppLaunchOrdinal(extensions::kWebStoreAppId,
342 cws_app_launch_ordinal.CreateAfter()); 343 cws_app_launch_ordinal.CreateAfter());
343 extensions::ExtensionPrefs::Get(verifier()) 344 extensions::ExtensionPrefs::Get(verifier())
344 ->app_sorting() 345 ->app_sorting()
345 ->SetAppLaunchOrdinal(extension_misc::kWebStoreAppId, 346 ->SetAppLaunchOrdinal(extensions::kWebStoreAppId,
346 cws_app_launch_ordinal.CreateAfter()); 347 cws_app_launch_ordinal.CreateAfter());
347 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); 348 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier());
348 349
349 // Change the page ordinal. 350 // Change the page ordinal.
350 syncer::StringOrdinal cws_page_ordinal = 351 syncer::StringOrdinal cws_page_ordinal =
351 extensions::ExtensionPrefs::Get(GetProfile(1)) 352 extensions::ExtensionPrefs::Get(GetProfile(1))
352 ->app_sorting() 353 ->app_sorting()
353 ->GetPageOrdinal(extension_misc::kWebStoreAppId); 354 ->GetPageOrdinal(extensions::kWebStoreAppId);
354 extensions::ExtensionPrefs::Get(GetProfile(1))->app_sorting()->SetPageOrdinal( 355 extensions::ExtensionPrefs::Get(GetProfile(1))->app_sorting()->SetPageOrdinal(
355 extension_misc::kWebStoreAppId, cws_page_ordinal.CreateAfter()); 356 extensions::kWebStoreAppId, cws_page_ordinal.CreateAfter());
356 extensions::ExtensionPrefs::Get(verifier())->app_sorting()->SetPageOrdinal( 357 extensions::ExtensionPrefs::Get(verifier())->app_sorting()->SetPageOrdinal(
357 extension_misc::kWebStoreAppId, cws_page_ordinal.CreateAfter()); 358 extensions::kWebStoreAppId, cws_page_ordinal.CreateAfter());
358 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); 359 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier());
359 } 360 }
360 361
361 // Adjust the launch type on the first client and sync. Both clients should 362 // Adjust the launch type on the first client and sync. Both clients should
362 // have the same launch type values for the CWS. 363 // have the same launch type values for the CWS.
363 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateLaunchType) { 364 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateLaunchType) {
364 ASSERT_TRUE(SetupSync()); 365 ASSERT_TRUE(SetupSync());
365 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); 366 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
366 367
367 // Change the launch type to window. 368 // Change the launch type to window.
368 extensions::SetLaunchType(GetExtensionService(GetProfile(1)), 369 extensions::SetLaunchType(GetExtensionService(GetProfile(1)),
369 extension_misc::kWebStoreAppId, 370 extensions::kWebStoreAppId,
370 extensions::LAUNCH_TYPE_WINDOW); 371 extensions::LAUNCH_TYPE_WINDOW);
371 extensions::SetLaunchType(GetExtensionService(verifier()), 372 extensions::SetLaunchType(GetExtensionService(verifier()),
372 extension_misc::kWebStoreAppId, 373 extensions::kWebStoreAppId,
373 extensions::LAUNCH_TYPE_WINDOW); 374 extensions::LAUNCH_TYPE_WINDOW);
374 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); 375 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier());
375 376
376 // Change the launch type to regular tab. 377 // Change the launch type to regular tab.
377 extensions::SetLaunchType(GetExtensionService(GetProfile(1)), 378 extensions::SetLaunchType(GetExtensionService(GetProfile(1)),
378 extension_misc::kWebStoreAppId, 379 extensions::kWebStoreAppId,
379 extensions::LAUNCH_TYPE_REGULAR); 380 extensions::LAUNCH_TYPE_REGULAR);
380 ASSERT_FALSE(HasSameAppsAsVerifier(1)); 381 ASSERT_FALSE(HasSameAppsAsVerifier(1));
381 extensions::SetLaunchType(GetExtensionService(verifier()), 382 extensions::SetLaunchType(GetExtensionService(verifier()),
382 extension_misc::kWebStoreAppId, 383 extensions::kWebStoreAppId,
383 extensions::LAUNCH_TYPE_REGULAR); 384 extensions::LAUNCH_TYPE_REGULAR);
384 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); 385 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier());
385 } 386 }
386 387
387 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UnexpectedLaunchType) { 388 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UnexpectedLaunchType) {
388 ASSERT_TRUE(SetupSync()); 389 ASSERT_TRUE(SetupSync());
389 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); 390 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
390 391
391 extensions::SetLaunchType(GetExtensionService(GetProfile(1)), 392 extensions::SetLaunchType(GetExtensionService(GetProfile(1)),
392 extension_misc::kWebStoreAppId, 393 extensions::kWebStoreAppId,
393 extensions::LAUNCH_TYPE_REGULAR); 394 extensions::LAUNCH_TYPE_REGULAR);
394 extensions::SetLaunchType(GetExtensionService(verifier()), 395 extensions::SetLaunchType(GetExtensionService(verifier()),
395 extension_misc::kWebStoreAppId, 396 extensions::kWebStoreAppId,
396 extensions::LAUNCH_TYPE_REGULAR); 397 extensions::LAUNCH_TYPE_REGULAR);
397 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier()); 398 ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier());
398 399
399 const extensions::Extension* extension = 400 const extensions::Extension* extension =
400 GetExtensionRegistry(GetProfile(1))->GetExtensionById( 401 GetExtensionRegistry(GetProfile(1))->GetExtensionById(
401 extension_misc::kWebStoreAppId, 402 extensions::kWebStoreAppId,
402 extensions::ExtensionRegistry::EVERYTHING); 403 extensions::ExtensionRegistry::EVERYTHING);
403 ASSERT_TRUE(extension); 404 ASSERT_TRUE(extension);
404 405
405 ExtensionSyncService* extension_sync_service = 406 ExtensionSyncService* extension_sync_service =
406 ExtensionSyncService::Get(GetProfile(1)); 407 ExtensionSyncService::Get(GetProfile(1));
407 408
408 extensions::AppSyncData original_data( 409 extensions::AppSyncData original_data(
409 extension_sync_service->GetAppSyncData(*extension)); 410 extension_sync_service->GetAppSyncData(*extension));
410 411
411 // Create an invalid launch type and ensure it doesn't get down-synced. This 412 // 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
462 content::WindowedNotificationObserver windowed_observer( 463 content::WindowedNotificationObserver windowed_observer(
463 extensions::NOTIFICATION_CRX_INSTALLER_DONE, 464 extensions::NOTIFICATION_CRX_INSTALLER_DONE,
464 base::Bind(&AllProfilesHaveSameAppsAsVerifier)); 465 base::Bind(&AllProfilesHaveSameAppsAsVerifier));
465 windowed_observer.Wait(); 466 windowed_observer.Wait();
466 } 467 }
467 } 468 }
468 469
469 // TODO(akalin): Add tests exercising: 470 // TODO(akalin): Add tests exercising:
470 // - Offline installation/uninstallation behavior 471 // - Offline installation/uninstallation behavior
471 // - App-specific properties 472 // - App-specific properties
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698