Index: chrome/browser/extensions/platform_app_browsertest.cc |
diff --git a/chrome/browser/extensions/platform_app_browsertest.cc b/chrome/browser/extensions/platform_app_browsertest.cc |
index 9df1d6d01f492795cb5faed3b2205e0d2efc8c16..493eb19c833dc570c22922d4edd7416dacb13b99 100644 |
--- a/chrome/browser/extensions/platform_app_browsertest.cc |
+++ b/chrome/browser/extensions/platform_app_browsertest.cc |
@@ -21,6 +21,7 @@ |
#include "chrome/browser/extensions/shell_window_registry.h" |
#include "chrome/browser/tab_contents/render_view_context_menu.h" |
#include "chrome/browser/ui/browser.h" |
+#include "chrome/browser/ui/browser_window.h" |
#include "chrome/browser/ui/browser_tabstrip.h" |
#include "chrome/browser/ui/extensions/application_launch.h" |
#include "chrome/browser/ui/extensions/shell_window.h" |
@@ -150,6 +151,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, CreateAndCloseShellWindow) { |
const Extension* extension = LoadAndLaunchPlatformApp("minimal"); |
ShellWindow* window = CreateShellWindow(extension); |
CloseShellWindow(window); |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
// Tests that platform apps can be launched in incognito mode without crashing. |
@@ -168,6 +170,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchAppIncognito) { |
NEW_WINDOW)); |
ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
// Tests that platform apps received the "launch" event when launched. |
@@ -202,6 +205,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchReply) { |
web_contents); |
ASSERT_TRUE(handler.WaitUntilReply()); |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
// Tests that platform apps cannot use certain disabled window properties, but |
@@ -212,11 +216,8 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisabledWindowProperties) { |
} |
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, EmptyContextMenu) { |
- ExtensionTestMessageListener launched_listener("Launched", false); |
LoadAndLaunchPlatformApp("minimal"); |
- ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
- |
// The empty app doesn't add any context menu items, so its menu should |
// only include the developer tools. |
WebContents* web_contents = GetFirstShellWindowWebContents(); |
@@ -232,16 +233,12 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, EmptyContextMenu) { |
ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP)); |
ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); |
ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) { |
- ExtensionTestMessageListener launched_listener("Launched", false); |
LoadAndLaunchPlatformApp("context_menu"); |
- // Wait for the extension to tell us it's initialized its context menus and |
- // launched a window. |
- ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
- |
// The context_menu app has two context menu items. These, along with a |
// separator and the developer tools, is all that should be in the menu. |
WebContents* web_contents = GetFirstShellWindowWebContents(); |
@@ -260,16 +257,12 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) { |
ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); |
ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); |
ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, InstalledAppWithContextMenu) { |
- ExtensionTestMessageListener launched_listener("Launched", false); |
InstallAndLaunchPlatformApp("context_menu"); |
- // Wait for the extension to tell us it's initialized its context menus and |
- // launched a window. |
- ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
- |
// The context_menu app has two context menu items. For an installed app |
// these are all that should be in the menu. |
WebContents* web_contents = GetFirstShellWindowWebContents(); |
@@ -288,16 +281,12 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, InstalledAppWithContextMenu) { |
ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); |
ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); |
ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuTextField) { |
- ExtensionTestMessageListener launched_listener("Launched", false); |
LoadAndLaunchPlatformApp("context_menu"); |
- // Wait for the extension to tell us it's initialized its context menus and |
- // launched a window. |
- ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
- |
// The context_menu app has one context menu item. This, along with a |
// separator and the developer tools, is all that should be in the menu. |
WebContents* web_contents = GetFirstShellWindowWebContents(); |
@@ -317,16 +306,12 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuTextField) { |
ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); |
ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); |
ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuSelection) { |
- ExtensionTestMessageListener launched_listener("Launched", false); |
LoadAndLaunchPlatformApp("context_menu"); |
- // Wait for the extension to tell us it's initialized its context menus and |
- // launched a window. |
- ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
- |
// The context_menu app has one context menu item. This, along with a |
// separator and the developer tools, is all that should be in the menu. |
WebContents* web_contents = GetFirstShellWindowWebContents(); |
@@ -346,16 +331,12 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuSelection) { |
ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); |
ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); |
ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) { |
- ExtensionTestMessageListener launched_listener("Launched", false); |
LoadAndLaunchPlatformApp("context_menu_click"); |
- // Wait for the extension to tell us it's initialized its context menus and |
- // launched a window. |
- ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
- |
// Test that the menu item shows up |
WebContents* web_contents = GetFirstShellWindowWebContents(); |
ASSERT_TRUE(web_contents); |
@@ -373,13 +354,15 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) { |
menu->ExecuteCommand(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST); |
ASSERT_TRUE(onclicked_listener.WaitUntilSatisfied()); |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) { |
TabsAddedNotificationObserver observer(2); |
ASSERT_TRUE(StartTestServer()); |
- ASSERT_TRUE(RunPlatformAppTest("platform_apps/navigation")) << message_; |
+ ASSERT_TRUE(RunPlatformAppTestReturnImmediately("platform_apps/navigation")) |
+ << message_; |
observer.Wait(); |
ASSERT_EQ(2U, observer.tabs().size()); |
@@ -387,6 +370,8 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) { |
observer.tabs()[0]->GetURL().spec()); |
EXPECT_EQ("http://chromium.org/", |
observer.tabs()[1]->GetURL().spec()); |
+ browser()->window()->Close(); |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Iframes) { |
@@ -456,9 +441,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ExtensionWindowingApis) { |
ASSERT_EQ(0U, GetShellWindowCount()); |
// Launch a platform app that shows a window. |
- ExtensionTestMessageListener launched_listener("Launched", false); |
LoadAndLaunchPlatformApp("minimal"); |
- ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
ASSERT_EQ(1U, GetShellWindowCount()); |
ShellWindowRegistry::ShellWindowSet shell_windows = |
ShellWindowRegistry::Get(browser()->profile())->shell_windows(); |
@@ -475,13 +458,12 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ExtensionWindowingApis) { |
// to get a list of all the shell windows, so we can test this. |
// Launch another platform app that also shows a window. |
- ExtensionTestMessageListener launched_listener2("Launched", false); |
LoadAndLaunchPlatformApp("context_menu"); |
- ASSERT_TRUE(launched_listener2.WaitUntilSatisfied()); |
// There are two total shell windows, but each app can only see its own. |
ASSERT_EQ(2U, GetShellWindowCount()); |
// TODO(jeremya): as above, this requires more extension functions. |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
// ChromeOS does not support passing arguments on the command line, so the tests |
@@ -525,6 +507,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithRelativeFile) { |
message_ = catcher.message(); |
ASSERT_TRUE(0); |
} |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
// Tests that no launch data is sent through if the platform app provides |
@@ -599,6 +582,8 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) { |
LoadAndLaunchPlatformApp("open_link"); |
observer.Wait(); |
ASSERT_EQ(2, browser()->tab_count()); |
+ browser()->window()->Close(); |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) { |
@@ -673,6 +658,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, |
// Wait for javascript to verify that the third window got the restored size |
// and explicitly specified coordinates. |
ASSERT_TRUE(done3_listener.WaitUntilSatisfied()); |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
// Tests that a running app is recorded in the preferences as such. |
@@ -704,6 +690,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) { |
AppRestoreServiceFactory::GetForProfile(browser()->profile())-> |
HandleStartup(true); |
restart_listener.WaitUntilSatisfied(); |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
// Tests that relaunching an app with devtools open reopens devtools. |
@@ -757,6 +744,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_DevToolsOpenedWithReload) { |
rvh = window->web_contents()->GetRenderViewHost(); |
ASSERT_TRUE(rvh); |
ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh)); |
+ CloseShellWindowsAndWaitForAppToExit(); |
} |
} // namespace extensions |