| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/test/test_timeouts.h" | 6 #include "base/test/test_timeouts.h" |
| 7 #include "base/threading/platform_thread.h" | 7 #include "base/threading/platform_thread.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/automation/automation_util.h" | 10 #include "chrome/browser/automation/automation_util.h" |
| 11 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 11 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 12 #include "chrome/browser/extensions/app_restore_service_factory.h" | |
| 13 #include "chrome/browser/extensions/app_restore_service.h" | |
| 14 #include "chrome/browser/extensions/extension_browsertest.h" | 12 #include "chrome/browser/extensions/extension_browsertest.h" |
| 15 #include "chrome/browser/extensions/extension_prefs.h" | |
| 16 #include "chrome/browser/extensions/extension_service.h" | |
| 17 #include "chrome/browser/extensions/extension_system.h" | |
| 18 #include "chrome/browser/extensions/extension_test_message_listener.h" | 13 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 19 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | 14 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
| 20 #include "chrome/browser/extensions/platform_app_launcher.h" | 15 #include "chrome/browser/extensions/platform_app_launcher.h" |
| 21 #include "chrome/browser/extensions/shell_window_registry.h" | 16 #include "chrome/browser/extensions/shell_window_registry.h" |
| 22 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_tabstrip.h" | 18 #include "chrome/browser/ui/browser_tabstrip.h" |
| 24 #include "chrome/browser/ui/extensions/application_launch.h" | 19 #include "chrome/browser/ui/extensions/application_launch.h" |
| 25 #include "chrome/browser/ui/extensions/shell_window.h" | 20 #include "chrome/browser/ui/extensions/shell_window.h" |
| 26 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
| 27 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
| 28 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
| 29 #include "content/public/browser/web_intents_dispatcher.h" | 24 #include "content/public/browser/web_intents_dispatcher.h" |
| 30 #include "content/public/test/test_utils.h" | |
| 31 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
| 32 #include "webkit/glue/web_intent_data.h" | 26 #include "webkit/glue/web_intent_data.h" |
| 33 | 27 |
| 34 using content::WebContents; | 28 using content::WebContents; |
| 35 | 29 |
| 36 namespace extensions { | 30 namespace extensions { |
| 37 | 31 |
| 38 namespace { | 32 namespace { |
| 39 | 33 |
| 40 // Non-abstract RenderViewContextMenu class. | 34 // Non-abstract RenderViewContextMenu class. |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 ASSERT_TRUE(done2_listener.WaitUntilSatisfied()); | 562 ASSERT_TRUE(done2_listener.WaitUntilSatisfied()); |
| 569 | 563 |
| 570 // Tell javascript to open a third window. | 564 // Tell javascript to open a third window. |
| 571 page3_listener.Reply("continue"); | 565 page3_listener.Reply("continue"); |
| 572 | 566 |
| 573 // Wait for javascript to verify that the third window got the restored size | 567 // Wait for javascript to verify that the third window got the restored size |
| 574 // and explicitly specified coordinates. | 568 // and explicitly specified coordinates. |
| 575 ASSERT_TRUE(done3_listener.WaitUntilSatisfied()); | 569 ASSERT_TRUE(done3_listener.WaitUntilSatisfied()); |
| 576 } | 570 } |
| 577 | 571 |
| 578 // Tests that a running app is recorded in the preferences as such. | |
| 579 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) { | |
| 580 content::WindowedNotificationObserver extension_suspended( | |
| 581 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | |
| 582 content::NotificationService::AllSources()); | |
| 583 | |
| 584 const Extension* extension = LoadExtension( | |
| 585 test_data_dir_.AppendASCII("platform_apps/restart_test")); | |
| 586 ASSERT_TRUE(extension); | |
| 587 ExtensionService* extension_service = | |
| 588 ExtensionSystem::Get(browser()->profile())->extension_service(); | |
| 589 ExtensionPrefs* extension_prefs = extension_service->extension_prefs(); | |
| 590 | |
| 591 // App is running. | |
| 592 ASSERT_TRUE(extension_prefs->IsExtensionRunning(extension->id())); | |
| 593 | |
| 594 // Wait for the extension to get suspended. | |
| 595 extension_suspended.Wait(); | |
| 596 | |
| 597 // App isn't running because it got suspended. | |
| 598 ASSERT_FALSE(extension_prefs->IsExtensionRunning(extension->id())); | |
| 599 | |
| 600 // Pretend that the app is supposed to be running. | |
| 601 extension_prefs->SetExtensionRunning(extension->id(), true); | |
| 602 | |
| 603 ExtensionTestMessageListener restart_listener("onRestarted", false); | |
| 604 AppRestoreServiceFactory::GetForProfile(browser()->profile())->RestoreApps(); | |
| 605 restart_listener.WaitUntilSatisfied(); | |
| 606 } | |
| 607 | |
| 608 } // namespace extensions | 572 } // namespace extensions |
| OLD | NEW |