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

Side by Side Diff: chrome/browser/extensions/api/debugger/debugger_apitest.cc

Issue 1448903004: [DevTools] One infobar per extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nullptr Created 5 years, 1 month 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
« no previous file with comments | « chrome/browser/extensions/api/debugger/debugger_api.cc ('k') | no next file » | 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 IN_PROC_BROWSER_TEST_F(DebuggerApiTest, InfoBar) { 186 IN_PROC_BROWSER_TEST_F(DebuggerApiTest, InfoBar) {
187 int tab_id = SessionTabHelper::IdForTab( 187 int tab_id = SessionTabHelper::IdForTab(
188 browser()->tab_strip_model()->GetActiveWebContents()); 188 browser()->tab_strip_model()->GetActiveWebContents());
189 scoped_refptr<DebuggerAttachFunction> attach_function; 189 scoped_refptr<DebuggerAttachFunction> attach_function;
190 scoped_refptr<DebuggerDetachFunction> detach_function; 190 scoped_refptr<DebuggerDetachFunction> detach_function;
191 191
192 Browser* another_browser = 192 Browser* another_browser =
193 new Browser(Browser::CreateParams(profile(), chrome::GetActiveDesktop())); 193 new Browser(Browser::CreateParams(profile(), chrome::GetActiveDesktop()));
194 AddBlankTabAndShow(another_browser); 194 AddBlankTabAndShow(another_browser);
195 AddBlankTabAndShow(another_browser); 195 AddBlankTabAndShow(another_browser);
196 int tab_id2 = SessionTabHelper::IdForTab(
197 another_browser->tab_strip_model()->GetActiveWebContents());
196 198
197 InfoBarService* service1 = InfoBarService::FromWebContents( 199 InfoBarService* service1 = InfoBarService::FromWebContents(
198 browser()->tab_strip_model()->GetActiveWebContents()); 200 browser()->tab_strip_model()->GetActiveWebContents());
199 InfoBarService* service2 = InfoBarService::FromWebContents( 201 InfoBarService* service2 = InfoBarService::FromWebContents(
200 another_browser->tab_strip_model()->GetWebContentsAt(0)); 202 another_browser->tab_strip_model()->GetWebContentsAt(0));
201 InfoBarService* service3 = InfoBarService::FromWebContents( 203 InfoBarService* service3 = InfoBarService::FromWebContents(
202 another_browser->tab_strip_model()->GetWebContentsAt(1)); 204 another_browser->tab_strip_model()->GetWebContentsAt(1));
203 205
204 // Attach should create infobars in both browsers. 206 // Attach should create infobars in both browsers.
205 attach_function = new DebuggerAttachFunction(); 207 attach_function = new DebuggerAttachFunction();
206 attach_function->set_extension(extension()); 208 attach_function->set_extension(extension());
207 ASSERT_TRUE( 209 ASSERT_TRUE(
208 RunFunction(attach_function.get(), 210 RunFunction(attach_function.get(),
209 base::StringPrintf("[{\"tabId\": %d}, \"1.1\"]", tab_id), 211 base::StringPrintf("[{\"tabId\": %d}, \"1.1\"]", tab_id),
210 browser(), extension_function_test_utils::NONE)); 212 browser(), extension_function_test_utils::NONE));
211 EXPECT_EQ(1u, service1->infobar_count()); 213 EXPECT_EQ(1u, service1->infobar_count());
212 EXPECT_EQ(1u, service2->infobar_count()); 214 EXPECT_EQ(1u, service2->infobar_count());
213 EXPECT_EQ(1u, service3->infobar_count()); 215 EXPECT_EQ(1u, service3->infobar_count());
214 216
217 // Second attach should not create infobars.
218 attach_function = new DebuggerAttachFunction();
219 attach_function->set_extension(extension());
220 ASSERT_TRUE(
221 RunFunction(attach_function.get(),
222 base::StringPrintf("[{\"tabId\": %d}, \"1.1\"]", tab_id2),
223 browser(), extension_function_test_utils::NONE));
224 EXPECT_EQ(1u, service1->infobar_count());
225 EXPECT_EQ(1u, service2->infobar_count());
226 EXPECT_EQ(1u, service3->infobar_count());
227
228 // Detach from one of the tabs should not remove infobars.
229 detach_function = new DebuggerDetachFunction();
230 detach_function->set_extension(extension());
231 ASSERT_TRUE(RunFunction(detach_function.get(),
232 base::StringPrintf("[{\"tabId\": %d}]", tab_id2),
233 browser(), extension_function_test_utils::NONE));
234 EXPECT_EQ(1u, service1->infobar_count());
235 EXPECT_EQ(1u, service2->infobar_count());
236 EXPECT_EQ(1u, service3->infobar_count());
237
215 // Detach should remove all infobars. 238 // Detach should remove all infobars.
216 detach_function = new DebuggerDetachFunction(); 239 detach_function = new DebuggerDetachFunction();
217 detach_function->set_extension(extension()); 240 detach_function->set_extension(extension());
218 ASSERT_TRUE(RunFunction(detach_function.get(), 241 ASSERT_TRUE(RunFunction(detach_function.get(),
219 base::StringPrintf("[{\"tabId\": %d}]", tab_id), 242 base::StringPrintf("[{\"tabId\": %d}]", tab_id),
220 browser(), extension_function_test_utils::NONE)); 243 browser(), extension_function_test_utils::NONE));
221 EXPECT_EQ(0u, service1->infobar_count()); 244 EXPECT_EQ(0u, service1->infobar_count());
222 EXPECT_EQ(0u, service2->infobar_count()); 245 EXPECT_EQ(0u, service2->infobar_count());
223 EXPECT_EQ(0u, service3->infobar_count()); 246 EXPECT_EQ(0u, service3->infobar_count());
224 247
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 // Detach should remove the remaining infobar. 294 // Detach should remove the remaining infobar.
272 detach_function = new DebuggerDetachFunction(); 295 detach_function = new DebuggerDetachFunction();
273 detach_function->set_extension(extension()); 296 detach_function->set_extension(extension());
274 ASSERT_TRUE(RunFunction(detach_function.get(), 297 ASSERT_TRUE(RunFunction(detach_function.get(),
275 base::StringPrintf("[{\"tabId\": %d}]", tab_id), 298 base::StringPrintf("[{\"tabId\": %d}]", tab_id),
276 browser(), extension_function_test_utils::NONE)); 299 browser(), extension_function_test_utils::NONE));
277 EXPECT_EQ(0u, service1->infobar_count()); 300 EXPECT_EQ(0u, service1->infobar_count());
278 } 301 }
279 302
280 } // namespace extensions 303 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/debugger/debugger_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698