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

Unified Diff: chrome/browser/extensions/platform_app_browsertest.cc

Issue 11299326: Revert 170660 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/platform_app_browsertest.cc
===================================================================
--- chrome/browser/extensions/platform_app_browsertest.cc (revision 170888)
+++ chrome/browser/extensions/platform_app_browsertest.cc (working copy)
@@ -20,12 +20,10 @@
#include "chrome/browser/extensions/platform_app_browsertest_util.h"
#include "chrome/browser/extensions/platform_app_launcher.h"
#include "chrome/browser/extensions/shell_window_registry.h"
-#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/tab_contents/render_view_context_menu.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
-#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/constrained_window_tab_helper.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/extensions/native_app_window.h"
@@ -149,8 +147,6 @@
} // namespace
-// TODO(benwells): Break up this file into some sensible smaller files.
-
// Tests that CreateShellWindow doesn't crash if you close it straight away.
// LauncherPlatformAppBrowserTest relies on this behaviour, but is only run for
// ash, so we test that it works here.
@@ -158,7 +154,6 @@
const Extension* extension = LoadAndLaunchPlatformApp("minimal");
ShellWindow* window = CreateShellWindow(extension);
CloseShellWindow(window);
- CloseShellWindowsAndWaitForAppToExit();
}
// Tests that platform apps can be launched in incognito mode without crashing.
@@ -183,18 +178,8 @@
NEW_WINDOW));
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
- CloseShellWindowsAndWaitForAppToExit();
}
-// Tests that the browser process is kept alive by the platform app's background
-// page.
-IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppEventPageKeepsBrowserAlive) {
- LoadAndLaunchPlatformApp("minimal");
- browser()->window()->Close();
- ASSERT_TRUE(browser::WillKeepAlive());
- CloseShellWindowsAndWaitForAppToExit();
-}
-
// Tests that platform apps received the "launch" event when launched.
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OnLaunchedEvent) {
ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch")) << message_;
@@ -227,7 +212,6 @@
web_contents);
ASSERT_TRUE(handler.WaitUntilReply());
- CloseShellWindowsAndWaitForAppToExit();
}
// Tests that platform apps cannot use certain disabled window properties, but
@@ -238,8 +222,11 @@
}
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();
@@ -255,12 +242,16 @@
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();
@@ -279,12 +270,16 @@
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();
@@ -303,12 +298,16 @@
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();
@@ -328,12 +327,16 @@
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();
@@ -353,12 +356,16 @@
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);
@@ -376,15 +383,13 @@
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(RunPlatformAppTestReturnImmediately("platform_apps/navigation"))
- << message_;
+ ASSERT_TRUE(RunPlatformAppTest("platform_apps/navigation")) << message_;
observer.Wait();
ASSERT_EQ(2U, observer.tabs().size());
@@ -392,8 +397,6 @@
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) {
@@ -463,7 +466,9 @@
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();
@@ -480,12 +485,13 @@
// 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
@@ -530,7 +536,6 @@
message_ = catcher.message();
ASSERT_TRUE(0);
}
- CloseShellWindowsAndWaitForAppToExit();
}
// Tests that no launch data is sent through if the file is of the wrong MIME
@@ -597,8 +602,6 @@
LoadAndLaunchPlatformApp("open_link");
observer.Wait();
ASSERT_EQ(2, browser()->tab_count());
- browser()->window()->Close();
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) {
@@ -670,8 +673,6 @@
// Wait for javascript to verify that the second window got the updated
// coordinates, ignoring the default coordinates passed to the create method.
ASSERT_TRUE(done2_listener.WaitUntilSatisfied());
-
- CloseShellWindowsAndWaitForAppToExit();
}
// Tests that a running app is recorded in the preferences as such.
@@ -703,7 +704,6 @@
AppRestoreServiceFactory::GetForProfile(browser()->profile())->
HandleStartup(true);
restart_listener.WaitUntilSatisfied();
- CloseShellWindowsAndWaitForAppToExit();
}
namespace {
@@ -721,8 +721,10 @@
void PlatformAppDevToolsBrowserTest::RunTestWithDevTools(
const char* name, int test_flags) {
using content::DevToolsAgentHostRegistry;
+ ExtensionTestMessageListener launched_listener("Launched", false);
const Extension* extension = LoadAndLaunchPlatformApp(name);
ASSERT_TRUE(extension);
+ ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
ShellWindow* window = GetFirstShellWindow();
ASSERT_TRUE(window);
ASSERT_EQ(window->window_key().empty(), (test_flags & HAS_ID) == 0);
@@ -760,7 +762,6 @@
ASSERT_TRUE(rvh);
ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh));
}
- CloseShellWindowsAndWaitForAppToExit();
}
} // namespace
@@ -802,19 +803,14 @@
ExtensionTestMessageListener listener("PermissionRequestDone", false);
constrained_window_tab_helper->CloseConstrainedWindows();
ASSERT_TRUE(listener.WaitUntilSatisfied());
-
- CloseShellWindowsAndWaitForAppToExit();
}
// Tests that an app calling chrome.runtime.reload will reload the app and
// relaunch it if it was running.
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) {
ExtensionTestMessageListener launched_listener("Launched", true);
- const Extension* extension = LoadPlatformApp("reload");
+ const Extension* extension = LoadAndLaunchPlatformApp("reload");
ASSERT_TRUE(extension);
- application_launch::OpenApplication(application_launch::LaunchParams(
- browser()->profile(), extension, extension_misc::LAUNCH_NONE,
- NEW_WINDOW));
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
ASSERT_TRUE(GetFirstShellWindow());
@@ -823,7 +819,6 @@
launched_listener.Reply("reload");
ASSERT_TRUE(launched_listener2.WaitUntilSatisfied());
ASSERT_TRUE(GetFirstShellWindow());
- CloseShellWindowsAndWaitForAppToExit();
}
namespace {
@@ -885,8 +880,6 @@
NEW_WINDOW));
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
-
- CloseShellWindowsAndWaitForAppToExit();
}
// Component App Test 2 of 3: ensure an installed component app can be launched
@@ -929,8 +922,6 @@
extension_prefs->pref_service()->RegisterStringPref(
pref_path.c_str(), std::string(), PrefServiceBase::UNSYNCABLE_PREF);
extension_prefs->pref_service()->Set(pref_path.c_str(), old_version);
-
- CloseShellWindowsAndWaitForAppToExit();
}
// Component App Test 3 of 3: simulate a component extension upgrade that
@@ -954,8 +945,6 @@
NEW_WINDOW));
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
-
- CloseShellWindowsAndWaitForAppToExit();
}
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/extension_host.cc ('k') | chrome/browser/extensions/platform_app_browsertest_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698