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

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

Issue 431173002: Create ExtensionActionView class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge conflict Created 6 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_action_test_util.h" 5 #include "chrome/browser/extensions/browser_action_test_util.h"
6 #include "chrome/browser/extensions/extension_action.h" 6 #include "chrome/browser/extensions/extension_action.h"
7 #include "chrome/browser/extensions/extension_action_manager.h" 7 #include "chrome/browser/extensions/extension_action_manager.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_tab_util.h" 10 #include "chrome/browser/extensions/extension_tab_util.h"
11 #include "chrome/browser/extensions/extension_test_message_listener.h" 11 #include "chrome/browser/extensions/extension_test_message_listener.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_commands.h" 13 #include "chrome/browser/ui/browser_commands.h"
14 #include "chrome/browser/ui/browser_finder.h" 14 #include "chrome/browser/ui/browser_finder.h"
15 #include "chrome/browser/ui/browser_list.h" 15 #include "chrome/browser/ui/browser_list.h"
16 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/test/base/interactive_test_utils.h" 18 #include "chrome/test/base/interactive_test_utils.h"
19 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
20 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
21 #include "extensions/browser/extension_registry.h"
21 #include "extensions/browser/extension_system.h" 22 #include "extensions/browser/extension_system.h"
23 #include "extensions/common/extension.h"
24 #include "extensions/common/extension_set.h"
22 #include "extensions/common/permissions/permissions_data.h" 25 #include "extensions/common/permissions/permissions_data.h"
23 26
24 #if defined(OS_WIN) 27 #if defined(OS_WIN)
25 #include "ui/views/win/hwnd_util.h" 28 #include "ui/views/win/hwnd_util.h"
26 #endif 29 #endif
27 30
28 namespace extensions { 31 namespace extensions {
29 namespace { 32 namespace {
30 33
31 // chrome.browserAction API tests that interact with the UI in such a way that 34 // chrome.browserAction API tests that interact with the UI in such a way that
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 chrome::NewTab(browser()); 259 chrome::NewTab(browser());
257 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 260 ASSERT_EQ(2, browser()->tab_strip_model()->count());
258 OpenExtensionPopupViaAPI(); 261 OpenExtensionPopupViaAPI();
259 262
260 // Press CTRL+TAB to change active tabs, the extension popup should close. 263 // Press CTRL+TAB to change active tabs, the extension popup should close.
261 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 264 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
262 browser(), ui::VKEY_TAB, true, false, false, false)); 265 browser(), ui::VKEY_TAB, true, false, false, false));
263 EXPECT_FALSE(BrowserActionTestUtil(browser()).HasPopup()); 266 EXPECT_FALSE(BrowserActionTestUtil(browser()).HasPopup());
264 } 267 }
265 268
269 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest,
270 DeleteBrowserActionWithPopupOpen) {
271 if (!ShouldRunPopupTest())
272 return;
273
274 // First, we open a popup.
275 OpenExtensionPopupViaAPI();
276 BrowserActionTestUtil browser_action_test_util(browser());
277 EXPECT_TRUE(browser_action_test_util.HasPopup());
278
279 // Then, find the extension that created it.
280 content::WebContents* active_web_contents =
281 browser()->tab_strip_model()->GetActiveWebContents();
282 ASSERT_TRUE(active_web_contents);
283 GURL url = active_web_contents->GetLastCommittedURL();
284 const Extension* extension = ExtensionRegistry::Get(browser()->profile())->
285 enabled_extensions().GetExtensionOrAppByURL(url);
286 ASSERT_TRUE(extension);
287
288 // Finally, uninstall the extension, which causes the view to be deleted and
289 // the popup to go away. This should not crash.
290 UninstallExtension(extension->id());
291 EXPECT_FALSE(browser_action_test_util.HasPopup());
292 }
293
266 #if defined(TOOLKIT_VIEWS) 294 #if defined(TOOLKIT_VIEWS)
267 // Test closing the browser while inspecting an extension popup with dev tools. 295 // Test closing the browser while inspecting an extension popup with dev tools.
268 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, CloseBrowserWithDevTools) { 296 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, CloseBrowserWithDevTools) {
269 if (!ShouldRunPopupTest()) 297 if (!ShouldRunPopupTest())
270 return; 298 return;
271 299
272 // Load a first extension that can open a popup. 300 // Load a first extension that can open a popup.
273 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( 301 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
274 "browser_action/popup"))); 302 "browser_action/popup")));
275 const Extension* extension = GetSingleLoadedExtension(); 303 const Extension* extension = GetSingleLoadedExtension();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 341
314 // Forcibly closing the browser HWND should not cause a crash. 342 // Forcibly closing the browser HWND should not cause a crash.
315 EXPECT_EQ(TRUE, ::CloseWindow(hwnd)); 343 EXPECT_EQ(TRUE, ::CloseWindow(hwnd));
316 EXPECT_EQ(TRUE, ::DestroyWindow(hwnd)); 344 EXPECT_EQ(TRUE, ::DestroyWindow(hwnd));
317 EXPECT_EQ(FALSE, ::IsWindow(hwnd)); 345 EXPECT_EQ(FALSE, ::IsWindow(hwnd));
318 } 346 }
319 #endif // OS_WIN 347 #endif // OS_WIN
320 348
321 } // namespace 349 } // namespace
322 } // namespace extensions 350 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698