Chromium Code Reviews| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 action->GetBadgeBackgroundColor(ExtensionAction::kDefaultTabId)); | 73 action->GetBadgeBackgroundColor(ExtensionAction::kDefaultTabId)); |
| 74 | 74 |
| 75 // Simulate the browser action being clicked. | 75 // Simulate the browser action being clicked. |
| 76 ui_test_utils::NavigateToURL(browser(), | 76 ui_test_utils::NavigateToURL(browser(), |
| 77 test_server()->GetURL("files/extensions/test_file.txt")); | 77 test_server()->GetURL("files/extensions/test_file.txt")); |
| 78 | 78 |
| 79 ExtensionService* service = browser()->profile()->GetExtensionService(); | 79 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 80 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); | 80 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); |
| 81 | 81 |
| 82 // Verify the command worked. | 82 // Verify the command worked. |
| 83 WebContents* tab = browser()->GetSelectedWebContents(); | 83 WebContents* tab = browser()->GetActiveWebContents(); |
|
Aaron Boodman
2012/06/11 22:04:26
Do these have the exact same semantics?
| |
| 84 bool result = false; | 84 bool result = false; |
| 85 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 85 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 86 tab->GetRenderViewHost(), L"", | 86 tab->GetRenderViewHost(), L"", |
| 87 L"setInterval(function(){" | 87 L"setInterval(function(){" |
| 88 L" if(document.body.bgColor == 'red'){" | 88 L" if(document.body.bgColor == 'red'){" |
| 89 L" window.domAutomationController.send(true)}}, 100)", | 89 L" window.domAutomationController.send(true)}}, 100)", |
| 90 &result)); | 90 &result)); |
| 91 ASSERT_TRUE(result); | 91 ASSERT_TRUE(result); |
| 92 } | 92 } |
| 93 | 93 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 EXPECT_TRUE(actions_bar.HidePopup()); | 189 EXPECT_TRUE(actions_bar.HidePopup()); |
| 190 } | 190 } |
| 191 | 191 |
| 192 // Test that calling chrome.browserAction.setPopup() can enable and change | 192 // Test that calling chrome.browserAction.setPopup() can enable and change |
| 193 // a popup. | 193 // a popup. |
| 194 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionAddPopup) { | 194 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionAddPopup) { |
| 195 ASSERT_TRUE(RunExtensionTest("browser_action/add_popup")) << message_; | 195 ASSERT_TRUE(RunExtensionTest("browser_action/add_popup")) << message_; |
| 196 const Extension* extension = GetSingleLoadedExtension(); | 196 const Extension* extension = GetSingleLoadedExtension(); |
| 197 ASSERT_TRUE(extension) << message_; | 197 ASSERT_TRUE(extension) << message_; |
| 198 | 198 |
| 199 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedWebContents()); | 199 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetActiveWebContents()); |
| 200 | 200 |
| 201 ExtensionAction* browser_action = extension->browser_action(); | 201 ExtensionAction* browser_action = extension->browser_action(); |
| 202 ASSERT_TRUE(browser_action) | 202 ASSERT_TRUE(browser_action) |
| 203 << "Browser action test extension should have a browser action."; | 203 << "Browser action test extension should have a browser action."; |
| 204 | 204 |
| 205 ASSERT_FALSE(browser_action->HasPopup(tab_id)); | 205 ASSERT_FALSE(browser_action->HasPopup(tab_id)); |
| 206 ASSERT_FALSE(browser_action->HasPopup(ExtensionAction::kDefaultTabId)); | 206 ASSERT_FALSE(browser_action->HasPopup(ExtensionAction::kDefaultTabId)); |
| 207 | 207 |
| 208 // Simulate a click on the browser action icon. The onClicked handler | 208 // Simulate a click on the browser action icon. The onClicked handler |
| 209 // will add a popup. | 209 // will add a popup. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 browser_action->GetPopupUrl(tab_id).path().c_str()); | 244 browser_action->GetPopupUrl(tab_id).path().c_str()); |
| 245 } | 245 } |
| 246 | 246 |
| 247 // Test that calling chrome.browserAction.setPopup() can remove a popup. | 247 // Test that calling chrome.browserAction.setPopup() can remove a popup. |
| 248 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionRemovePopup) { | 248 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionRemovePopup) { |
| 249 // Load the extension, which has a browser action with a default popup. | 249 // Load the extension, which has a browser action with a default popup. |
| 250 ASSERT_TRUE(RunExtensionTest("browser_action/remove_popup")) << message_; | 250 ASSERT_TRUE(RunExtensionTest("browser_action/remove_popup")) << message_; |
| 251 const Extension* extension = GetSingleLoadedExtension(); | 251 const Extension* extension = GetSingleLoadedExtension(); |
| 252 ASSERT_TRUE(extension) << message_; | 252 ASSERT_TRUE(extension) << message_; |
| 253 | 253 |
| 254 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedWebContents()); | 254 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetActiveWebContents()); |
| 255 | 255 |
| 256 ExtensionAction* browser_action = extension->browser_action(); | 256 ExtensionAction* browser_action = extension->browser_action(); |
| 257 ASSERT_TRUE(browser_action) | 257 ASSERT_TRUE(browser_action) |
| 258 << "Browser action test extension should have a browser action."; | 258 << "Browser action test extension should have a browser action."; |
| 259 | 259 |
| 260 ASSERT_TRUE(browser_action->HasPopup(tab_id)) | 260 ASSERT_TRUE(browser_action->HasPopup(tab_id)) |
| 261 << "Expect a browser action popup before the test removes it."; | 261 << "Expect a browser action popup before the test removes it."; |
| 262 ASSERT_TRUE(browser_action->HasPopup(ExtensionAction::kDefaultTabId)) | 262 ASSERT_TRUE(browser_action->HasPopup(ExtensionAction::kDefaultTabId)) |
| 263 << "Expect a browser action popup is the default for all tabs."; | 263 << "Expect a browser action popup is the default for all tabs."; |
| 264 | 264 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 458 ResultCatcher catcher; | 458 ResultCatcher catcher; |
| 459 ui_test_utils::NavigateToURL(browser(), | 459 ui_test_utils::NavigateToURL(browser(), |
| 460 GURL(extension->GetResourceURL("update.html"))); | 460 GURL(extension->GetResourceURL("update.html"))); |
| 461 ASSERT_TRUE(catcher.GetNextResult()); | 461 ASSERT_TRUE(catcher.GetNextResult()); |
| 462 | 462 |
| 463 // Test the getters for a specific tab. | 463 // Test the getters for a specific tab. |
| 464 ui_test_utils::NavigateToURL(browser(), | 464 ui_test_utils::NavigateToURL(browser(), |
| 465 GURL(extension->GetResourceURL("update2.html"))); | 465 GURL(extension->GetResourceURL("update2.html"))); |
| 466 ASSERT_TRUE(catcher.GetNextResult()); | 466 ASSERT_TRUE(catcher.GetNextResult()); |
| 467 } | 467 } |
| OLD | NEW |