// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/scoped_observer.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/browser_action_test_util.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/extensions/lazy_background_page_test_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/bookmarks/test/bookmark_test_helpers.h"
-#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/browser/extension_system.h"
+#include "extensions/browser/process_manager.h"
#include "extensions/common/extension.h"
-#include "extensions/common/switches.h"
+#include "extensions/test/extension_test_message_listener.h"
+#include "extensions/test/result_catcher.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/gurl.h"
using extensions::Extension;
+using extensions::ResultCatcher;
namespace {
LazyBackgroundPageApiTest() {}
virtual ~LazyBackgroundPageApiTest() {}
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- ExtensionApiTest::SetUpCommandLine(command_line);
+ virtual void SetUpOnMainThread() OVERRIDE {
+ ExtensionApiTest::SetUpOnMainThread();
// Set shorter delays to prevent test timeouts.
- command_line->AppendSwitchASCII(
- extensions::switches::kEventPageIdleTime, "1000");
- command_line->AppendSwitchASCII(
- extensions::switches::kEventPageSuspendingTime, "1000");
+ extensions::ProcessManager::SetEventPageIdleTimeForTesting(1);
+ extensions::ProcessManager::SetEventPageSuspendingTimeForTesting(1);
}
// Loads the extension, which temporarily starts the lazy background page
// Open a tab to a URL that will trigger the page action to show.
LazyBackgroundObserver page_complete;
- content::WindowedNotificationObserver page_action_changed(
- extensions::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED,
- content::NotificationService::AllSources());
ui_test_utils::NavigateToURL(
browser(), embedded_test_server()->GetURL("/extensions/test_file.html"));
page_complete.Wait();
EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id()));
// Page action is shown.
- page_action_changed.Wait();
+ WaitForPageActionVisibilityChangeTo(num_page_actions + 1);
EXPECT_EQ(num_page_actions + 1,
browser()->window()->GetLocationBar()->
GetLocationBarForTesting()->PageActionVisibleCount());
// the event page is not loaded.
IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, EventDispatchToTab) {
ResultCatcher catcher;
- catcher.RestrictToProfile(browser()->profile());
+ catcher.RestrictToBrowserContext(browser()->profile());
const extensions::Extension* extension =
LoadExtensionAndWait("event_dispatch_to_tab");