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

Side by Side Diff: chrome/browser/extensions/extension_devtools_browsertests.cc

Issue 10449042: Remove wchar/wstring version of StringPrintf. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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
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 "base/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/stringprintf.h" 6 #include "base/stringprintf.h"
7 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/extensions/extension_devtools_browsertest.h" 8 #include "chrome/browser/extensions/extension_devtools_browsertest.h"
8 #include "chrome/browser/extensions/extension_error_reporter.h" 9 #include "chrome/browser/extensions/extension_error_reporter.h"
9 #include "chrome/browser/extensions/extension_host.h" 10 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/extensions/extension_process_manager.h" 11 #include "chrome/browser/extensions/extension_process_manager.h"
11 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_tab_util.h" 13 #include "chrome/browser/extensions/extension_tab_util.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // Grab a handle to the DevToolsManager so we can forward messages to it. 69 // Grab a handle to the DevToolsManager so we can forward messages to it.
69 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); 70 DevToolsManager* devtools_manager = DevToolsManager::GetInstance();
70 71
71 // Grab the tab_id of whatever tab happens to be first. 72 // Grab the tab_id of whatever tab happens to be first.
72 WebContents* web_contents = browser()->GetWebContentsAt(0); 73 WebContents* web_contents = browser()->GetWebContentsAt(0);
73 ASSERT_TRUE(web_contents); 74 ASSERT_TRUE(web_contents);
74 int tab_id = ExtensionTabUtil::GetTabId(web_contents); 75 int tab_id = ExtensionTabUtil::GetTabId(web_contents);
75 76
76 // Test setup. 77 // Test setup.
77 bool result = false; 78 bool result = false;
78 std::wstring register_listeners_js = base::StringPrintf( 79 std::wstring register_listeners_js = ASCIIToWide(base::StringPrintf(
79 L"setListenersOnTab(%d)", tab_id); 80 "setListenersOnTab(%d)", tab_id));
80 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 81 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
81 host->render_view_host(), L"", register_listeners_js, &result)); 82 host->render_view_host(), L"", register_listeners_js, &result));
82 EXPECT_TRUE(result); 83 EXPECT_TRUE(result);
83 84
84 // Setting the events should have caused an ExtensionDevToolsBridge to be 85 // Setting the events should have caused an ExtensionDevToolsBridge to be
85 // registered for the tab's RenderViewHost. 86 // registered for the tab's RenderViewHost.
86 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( 87 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost(
87 web_contents->GetRenderViewHost()); 88 web_contents->GetRenderViewHost());
88 DevToolsClientHost* devtools_client_host = 89 DevToolsClientHost* devtools_client_host =
89 devtools_manager->GetDevToolsClientHostFor(agent); 90 devtools_manager->GetDevToolsClientHostFor(agent);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 128
128 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); 129 DevToolsManager* devtools_manager = DevToolsManager::GetInstance();
129 130
130 // Grab the tab_id of whatever tab happens to be first. 131 // Grab the tab_id of whatever tab happens to be first.
131 WebContents* web_contents = browser()->GetWebContentsAt(0); 132 WebContents* web_contents = browser()->GetWebContentsAt(0);
132 ASSERT_TRUE(web_contents); 133 ASSERT_TRUE(web_contents);
133 int tab_id = ExtensionTabUtil::GetTabId(web_contents); 134 int tab_id = ExtensionTabUtil::GetTabId(web_contents);
134 135
135 // Test setup. 136 // Test setup.
136 bool result = false; 137 bool result = false;
137 std::wstring register_listeners_js = base::StringPrintf( 138 std::wstring register_listeners_js = ASCIIToWide(base::StringPrintf(
138 L"setListenersOnTab(%d)", tab_id); 139 "setListenersOnTab(%d)", tab_id));
139 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 140 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
140 host_one->render_view_host(), L"", register_listeners_js, &result)); 141 host_one->render_view_host(), L"", register_listeners_js, &result));
141 EXPECT_TRUE(result); 142 EXPECT_TRUE(result);
142 143
143 // Setting the event listeners should have caused an ExtensionDevToolsBridge 144 // Setting the event listeners should have caused an ExtensionDevToolsBridge
144 // to be registered for the tab's RenderViewHost. 145 // to be registered for the tab's RenderViewHost.
145 ASSERT_TRUE(devtools_manager->GetDevToolsClientHostFor( 146 ASSERT_TRUE(devtools_manager->GetDevToolsClientHostFor(
146 DevToolsAgentHostRegistry::GetDevToolsAgentHost( 147 DevToolsAgentHostRegistry::GetDevToolsAgentHost(
147 web_contents->GetRenderViewHost()))); 148 web_contents->GetRenderViewHost())));
148 149
149 // Register listeners from the second extension as well. 150 // Register listeners from the second extension as well.
150 std::wstring script = base::StringPrintf(L"registerListenersForTab(%d)", 151 std::wstring script = ASCIIToWide(base::StringPrintf(
151 tab_id); 152 "registerListenersForTab(%d)", tab_id));
152 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 153 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
153 host_two->render_view_host(), L"", script, &result)); 154 host_two->render_view_host(), L"", script, &result));
154 EXPECT_TRUE(result); 155 EXPECT_TRUE(result);
155 156
156 // Removing the listeners from the first extension should leave the bridge 157 // Removing the listeners from the first extension should leave the bridge
157 // alive. 158 // alive.
158 result = false; 159 result = false;
159 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 160 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
160 host_one->render_view_host(), L"", L"unregisterListeners()", &result)); 161 host_one->render_view_host(), L"", L"unregisterListeners()", &result));
161 EXPECT_TRUE(result); 162 EXPECT_TRUE(result);
162 ASSERT_TRUE(devtools_manager->GetDevToolsClientHostFor( 163 ASSERT_TRUE(devtools_manager->GetDevToolsClientHostFor(
163 DevToolsAgentHostRegistry::GetDevToolsAgentHost( 164 DevToolsAgentHostRegistry::GetDevToolsAgentHost(
164 web_contents->GetRenderViewHost()))); 165 web_contents->GetRenderViewHost())));
165 166
166 // Removing the listeners from the second extension should tear the bridge 167 // Removing the listeners from the second extension should tear the bridge
167 // down. 168 // down.
168 result = false; 169 result = false;
169 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 170 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
170 host_two->render_view_host(), L"", L"unregisterListeners()", &result)); 171 host_two->render_view_host(), L"", L"unregisterListeners()", &result));
171 EXPECT_TRUE(result); 172 EXPECT_TRUE(result);
172 ASSERT_FALSE(devtools_manager->GetDevToolsClientHostFor( 173 ASSERT_FALSE(devtools_manager->GetDevToolsClientHostFor(
173 DevToolsAgentHostRegistry::GetDevToolsAgentHost( 174 DevToolsAgentHostRegistry::GetDevToolsAgentHost(
174 web_contents->GetRenderViewHost()))); 175 web_contents->GetRenderViewHost())));
175 } 176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698