| 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 |
| 11 #include "chrome/browser/extensions/browser_action_test_util.h" | 11 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 12 #include "chrome/browser/extensions/extension_apitest.h" | 12 #include "chrome/browser/extensions/extension_apitest.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/extensions/extension_tab_util.h" | 14 #include "chrome/browser/extensions/extension_tab_util.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_commands.h" | 17 #include "chrome/browser/ui/browser_commands.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/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/extensions/extension_action.h" | 21 #include "chrome/common/extensions/extension_action.h" |
| 22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 23 #include "chrome/test/base/ui_test_utils.h" | 23 #include "chrome/test/base/ui_test_utils.h" |
| 24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "content/public/test/browser_test_utils.h" |
| 26 #include "ui/gfx/rect.h" | 27 #include "ui/gfx/rect.h" |
| 27 #include "ui/gfx/size.h" | 28 #include "ui/gfx/size.h" |
| 28 | 29 |
| 29 using content::WebContents; | 30 using content::WebContents; |
| 30 using extensions::Extension; | 31 using extensions::Extension; |
| 31 | 32 |
| 32 class BrowserActionApiTest : public ExtensionApiTest { | 33 class BrowserActionApiTest : public ExtensionApiTest { |
| 33 public: | 34 public: |
| 34 BrowserActionApiTest() {} | 35 BrowserActionApiTest() {} |
| 35 virtual ~BrowserActionApiTest() {} | 36 virtual ~BrowserActionApiTest() {} |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // Simulate the browser action being clicked. | 77 // Simulate the browser action being clicked. |
| 77 ui_test_utils::NavigateToURL(browser(), | 78 ui_test_utils::NavigateToURL(browser(), |
| 78 test_server()->GetURL("files/extensions/test_file.txt")); | 79 test_server()->GetURL("files/extensions/test_file.txt")); |
| 79 | 80 |
| 80 ExtensionService* service = browser()->profile()->GetExtensionService(); | 81 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 81 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); | 82 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); |
| 82 | 83 |
| 83 // Verify the command worked. | 84 // Verify the command worked. |
| 84 WebContents* tab = chrome::GetActiveWebContents(browser()); | 85 WebContents* tab = chrome::GetActiveWebContents(browser()); |
| 85 bool result = false; | 86 bool result = false; |
| 86 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 87 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 87 tab->GetRenderViewHost(), L"", | 88 tab->GetRenderViewHost(), L"", |
| 88 L"setInterval(function(){" | 89 L"setInterval(function(){" |
| 89 L" if(document.body.bgColor == 'red'){" | 90 L" if(document.body.bgColor == 'red'){" |
| 90 L" window.domAutomationController.send(true)}}, 100)", | 91 L" window.domAutomationController.send(true)}}, 100)", |
| 91 &result)); | 92 &result)); |
| 92 ASSERT_TRUE(result); | 93 ASSERT_TRUE(result); |
| 93 } | 94 } |
| 94 | 95 |
| 95 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { | 96 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { |
| 96 ASSERT_TRUE(RunExtensionTest("browser_action/no_icon")) << message_; | 97 ASSERT_TRUE(RunExtensionTest("browser_action/no_icon")) << message_; |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 ResultCatcher catcher; | 462 ResultCatcher catcher; |
| 462 ui_test_utils::NavigateToURL(browser(), | 463 ui_test_utils::NavigateToURL(browser(), |
| 463 GURL(extension->GetResourceURL("update.html"))); | 464 GURL(extension->GetResourceURL("update.html"))); |
| 464 ASSERT_TRUE(catcher.GetNextResult()); | 465 ASSERT_TRUE(catcher.GetNextResult()); |
| 465 | 466 |
| 466 // Test the getters for a specific tab. | 467 // Test the getters for a specific tab. |
| 467 ui_test_utils::NavigateToURL(browser(), | 468 ui_test_utils::NavigateToURL(browser(), |
| 468 GURL(extension->GetResourceURL("update2.html"))); | 469 GURL(extension->GetResourceURL("update2.html"))); |
| 469 ASSERT_TRUE(catcher.GetNextResult()); | 470 ASSERT_TRUE(catcher.GetNextResult()); |
| 470 } | 471 } |
| OLD | NEW |