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

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

Issue 11117011: Keep browser process alive while there are platform apps with background pages running. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update new sync tests Created 8 years, 1 month 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_util.cc
diff --git a/chrome/browser/extensions/platform_app_browsertest_util.cc b/chrome/browser/extensions/platform_app_browsertest_util.cc
index 5b26f9bb58c9f3b0dc82ad4b43a5328372ba576f..2f42da21de3be2fb43d0f4e081d97a9e3e3982fb 100644
--- a/chrome/browser/extensions/platform_app_browsertest_util.cc
+++ b/chrome/browser/extensions/platform_app_browsertest_util.cc
@@ -8,10 +8,12 @@
#include "base/stringprintf.h"
#include "chrome/browser/extensions/api/tabs/tabs.h"
#include "chrome/browser/extensions/extension_function_test_utils.h"
+#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/extensions/shell_window_registry.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/extensions/shell_window.h"
+#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h"
@@ -25,46 +27,49 @@ namespace extensions {
void PlatformAppBrowserTest::SetUpCommandLine(CommandLine* command_line) {
// Skips ExtensionApiTest::SetUpCommandLine.
ExtensionBrowserTest::SetUpCommandLine(command_line);
-
- // Make event pages get suspended quicker.
- command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1");
- command_line->AppendSwitchASCII(switches::kEventPageUnloadingTime, "1");
}
-const Extension* PlatformAppBrowserTest::LoadAndLaunchPlatformApp(
- const char* name) {
- content::WindowedNotificationObserver app_loaded_observer(
- content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
- content::NotificationService::AllSources());
-
+const Extension* PlatformAppBrowserTest::LoadPlatformApp(const char* name) {
const Extension* extension = LoadExtension(
test_data_dir_.AppendASCII("platform_apps").AppendASCII(name));
EXPECT_TRUE(extension);
+ return extension;
+}
+
+const Extension* PlatformAppBrowserTest::InstallPlatformApp(
+ const char* name) {
+ const Extension* extension = InstallExtension(
+ test_data_dir_.AppendASCII("platform_apps").AppendASCII(name), 1);
+ EXPECT_TRUE(extension);
+
+ return extension;
+}
+
+const Extension* PlatformAppBrowserTest::LoadAndLaunchPlatformApp(
+ const char* name) {
+ ExtensionTestMessageListener launched_listener("Launched", false);
+
+ const Extension* extension = LoadPlatformApp(name);
application_launch::OpenApplication(application_launch::LaunchParams(
browser()->profile(), extension, extension_misc::LAUNCH_NONE,
NEW_WINDOW));
- app_loaded_observer.Wait();
+ launched_listener.WaitUntilSatisfied();
return extension;
}
const Extension* PlatformAppBrowserTest::InstallAndLaunchPlatformApp(
const char* name) {
- content::WindowedNotificationObserver app_loaded_observer(
- content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
- content::NotificationService::AllSources());
-
- const Extension* extension = InstallExtension(
- test_data_dir_.AppendASCII("platform_apps").AppendASCII(name), 1);
- EXPECT_TRUE(extension);
+ ExtensionTestMessageListener launched_listener("Launched", false);
+ const Extension* extension = InstallPlatformApp(name);
application_launch::OpenApplication(application_launch::LaunchParams(
browser()->profile(), extension, extension_misc::LAUNCH_NONE,
NEW_WINDOW));
- app_loaded_observer.Wait();
+ launched_listener.WaitUntilSatisfied();
return extension;
}
@@ -83,9 +88,8 @@ ShellWindow* PlatformAppBrowserTest::GetFirstShellWindow() {
ShellWindowRegistry::const_iterator iter;
ShellWindowRegistry::ShellWindowSet shell_windows =
app_registry->shell_windows();
- for (iter = shell_windows.begin(); iter != shell_windows.end(); ++iter) {
+ for (iter = shell_windows.begin(); iter != shell_windows.end(); ++iter)
return *iter;
- }
return NULL;
}
@@ -143,12 +147,4 @@ ShellWindow* PlatformAppBrowserTest::CreateShellWindow(
browser()->profile(), extension, GURL(""), params);
}
-void PlatformAppBrowserTest::CloseShellWindow(ShellWindow* window) {
- content::WindowedNotificationObserver destroyed_observer(
- content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
- content::NotificationService::AllSources());
- window->GetBaseWindow()->Close();
- destroyed_observer.Wait();
-}
-
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698