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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "chrome/browser/extensions/extension_action.h" | 6 #include "chrome/browser/extensions/extension_action.h" |
7 #include "chrome/browser/extensions/extension_action_manager.h" | 7 #include "chrome/browser/extensions/extension_action_manager.h" |
| 8 #include "chrome/browser/extensions/extension_action_test_util.h" |
8 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_tab_util.h" | 11 #include "chrome/browser/extensions/extension_tab_util.h" |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
13 #include "chrome/browser/ui/location_bar/location_bar.h" | |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
16 #include "extensions/browser/extension_system.h" | 16 #include "extensions/browser/extension_system.h" |
17 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
18 #include "extensions/common/switches.h" | 18 #include "extensions/common/switches.h" |
19 | 19 |
20 namespace extensions { | 20 namespace extensions { |
21 namespace { | 21 namespace { |
22 | 22 |
23 const std::string kFeedPage = "files/feeds/feed.html"; | 23 const std::string kFeedPage = "files/feeds/feed.html"; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, UnloadPageAction) { | 101 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, UnloadPageAction) { |
102 ASSERT_TRUE(test_server()->Start()); | 102 ASSERT_TRUE(test_server()->Start()); |
103 | 103 |
104 base::FilePath extension_path( | 104 base::FilePath extension_path( |
105 test_data_dir_.AppendASCII("subscribe_page_action")); | 105 test_data_dir_.AppendASCII("subscribe_page_action")); |
106 ASSERT_TRUE(LoadExtension(extension_path)); | 106 ASSERT_TRUE(LoadExtension(extension_path)); |
107 | 107 |
108 // Navigation prompts the location bar to load page actions. | 108 // Navigation prompts the location bar to load page actions. |
109 GURL feed_url = test_server()->GetURL(kFeedPage); | 109 GURL feed_url = test_server()->GetURL(kFeedPage); |
110 ui_test_utils::NavigateToURL(browser(), feed_url); | 110 ui_test_utils::NavigateToURL(browser(), feed_url); |
111 LocationBarTesting* location_bar = | 111 content::WebContents* tab = |
112 browser()->window()->GetLocationBar()->GetLocationBarForTesting(); | 112 browser()->tab_strip_model()->GetActiveWebContents(); |
113 EXPECT_EQ(1, location_bar->PageActionCount()); | 113 EXPECT_EQ(1u, extension_action_test_util::GetTotalPageActionCount(tab)); |
114 | 114 |
115 UnloadExtension(last_loaded_extension_id()); | 115 UnloadExtension(last_loaded_extension_id()); |
116 | 116 |
117 // Make sure the page action goes away when it's unloaded. | 117 // Make sure the page action goes away when it's unloaded. |
118 EXPECT_EQ(0, location_bar->PageActionCount()); | 118 EXPECT_EQ(0u, extension_action_test_util::GetTotalPageActionCount(tab)); |
119 } | 119 } |
120 | 120 |
121 // Tests that we can load page actions in the Omnibox. | 121 // Tests that we can load page actions in the Omnibox. |
122 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PageActionRefreshCrash) { | 122 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PageActionRefreshCrash) { |
123 base::TimeTicks start_time = base::TimeTicks::Now(); | 123 base::TimeTicks start_time = base::TimeTicks::Now(); |
124 | 124 |
125 ExtensionService* service = extensions::ExtensionSystem::Get( | 125 ExtensionService* service = extensions::ExtensionSystem::Get( |
126 browser()->profile())->extension_service(); | 126 browser()->profile())->extension_service(); |
127 | 127 |
128 size_t size_before = service->extensions()->size(); | 128 size_t size_before = service->extensions()->size(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 int tab_id = ExtensionTabUtil::GetTabId( | 201 int tab_id = ExtensionTabUtil::GetTabId( |
202 browser()->tab_strip_model()->GetActiveWebContents()); | 202 browser()->tab_strip_model()->GetActiveWebContents()); |
203 EXPECT_STREQ(base::WideToUTF8(L"Hreggvi\u00F0ur").c_str(), | 203 EXPECT_STREQ(base::WideToUTF8(L"Hreggvi\u00F0ur").c_str(), |
204 ExtensionActionManager::Get(browser()->profile())-> | 204 ExtensionActionManager::Get(browser()->profile())-> |
205 GetPageAction(*extension)-> | 205 GetPageAction(*extension)-> |
206 GetTitle(tab_id).c_str()); | 206 GetTitle(tab_id).c_str()); |
207 } | 207 } |
208 | 208 |
209 } // namespace | 209 } // namespace |
210 } // namespace extensions | 210 } // namespace extensions |
OLD | NEW |