Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: chrome/browser/extensions/api/extension_action/browser_action_apitest.cc

Issue 10909256: Always send the full tab object in ExtensionAction click event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: kalments Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/messaging/message_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 const Extension* extension = GetSingleLoadedExtension(); 94 const Extension* extension = GetSingleLoadedExtension();
95 ASSERT_TRUE(extension) << message_; 95 ASSERT_TRUE(extension) << message_;
96 96
97 // Test that there is a browser action in the toolbar. 97 // Test that there is a browser action in the toolbar.
98 ASSERT_EQ(1, GetBrowserActionsBar().NumberOfBrowserActions()); 98 ASSERT_EQ(1, GetBrowserActionsBar().NumberOfBrowserActions());
99 99
100 // Tell the extension to update the browser action state. 100 // Tell the extension to update the browser action state.
101 ResultCatcher catcher; 101 ResultCatcher catcher;
102 ui_test_utils::NavigateToURL(browser(), 102 ui_test_utils::NavigateToURL(browser(),
103 GURL(extension->GetResourceURL("update.html"))); 103 GURL(extension->GetResourceURL("update.html")));
104 ASSERT_TRUE(catcher.GetNextResult()); 104 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
105 105
106 // Test that we received the changes. 106 // Test that we received the changes.
107 ExtensionAction* action = extension->browser_action(); 107 ExtensionAction* action = extension->browser_action();
108 ASSERT_EQ("Modified", action->GetTitle(ExtensionAction::kDefaultTabId)); 108 ASSERT_EQ("Modified", action->GetTitle(ExtensionAction::kDefaultTabId));
109 ASSERT_EQ("badge", action->GetBadgeText(ExtensionAction::kDefaultTabId)); 109 ASSERT_EQ("badge", action->GetBadgeText(ExtensionAction::kDefaultTabId));
110 ASSERT_EQ(SkColorSetARGB(255, 255, 255, 255), 110 ASSERT_EQ(SkColorSetARGB(255, 255, 255, 255),
111 action->GetBadgeBackgroundColor(ExtensionAction::kDefaultTabId)); 111 action->GetBadgeBackgroundColor(ExtensionAction::kDefaultTabId));
112 112
113 // Simulate the browser action being clicked. 113 // Simulate the browser action being clicked.
114 ui_test_utils::NavigateToURL(browser(), 114 ui_test_utils::NavigateToURL(browser(),
115 test_server()->GetURL("files/extensions/test_file.txt")); 115 test_server()->GetURL("files/extensions/test_file.txt"));
116 116
117 ExtensionService* service = browser()->profile()->GetExtensionService(); 117 ExtensionService* service = browser()->profile()->GetExtensionService();
118 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); 118 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL);
119 119
120 // Verify the command worked. 120 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
121 WebContents* tab = chrome::GetActiveWebContents(browser());
122 bool result = false;
123 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
124 tab->GetRenderViewHost(), L"",
125 L"setInterval(function(){"
126 L" if(document.body.bgColor == 'red'){"
127 L" window.domAutomationController.send(true)}}, 100)",
128 &result));
129 ASSERT_TRUE(result);
130 } 121 }
131 122
132 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { 123 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) {
133 ASSERT_TRUE(RunExtensionTest("browser_action/no_icon")) << message_; 124 ASSERT_TRUE(RunExtensionTest("browser_action/no_icon")) << message_;
134 const Extension* extension = GetSingleLoadedExtension(); 125 const Extension* extension = GetSingleLoadedExtension();
135 ASSERT_TRUE(extension) << message_; 126 ASSERT_TRUE(extension) << message_;
136 127
137 #if defined (OS_MACOSX) 128 #if defined (OS_MACOSX)
138 // We need this on mac so we don't loose 2x representations from browser icon 129 // We need this on mac so we don't loose 2x representations from browser icon
139 // in transformations gfx::ImageSkia -> NSImage -> gfx::ImageSkia. 130 // in transformations gfx::ImageSkia -> NSImage -> gfx::ImageSkia.
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 GURL(extension->GetResourceURL("update.html"))); 635 GURL(extension->GetResourceURL("update.html")));
645 ASSERT_TRUE(catcher.GetNextResult()); 636 ASSERT_TRUE(catcher.GetNextResult());
646 637
647 // Test the getters for a specific tab. 638 // Test the getters for a specific tab.
648 ui_test_utils::NavigateToURL(browser(), 639 ui_test_utils::NavigateToURL(browser(),
649 GURL(extension->GetResourceURL("update2.html"))); 640 GURL(extension->GetResourceURL("update2.html")));
650 ASSERT_TRUE(catcher.GetNextResult()); 641 ASSERT_TRUE(catcher.GetNextResult());
651 } 642 }
652 643
653 } // namespace 644 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/messaging/message_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698