| 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/devtools/devtools_window.h" | 11 #include "chrome/browser/devtools/devtools_window.h" |
| 12 #include "chrome/browser/extensions/api/permissions/permissions_api.h" | 12 #include "chrome/browser/extensions/api/permissions/permissions_api.h" |
| 13 #include "chrome/browser/extensions/app_restore_service.h" | |
| 14 #include "chrome/browser/extensions/app_restore_service_factory.h" | |
| 15 #include "chrome/browser/extensions/extension_browsertest.h" | 13 #include "chrome/browser/extensions/extension_browsertest.h" |
| 16 #include "chrome/browser/extensions/extension_prefs.h" | 14 #include "chrome/browser/extensions/extension_prefs.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/extension_system.h" | 16 #include "chrome/browser/extensions/extension_system.h" |
| 19 #include "chrome/browser/extensions/extension_test_message_listener.h" | 17 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 20 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | 18 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
| 21 #include "chrome/browser/extensions/platform_app_launcher.h" | 19 #include "chrome/browser/extensions/platform_app_launcher.h" |
| 22 #include "chrome/browser/extensions/shell_window_registry.h" | 20 #include "chrome/browser/extensions/shell_window_registry.h" |
| 23 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_service.h" |
| 24 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 22 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 ASSERT_EQ(bounds, window->GetBaseWindow()->GetBounds()); | 645 ASSERT_EQ(bounds, window->GetBaseWindow()->GetBounds()); |
| 648 | 646 |
| 649 // Tell javascript to open a second window. | 647 // Tell javascript to open a second window. |
| 650 page2_listener.Reply("continue"); | 648 page2_listener.Reply("continue"); |
| 651 | 649 |
| 652 // Wait for javascript to verify that the second window got the updated | 650 // Wait for javascript to verify that the second window got the updated |
| 653 // coordinates, ignoring the default coordinates passed to the create method. | 651 // coordinates, ignoring the default coordinates passed to the create method. |
| 654 ASSERT_TRUE(done2_listener.WaitUntilSatisfied()); | 652 ASSERT_TRUE(done2_listener.WaitUntilSatisfied()); |
| 655 } | 653 } |
| 656 | 654 |
| 657 // Tests that a running app is recorded in the preferences as such. | |
| 658 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) { | |
| 659 content::WindowedNotificationObserver extension_suspended( | |
| 660 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | |
| 661 content::NotificationService::AllSources()); | |
| 662 | |
| 663 const Extension* extension = LoadExtension( | |
| 664 test_data_dir_.AppendASCII("platform_apps/restart_test")); | |
| 665 ASSERT_TRUE(extension); | |
| 666 ExtensionService* extension_service = | |
| 667 ExtensionSystem::Get(browser()->profile())->extension_service(); | |
| 668 ExtensionPrefs* extension_prefs = extension_service->extension_prefs(); | |
| 669 | |
| 670 // App is running. | |
| 671 ASSERT_TRUE(extension_prefs->IsExtensionRunning(extension->id())); | |
| 672 | |
| 673 // Wait for the extension to get suspended. | |
| 674 extension_suspended.Wait(); | |
| 675 | |
| 676 // App isn't running because it got suspended. | |
| 677 ASSERT_FALSE(extension_prefs->IsExtensionRunning(extension->id())); | |
| 678 | |
| 679 // Pretend that the app is supposed to be running. | |
| 680 extension_prefs->SetExtensionRunning(extension->id(), true); | |
| 681 | |
| 682 ExtensionTestMessageListener restart_listener("onRestarted", false); | |
| 683 AppRestoreServiceFactory::GetForProfile(browser()->profile())-> | |
| 684 HandleStartup(true); | |
| 685 restart_listener.WaitUntilSatisfied(); | |
| 686 } | |
| 687 | |
| 688 namespace { | 655 namespace { |
| 689 | 656 |
| 690 class PlatformAppDevToolsBrowserTest : public PlatformAppBrowserTest { | 657 class PlatformAppDevToolsBrowserTest : public PlatformAppBrowserTest { |
| 691 protected: | 658 protected: |
| 692 enum TestFlags { | 659 enum TestFlags { |
| 693 RELAUNCH = 0x1, | 660 RELAUNCH = 0x1, |
| 694 HAS_ID = 0x2, | 661 HAS_ID = 0x2, |
| 695 }; | 662 }; |
| 696 // Runs a test inside a harness that opens DevTools on a shell window. | 663 // Runs a test inside a harness that opens DevTools on a shell window. |
| 697 void RunTestWithDevTools(const char* name, int test_flags); | 664 void RunTestWithDevTools(const char* name, int test_flags); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 #define MAYBE_WebContentsHasFocus WebContentsHasFocus | 909 #define MAYBE_WebContentsHasFocus WebContentsHasFocus |
| 943 #endif | 910 #endif |
| 944 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_WebContentsHasFocus) { | 911 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_WebContentsHasFocus) { |
| 945 const Extension* extension = LoadAndLaunchPlatformApp("minimal"); | 912 const Extension* extension = LoadAndLaunchPlatformApp("minimal"); |
| 946 ShellWindow* window = CreateShellWindow(extension); | 913 ShellWindow* window = CreateShellWindow(extension); |
| 947 EXPECT_TRUE(window->web_contents()->GetRenderWidgetHostView()->HasFocus()); | 914 EXPECT_TRUE(window->web_contents()->GetRenderWidgetHostView()->HasFocus()); |
| 948 CloseShellWindow(window); | 915 CloseShellWindow(window); |
| 949 } | 916 } |
| 950 | 917 |
| 951 } // namespace extensions | 918 } // namespace extensions |
| OLD | NEW |