| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 10 #include "chrome/browser/extensions/browser_action_test_util.h" | 10 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 11 #include "chrome/browser/extensions/extension_apitest.h" | 11 #include "chrome/browser/extensions/extension_apitest.h" |
| 12 #include "chrome/browser/extensions/extension_host.h" | 12 #include "chrome/browser/extensions/extension_host.h" |
| 13 #include "chrome/browser/extensions/extension_test_message_listener.h" | 13 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/extensions/lazy_background_page_test_util.h" | 15 #include "chrome/browser/extensions/lazy_background_page_test_util.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_tabstrip.h" | 18 #include "chrome/browser/ui/browser_tabstrip.h" |
| 19 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
| 20 #include "chrome/browser/ui/omnibox/location_bar.h" | 20 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 21 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
| 22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/extensions/extension.h" | 23 #include "chrome/common/extensions/extension.h" |
| 24 #include "chrome/common/url_constants.h" |
| 24 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/test/browser_test_utils.h" | 28 #include "content/public/test/browser_test_utils.h" |
| 28 #include "googleurl/src/gurl.h" | 29 #include "googleurl/src/gurl.h" |
| 29 #include "net/base/mock_host_resolver.h" | 30 #include "net/base/mock_host_resolver.h" |
| 30 | 31 |
| 31 using extensions::Extension; | 32 using extensions::Extension; |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 105 |
| 105 // Observe background page being created and closed after | 106 // Observe background page being created and closed after |
| 106 // the browser action is clicked. | 107 // the browser action is clicked. |
| 107 LazyBackgroundObserver page_complete; | 108 LazyBackgroundObserver page_complete; |
| 108 BrowserActionTestUtil(browser()).Press(0); | 109 BrowserActionTestUtil(browser()).Press(0); |
| 109 page_complete.Wait(); | 110 page_complete.Wait(); |
| 110 | 111 |
| 111 // Background page created a new tab before it closed. | 112 // Background page created a new tab before it closed. |
| 112 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); | 113 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); |
| 113 EXPECT_EQ(num_tabs_before + 1, browser()->tab_count()); | 114 EXPECT_EQ(num_tabs_before + 1, browser()->tab_count()); |
| 114 EXPECT_EQ("chrome://chrome/extensions/", | 115 EXPECT_EQ(std::string(chrome::kChromeUIExtensionsURL), |
| 115 chrome::GetActiveWebContents(browser())->GetURL().spec()); | 116 chrome::GetActiveWebContents(browser())->GetURL().spec()); |
| 116 } | 117 } |
| 117 | 118 |
| 118 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, | 119 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, |
| 119 BrowserActionCreateTabAfterCallback) { | 120 BrowserActionCreateTabAfterCallback) { |
| 120 ASSERT_TRUE(LoadExtensionAndWait("browser_action_with_callback")); | 121 ASSERT_TRUE(LoadExtensionAndWait("browser_action_with_callback")); |
| 121 | 122 |
| 122 // Lazy Background Page doesn't exist yet. | 123 // Lazy Background Page doesn't exist yet. |
| 123 ExtensionProcessManager* pm = | 124 ExtensionProcessManager* pm = |
| 124 browser()->profile()->GetExtensionProcessManager(); | 125 browser()->profile()->GetExtensionProcessManager(); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); | 368 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); |
| 368 | 369 |
| 369 // The browser action has a new title. | 370 // The browser action has a new title. |
| 370 BrowserActionTestUtil browser_action(browser()); | 371 BrowserActionTestUtil browser_action(browser()); |
| 371 ASSERT_EQ(1, browser_action.NumberOfBrowserActions()); | 372 ASSERT_EQ(1, browser_action.NumberOfBrowserActions()); |
| 372 EXPECT_EQ("Success", browser_action.GetTooltip(0)); | 373 EXPECT_EQ("Success", browser_action.GetTooltip(0)); |
| 373 } | 374 } |
| 374 | 375 |
| 375 // TODO: background page with timer. | 376 // TODO: background page with timer. |
| 376 // TODO: background page that interacts with popup. | 377 // TODO: background page that interacts with popup. |
| OLD | NEW |