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

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

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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
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 "chrome/browser/extensions/browser_event_router.h" 5 #include "chrome/browser/extensions/browser_event_router.h"
6 #include "chrome/browser/extensions/extension_action.h" 6 #include "chrome/browser/extensions/extension_action.h"
7 #include "chrome/browser/extensions/extension_action_icon_factory.h" 7 #include "chrome/browser/extensions/extension_action_icon_factory.h"
8 #include "chrome/browser/extensions/extension_action_manager.h" 8 #include "chrome/browser/extensions/extension_action_manager.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 EXPECT_EQ("Modified", action->GetTitle(tab_id)); 56 EXPECT_EQ("Modified", action->GetTitle(tab_id));
57 57
58 { 58 {
59 // Simulate the page action being clicked. 59 // Simulate the page action being clicked.
60 ResultCatcher catcher; 60 ResultCatcher catcher;
61 int tab_id = ExtensionTabUtil::GetTabId( 61 int tab_id = ExtensionTabUtil::GetTabId(
62 browser()->tab_strip_model()->GetActiveWebContents()); 62 browser()->tab_strip_model()->GetActiveWebContents());
63 ExtensionService* service = extensions::ExtensionSystem::Get( 63 ExtensionService* service = extensions::ExtensionSystem::Get(
64 browser()->profile())->extension_service(); 64 browser()->profile())->extension_service();
65 service->browser_event_router()->PageActionExecuted( 65 service->browser_event_router()->PageActionExecuted(
66 browser()->profile(), *action, tab_id, "", 0); 66 browser()->profile(), *action, tab_id, std::string(), 0);
67 EXPECT_TRUE(catcher.GetNextResult()); 67 EXPECT_TRUE(catcher.GetNextResult());
68 } 68 }
69 69
70 { 70 {
71 // Tell the extension to update the page action state again. 71 // Tell the extension to update the page action state again.
72 ResultCatcher catcher; 72 ResultCatcher catcher;
73 ui_test_utils::NavigateToURL(browser(), 73 ui_test_utils::NavigateToURL(browser(),
74 GURL(extension->GetResourceURL("update2.html"))); 74 GURL(extension->GetResourceURL("update2.html")));
75 ASSERT_TRUE(catcher.GetNextResult()); 75 ASSERT_TRUE(catcher.GetNextResult());
76 } 76 }
(...skipping 24 matching lines...) Expand all
101 101
102 ASSERT_FALSE(page_action->HasPopup(tab_id)); 102 ASSERT_FALSE(page_action->HasPopup(tab_id));
103 103
104 // Simulate the page action being clicked. The resulting event should 104 // Simulate the page action being clicked. The resulting event should
105 // install a page action popup. 105 // install a page action popup.
106 { 106 {
107 ResultCatcher catcher; 107 ResultCatcher catcher;
108 ExtensionService* service = extensions::ExtensionSystem::Get( 108 ExtensionService* service = extensions::ExtensionSystem::Get(
109 browser()->profile())->extension_service(); 109 browser()->profile())->extension_service();
110 service->browser_event_router()->PageActionExecuted( 110 service->browser_event_router()->PageActionExecuted(
111 browser()->profile(), *page_action, tab_id, "", 1); 111 browser()->profile(), *page_action, tab_id, std::string(), 1);
112 ASSERT_TRUE(catcher.GetNextResult()); 112 ASSERT_TRUE(catcher.GetNextResult());
113 } 113 }
114 114
115 ASSERT_TRUE(page_action->HasPopup(tab_id)) 115 ASSERT_TRUE(page_action->HasPopup(tab_id))
116 << "Clicking on the page action should have caused a popup to be added."; 116 << "Clicking on the page action should have caused a popup to be added.";
117 117
118 ASSERT_STREQ("/a_popup.html", 118 ASSERT_STREQ("/a_popup.html",
119 page_action->GetPopupUrl(tab_id).path().c_str()); 119 page_action->GetPopupUrl(tab_id).path().c_str());
120 120
121 // Now change the popup from a_popup.html to a_second_popup.html . 121 // Now change the popup from a_popup.html to a_second_popup.html .
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 // Simulate the page action being clicked. 182 // Simulate the page action being clicked.
183 { 183 {
184 ResultCatcher catcher; 184 ResultCatcher catcher;
185 int tab_id = ExtensionTabUtil::GetTabId( 185 int tab_id = ExtensionTabUtil::GetTabId(
186 browser()->tab_strip_model()->GetActiveWebContents()); 186 browser()->tab_strip_model()->GetActiveWebContents());
187 ExtensionService* service = extensions::ExtensionSystem::Get( 187 ExtensionService* service = extensions::ExtensionSystem::Get(
188 browser()->profile())->extension_service(); 188 browser()->profile())->extension_service();
189 ExtensionAction* page_action = GetPageAction(*extension); 189 ExtensionAction* page_action = GetPageAction(*extension);
190 service->browser_event_router()->PageActionExecuted( 190 service->browser_event_router()->PageActionExecuted(
191 browser()->profile(), *page_action, tab_id, "", 1); 191 browser()->profile(), *page_action, tab_id, std::string(), 1);
192 EXPECT_TRUE(catcher.GetNextResult()); 192 EXPECT_TRUE(catcher.GetNextResult());
193 } 193 }
194 } 194 }
195 195
196 // Tests popups in page actions. 196 // Tests popups in page actions.
197 // Flaky on the trybots. See http://crbug.com/96725. 197 // Flaky on the trybots. See http://crbug.com/96725.
198 IN_PROC_BROWSER_TEST_F(PageActionApiTest, DISABLED_ShowPageActionPopup) { 198 IN_PROC_BROWSER_TEST_F(PageActionApiTest, DISABLED_ShowPageActionPopup) {
199 ASSERT_TRUE(RunExtensionTest("page_action/popup")) << message_; 199 ASSERT_TRUE(RunExtensionTest("page_action/popup")) << message_;
200 const Extension* extension = GetSingleLoadedExtension(); 200 const Extension* extension = GetSingleLoadedExtension();
201 ASSERT_TRUE(extension) << message_; 201 ASSERT_TRUE(extension) << message_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 ASSERT_TRUE(page_action); 253 ASSERT_TRUE(page_action);
254 254
255 { 255 {
256 // Simulate the page action being clicked. 256 // Simulate the page action being clicked.
257 ResultCatcher catcher; 257 ResultCatcher catcher;
258 int tab_id = ExtensionTabUtil::GetTabId( 258 int tab_id = ExtensionTabUtil::GetTabId(
259 browser()->tab_strip_model()->GetActiveWebContents()); 259 browser()->tab_strip_model()->GetActiveWebContents());
260 ExtensionService* service = extensions::ExtensionSystem::Get( 260 ExtensionService* service = extensions::ExtensionSystem::Get(
261 browser()->profile())->extension_service(); 261 browser()->profile())->extension_service();
262 service->browser_event_router()->PageActionExecuted( 262 service->browser_event_router()->PageActionExecuted(
263 browser()->profile(), *page_action, tab_id, "", 0); 263 browser()->profile(), *page_action, tab_id, std::string(), 0);
264 EXPECT_TRUE(catcher.GetNextResult()); 264 EXPECT_TRUE(catcher.GetNextResult());
265 } 265 }
266 266
267 WebContents* tab = 267 WebContents* tab =
268 browser()->tab_strip_model()->GetActiveWebContents(); 268 browser()->tab_strip_model()->GetActiveWebContents();
269 EXPECT_TRUE(tab != NULL); 269 EXPECT_TRUE(tab != NULL);
270 270
271 // Verify that the browser action turned the background color red. 271 // Verify that the browser action turned the background color red.
272 const std::string script = 272 const std::string script =
273 "window.domAutomationController.send(document.body.style." 273 "window.domAutomationController.send(document.body.style."
274 "backgroundColor);"; 274 "backgroundColor);";
275 std::string result; 275 std::string result;
276 const std::string frame_xpath = ""; 276 const std::string frame_xpath;
277 EXPECT_TRUE(content::ExecuteScriptInFrameAndExtractString(tab, 277 EXPECT_TRUE(content::ExecuteScriptInFrameAndExtractString(
278 frame_xpath, 278 tab, frame_xpath, script, &result));
279 script,
280 &result));
281 EXPECT_EQ(result, "red"); 279 EXPECT_EQ(result, "red");
282 } 280 }
283 281
284 } // namespace 282 } // namespace
285 } // namespace extensions 283 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698