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

Side by Side Diff: chrome/browser/apps/ephemeral_app_browsertest.cc

Issue 1419823011: app_sorting() calls should go via ExtensionSystem intsead of prefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/apps/ephemeral_app_browsertest.h" 5 #include "chrome/browser/apps/ephemeral_app_browsertest.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "apps/app_restore_service.h" 9 #include "apps/app_restore_service.h"
10 #include "apps/saved_files_service.h" 10 #include "apps/saved_files_service.h"
(...skipping 27 matching lines...) Expand all
38 #include "extensions/common/extension.h" 38 #include "extensions/common/extension.h"
39 #include "extensions/test/extension_test_message_listener.h" 39 #include "extensions/test/extension_test_message_listener.h"
40 #include "extensions/test/result_catcher.h" 40 #include "extensions/test/result_catcher.h"
41 #include "sync/api/fake_sync_change_processor.h" 41 #include "sync/api/fake_sync_change_processor.h"
42 #include "sync/api/sync_change_processor_wrapper_for_test.h" 42 #include "sync/api/sync_change_processor_wrapper_for_test.h"
43 #include "sync/api/sync_error_factory_mock.h" 43 #include "sync/api/sync_error_factory_mock.h"
44 #include "ui/app_list/app_list_switches.h" 44 #include "ui/app_list/app_list_switches.h"
45 #include "ui/message_center/message_center.h" 45 #include "ui/message_center/message_center.h"
46 #include "ui/message_center/notifier_settings.h" 46 #include "ui/message_center/notifier_settings.h"
47 47
48 using extensions::AppSorting;
48 using extensions::Event; 49 using extensions::Event;
49 using extensions::EventRouter; 50 using extensions::EventRouter;
50 using extensions::Extension; 51 using extensions::Extension;
51 using extensions::ExtensionPrefs; 52 using extensions::ExtensionPrefs;
52 using extensions::ExtensionRegistry; 53 using extensions::ExtensionRegistry;
53 using extensions::ExtensionRegistryObserver; 54 using extensions::ExtensionRegistryObserver;
54 using extensions::ExtensionSyncData; 55 using extensions::ExtensionSyncData;
55 using extensions::ExtensionSystem; 56 using extensions::ExtensionSystem;
56 using extensions::Manifest; 57 using extensions::Manifest;
57 using extensions::ResultCatcher; 58 using extensions::ResultCatcher;
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 370
370 // Verify properties of ephemeral apps. 371 // Verify properties of ephemeral apps.
371 void VerifyEphemeralApp(const std::string& app_id) { 372 void VerifyEphemeralApp(const std::string& app_id) {
372 EXPECT_TRUE(extensions::util::IsEphemeralApp(app_id, profile())); 373 EXPECT_TRUE(extensions::util::IsEphemeralApp(app_id, profile()));
373 374
374 // Ephemeral apps should not be synced. 375 // Ephemeral apps should not be synced.
375 scoped_ptr<ExtensionSyncData> sync_change = GetLastSyncChangeForApp(app_id); 376 scoped_ptr<ExtensionSyncData> sync_change = GetLastSyncChangeForApp(app_id);
376 EXPECT_FALSE(sync_change.get()); 377 EXPECT_FALSE(sync_change.get());
377 378
378 // Ephemeral apps should not be assigned ordinals. 379 // Ephemeral apps should not be assigned ordinals.
379 extensions::AppSorting* app_sorting = 380 AppSorting* app_sorting = ExtensionSystem::Get(profile())->app_sorting();
380 ExtensionPrefs::Get(profile())->app_sorting();
381 EXPECT_FALSE(app_sorting->GetAppLaunchOrdinal(app_id).IsValid()); 381 EXPECT_FALSE(app_sorting->GetAppLaunchOrdinal(app_id).IsValid());
382 EXPECT_FALSE(app_sorting->GetPageOrdinal(app_id).IsValid()); 382 EXPECT_FALSE(app_sorting->GetPageOrdinal(app_id).IsValid());
383 } 383 }
384 384
385 // Verify that after ephemeral apps stop running, they reside in extension 385 // Verify that after ephemeral apps stop running, they reside in extension
386 // system in a disabled and unloaded state. 386 // system in a disabled and unloaded state.
387 void VerifyInactiveEphemeralApp(const std::string& app_id) { 387 void VerifyInactiveEphemeralApp(const std::string& app_id) {
388 EXPECT_TRUE( 388 EXPECT_TRUE(
389 ExtensionRegistry::Get(profile())->disabled_extensions().Contains( 389 ExtensionRegistry::Get(profile())->disabled_extensions().Contains(
390 app_id)); 390 app_id));
(...skipping 15 matching lines...) Expand all
406 406
407 // The app should not be ephemeral. 407 // The app should not be ephemeral.
408 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); 408 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile());
409 ASSERT_TRUE(prefs); 409 ASSERT_TRUE(prefs);
410 EXPECT_FALSE(prefs->IsEphemeralApp(app_id)); 410 EXPECT_FALSE(prefs->IsEphemeralApp(app_id));
411 EXPECT_EQ(0, 411 EXPECT_EQ(0,
412 prefs->GetDisableReasons(app_id) & 412 prefs->GetDisableReasons(app_id) &
413 Extension::DISABLE_INACTIVE_EPHEMERAL_APP); 413 Extension::DISABLE_INACTIVE_EPHEMERAL_APP);
414 414
415 // Check sort ordinals. 415 // Check sort ordinals.
416 extensions::AppSorting* app_sorting = prefs->app_sorting(); 416 AppSorting* app_sorting = ExtensionSystem::Get(profile())->app_sorting();
417 EXPECT_TRUE(app_sorting->GetAppLaunchOrdinal(app_id).IsValid()); 417 EXPECT_TRUE(app_sorting->GetAppLaunchOrdinal(app_id).IsValid());
418 EXPECT_TRUE(app_sorting->GetPageOrdinal(app_id).IsValid()); 418 EXPECT_TRUE(app_sorting->GetPageOrdinal(app_id).IsValid());
419 } 419 }
420 420
421 // Dispatch a fake alarm event to the app. 421 // Dispatch a fake alarm event to the app.
422 void DispatchAlarmEvent(EventRouter* event_router, 422 void DispatchAlarmEvent(EventRouter* event_router,
423 const std::string& app_id) { 423 const std::string& app_id) {
424 alarms::Alarm dummy_alarm; 424 alarms::Alarm dummy_alarm;
425 dummy_alarm.name = "test_alarm"; 425 dummy_alarm.name = "test_alarm";
426 426
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 497
498 ExtensionSyncService::Get(profile())->ProcessSyncChanges( 498 ExtensionSyncService::Get(profile())->ProcessSyncChanges(
499 FROM_HERE, 499 FROM_HERE,
500 syncer::SyncChangeList( 500 syncer::SyncChangeList(
501 1, app_sync_data.GetSyncChange(syncer::SyncChange::ACTION_ADD))); 501 1, app_sync_data.GetSyncChange(syncer::SyncChange::ACTION_ADD)));
502 502
503 // Verify the installation. 503 // Verify the installation.
504 VerifyPromotedApp(app_id, expected_set); 504 VerifyPromotedApp(app_id, expected_set);
505 505
506 // The sort ordinals from sync should not be overridden. 506 // The sort ordinals from sync should not be overridden.
507 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); 507 AppSorting* app_sorting = ExtensionSystem::Get(profile())->app_sorting();
508 extensions::AppSorting* app_sorting = prefs->app_sorting();
509 EXPECT_TRUE( 508 EXPECT_TRUE(
510 app_sorting->GetAppLaunchOrdinal(app_id).Equals(kAppLaunchOrdinal)); 509 app_sorting->GetAppLaunchOrdinal(app_id).Equals(kAppLaunchOrdinal));
511 EXPECT_TRUE(app_sorting->GetPageOrdinal(app_id).Equals(kPageOrdinal)); 510 EXPECT_TRUE(app_sorting->GetPageOrdinal(app_id).Equals(kPageOrdinal));
512 } 511 }
513 512
514 void InitSyncService() { 513 void InitSyncService() {
515 if (!kEnableSync) 514 if (!kEnableSync)
516 return; 515 return;
517 516
518 ExtensionSyncService* sync_service = ExtensionSyncService::Get(profile()); 517 ExtensionSyncService* sync_service = ExtensionSyncService::Get(profile());
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 base::Bind(&PowerSaveBlockerStub::Create, &power_settings)); 1031 base::Bind(&PowerSaveBlockerStub::Create, &power_settings));
1033 1032
1034 const Extension* app = InstallAndLaunchEphemeralApp(kPowerTestApp); 1033 const Extension* app = InstallAndLaunchEphemeralApp(kPowerTestApp);
1035 ASSERT_TRUE(app); 1034 ASSERT_TRUE(app);
1036 EXPECT_EQ(1, power_settings.keep_awake_count()); 1035 EXPECT_EQ(1, power_settings.keep_awake_count());
1037 1036
1038 CloseAppWaitForUnload(app->id()); 1037 CloseAppWaitForUnload(app->id());
1039 1038
1040 EXPECT_EQ(0, power_settings.keep_awake_count()); 1039 EXPECT_EQ(0, power_settings.keep_awake_count());
1041 } 1040 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698