Chromium Code Reviews| Index: chrome/browser/extensions/lazy_background_page_apitest.cc |
| diff --git a/chrome/browser/extensions/lazy_background_page_apitest.cc b/chrome/browser/extensions/lazy_background_page_apitest.cc |
| index 7a4f85f52ea23df1fd364ba45e87fb4046afcb21..02434b805888867f68f749af3f8912b5374d3008 100644 |
| --- a/chrome/browser/extensions/lazy_background_page_apitest.cc |
| +++ b/chrome/browser/extensions/lazy_background_page_apitest.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/strings/utf_string_conversions.h" |
| #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| #include "chrome/browser/extensions/browser_action_test_util.h" |
| +#include "chrome/browser/extensions/extension_action_test_util.h" |
| #include "chrome/browser/extensions/extension_apitest.h" |
| #include "chrome/browser/extensions/lazy_background_page_test_util.h" |
| #include "chrome/browser/profiles/profile.h" |
| @@ -41,8 +42,8 @@ |
| using bookmarks::BookmarkModel; |
| using bookmarks::BookmarkNode; |
| -using extensions::Extension; |
| -using extensions::ResultCatcher; |
| + |
| +namespace extensions { |
| namespace { |
| @@ -52,12 +53,11 @@ namespace { |
| // incognito involves reloading the extension - and the background pages may |
| // have already loaded once before then. So we wait until the extension is |
| // unloaded before listening to the background page notifications. |
| -class LoadedIncognitoObserver : public extensions::ExtensionRegistryObserver { |
| +class LoadedIncognitoObserver : public ExtensionRegistryObserver { |
| public: |
| explicit LoadedIncognitoObserver(Profile* profile) |
| : profile_(profile), extension_registry_observer_(this) { |
| - extension_registry_observer_.Add( |
| - extensions::ExtensionRegistry::Get(profile_)); |
| + extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); |
| } |
| void Wait() { |
| @@ -67,18 +67,16 @@ class LoadedIncognitoObserver : public extensions::ExtensionRegistryObserver { |
| } |
| private: |
| - void OnExtensionUnloaded( |
| - content::BrowserContext* browser_context, |
| - const Extension* extension, |
| - extensions::UnloadedExtensionInfo::Reason reason) override { |
| + void OnExtensionUnloaded(content::BrowserContext* browser_context, |
| + const Extension* extension, |
| + UnloadedExtensionInfo::Reason reason) override { |
| original_complete_.reset(new LazyBackgroundObserver(profile_)); |
| incognito_complete_.reset( |
| new LazyBackgroundObserver(profile_->GetOffTheRecordProfile())); |
| } |
| Profile* profile_; |
| - ScopedObserver<extensions::ExtensionRegistry, |
| - extensions::ExtensionRegistryObserver> |
| + ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| extension_registry_observer_; |
| scoped_ptr<LazyBackgroundObserver> original_complete_; |
| scoped_ptr<LazyBackgroundObserver> incognito_complete_; |
| @@ -94,8 +92,8 @@ class LazyBackgroundPageApiTest : public ExtensionApiTest { |
| void SetUpInProcessBrowserTestFixture() override { |
| ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| // Set shorter delays to prevent test timeouts. |
| - extensions::ProcessManager::SetEventPageIdleTimeForTesting(1); |
| - extensions::ProcessManager::SetEventPageSuspendingTimeForTesting(1); |
| + ProcessManager::SetEventPageIdleTimeForTesting(1); |
| + ProcessManager::SetEventPageSuspendingTimeForTesting(1); |
| } |
| void SetUpCommandLine(base::CommandLine* command_line) override { |
| @@ -121,8 +119,7 @@ class LazyBackgroundPageApiTest : public ExtensionApiTest { |
| // Returns true if the lazy background page for the extension with |
| // |extension_id| is still running. |
| bool IsBackgroundPageAlive(const std::string& extension_id) { |
| - extensions::ProcessManager* pm = |
| - extensions::ProcessManager::Get(browser()->profile()); |
| + ProcessManager* pm = ProcessManager::Get(browser()->profile()); |
| return pm->GetBackgroundHostForExtension(extension_id); |
| } |
| @@ -191,9 +188,9 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, BroadcastEvent) { |
| // Page action is shown. |
| WaitForPageActionVisibilityChangeTo(num_page_actions + 1); |
| - EXPECT_EQ(num_page_actions + 1, |
| - browser()->window()->GetLocationBar()-> |
| - GetLocationBarForTesting()->PageActionVisibleCount()); |
| + EXPECT_EQ(static_cast<size_t>(num_page_actions + 1), |
| + extension_action_test_util::GetVisiblePageActionCount( |
|
Devlin
2015/09/21 23:28:15
This handy method checks for page actions in the r
|
| + browser()->tab_strip_model()->GetActiveWebContents())); |
| } |
| IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, Filters) { |
| @@ -239,8 +236,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, WaitForDialog) { |
| EXPECT_TRUE(IsBackgroundPageAlive(extension->id())); |
| // Close the dialog. The keep alive count is decremented. |
| - extensions::ProcessManager* pm = |
| - extensions::ProcessManager::Get(browser()->profile()); |
| + ProcessManager* pm = ProcessManager::Get(browser()->profile()); |
| int previous_keep_alive_count = pm->GetLazyKeepaliveCount(extension); |
| dialog->CloseModalDialog(); |
| EXPECT_EQ(previous_keep_alive_count - 1, |
| @@ -295,9 +291,8 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, WaitForRequest) { |
| EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| // Lazy Background Page still exists, because the extension started a request. |
| - extensions::ProcessManager* pm = |
| - extensions::ProcessManager::Get(browser()->profile()); |
| - extensions::ExtensionHost* host = |
| + ProcessManager* pm = ProcessManager::Get(browser()->profile()); |
| + ExtensionHost* host = |
| pm->GetBackgroundHostForExtension(last_loaded_extension_id()); |
| ASSERT_TRUE(host); |
| @@ -399,10 +394,8 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, DISABLED_IncognitoSplitMode) { |
| } |
| // Lazy Background Page doesn't exist yet. |
| - extensions::ProcessManager* pm = |
| - extensions::ProcessManager::Get(browser()->profile()); |
| - extensions::ProcessManager* pmi = |
| - extensions::ProcessManager::Get(incognito_browser->profile()); |
| + ProcessManager* pm = ProcessManager::Get(browser()->profile()); |
| + ProcessManager* pmi = ProcessManager::Get(incognito_browser->profile()); |
| EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); |
| EXPECT_FALSE(pmi->GetBackgroundHostForExtension(last_loaded_extension_id())); |
| @@ -488,8 +481,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, ImpulseAddsCount) { |
| ASSERT_TRUE(extension); |
| // Lazy Background Page doesn't exist yet. |
| - extensions::ProcessManager* pm = |
| - extensions::ProcessManager::Get(browser()->profile()); |
| + ProcessManager* pm = ProcessManager::Get(browser()->profile()); |
| EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); |
| EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| @@ -535,8 +527,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, EventDispatchToTab) { |
| ResultCatcher catcher; |
| catcher.RestrictToBrowserContext(browser()->profile()); |
| - const extensions::Extension* extension = |
| - LoadExtensionAndWait("event_dispatch_to_tab"); |
| + const Extension* extension = LoadExtensionAndWait("event_dispatch_to_tab"); |
| ExtensionTestMessageListener page_ready("ready", true); |
| GURL page_url = extension->GetResourceURL("page.html"); |
| @@ -630,3 +621,5 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnSuspendUseStorageApi) { |
| // TODO: background page with timer. |
| // TODO: background page that interacts with popup. |
| + |
| +} // namespace extensions |