OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 504 |
505 ExtensionSyncService::Get(profile())->ProcessSyncChanges( | 505 ExtensionSyncService::Get(profile())->ProcessSyncChanges( |
506 FROM_HERE, | 506 FROM_HERE, |
507 syncer::SyncChangeList( | 507 syncer::SyncChangeList( |
508 1, app_sync_data.GetSyncChange(syncer::SyncChange::ACTION_ADD))); | 508 1, app_sync_data.GetSyncChange(syncer::SyncChange::ACTION_ADD))); |
509 | 509 |
510 // Verify the installation. | 510 // Verify the installation. |
511 VerifyPromotedApp(app_id, expected_set); | 511 VerifyPromotedApp(app_id, expected_set); |
512 | 512 |
513 // The sort ordinals from sync should not be overridden. | 513 // The sort ordinals from sync should not be overridden. |
514 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); | 514 AppSorting* app_sorting = ExtensionSystem::Get(profile())->app_sorting(); |
515 extensions::AppSorting* app_sorting = prefs->app_sorting(); | |
516 EXPECT_TRUE( | 515 EXPECT_TRUE( |
517 app_sorting->GetAppLaunchOrdinal(app_id).Equals(kAppLaunchOrdinal)); | 516 app_sorting->GetAppLaunchOrdinal(app_id).Equals(kAppLaunchOrdinal)); |
518 EXPECT_TRUE(app_sorting->GetPageOrdinal(app_id).Equals(kPageOrdinal)); | 517 EXPECT_TRUE(app_sorting->GetPageOrdinal(app_id).Equals(kPageOrdinal)); |
519 } | 518 } |
520 | 519 |
521 void InitSyncService() { | 520 void InitSyncService() { |
522 if (!kEnableSync) | 521 if (!kEnableSync) |
523 return; | 522 return; |
524 | 523 |
525 ExtensionSyncService* sync_service = ExtensionSyncService::Get(profile()); | 524 ExtensionSyncService* sync_service = ExtensionSyncService::Get(profile()); |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 base::Bind(&PowerSaveBlockerStub::Create, &power_settings)); | 1042 base::Bind(&PowerSaveBlockerStub::Create, &power_settings)); |
1044 | 1043 |
1045 const Extension* app = InstallAndLaunchEphemeralApp(kPowerTestApp); | 1044 const Extension* app = InstallAndLaunchEphemeralApp(kPowerTestApp); |
1046 ASSERT_TRUE(app); | 1045 ASSERT_TRUE(app); |
1047 EXPECT_EQ(1, power_settings.keep_awake_count()); | 1046 EXPECT_EQ(1, power_settings.keep_awake_count()); |
1048 | 1047 |
1049 CloseAppWaitForUnload(app->id()); | 1048 CloseAppWaitForUnload(app->id()); |
1050 | 1049 |
1051 EXPECT_EQ(0, power_settings.keep_awake_count()); | 1050 EXPECT_EQ(0, power_settings.keep_awake_count()); |
1052 } | 1051 } |
OLD | NEW |