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

Side by Side Diff: chrome/browser/ui/browser_browsertest.cc

Issue 2227563003: Refactoring button field and its type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix mac/win errors Created 4 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 2399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 } 2410 }
2411 2411
2412 private: 2412 private:
2413 DISALLOW_COPY_AND_ASSIGN(ClickModifierTest); 2413 DISALLOW_COPY_AND_ASSIGN(ClickModifierTest);
2414 }; 2414 };
2415 2415
2416 // Tests for clicking on elements with handlers that run window.open. 2416 // Tests for clicking on elements with handlers that run window.open.
2417 2417
2418 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenBasicClickTest) { 2418 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenBasicClickTest) {
2419 int modifiers = 0; 2419 int modifiers = 0;
2420 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; 2420 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2421 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; 2421 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB;
2422 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); 2422 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition);
2423 } 2423 }
2424 2424
2425 // TODO(ericu): Alt-click behavior on window.open is platform-dependent and not 2425 // TODO(ericu): Alt-click behavior on window.open is platform-dependent and not
2426 // well defined. Should we add tests so we know if it changes? 2426 // well defined. Should we add tests so we know if it changes?
2427 2427
2428 // Shift-clicks open in a new window. 2428 // Shift-clicks open in a new window.
2429 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenShiftClickTest) { 2429 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenShiftClickTest) {
2430 int modifiers = blink::WebInputEvent::ShiftKey; 2430 int modifiers = blink::WebInputEvent::ShiftKey;
2431 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; 2431 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2432 WindowOpenDisposition disposition = NEW_WINDOW; 2432 WindowOpenDisposition disposition = NEW_WINDOW;
2433 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); 2433 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition);
2434 } 2434 }
2435 2435
2436 // Control-clicks open in a background tab. 2436 // Control-clicks open in a background tab.
2437 // On OSX meta [the command key] takes the place of control. 2437 // On OSX meta [the command key] takes the place of control.
2438 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenControlClickTest) { 2438 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenControlClickTest) {
2439 #if defined(OS_MACOSX) 2439 #if defined(OS_MACOSX)
2440 int modifiers = blink::WebInputEvent::MetaKey; 2440 int modifiers = blink::WebInputEvent::MetaKey;
2441 #else 2441 #else
2442 int modifiers = blink::WebInputEvent::ControlKey; 2442 int modifiers = blink::WebInputEvent::ControlKey;
2443 #endif 2443 #endif
2444 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; 2444 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2445 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; 2445 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB;
2446 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); 2446 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition);
2447 } 2447 }
2448 2448
2449 // Control-shift-clicks open in a foreground tab. 2449 // Control-shift-clicks open in a foreground tab.
2450 // On OSX meta [the command key] takes the place of control. 2450 // On OSX meta [the command key] takes the place of control.
2451 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenControlShiftClickTest) { 2451 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenControlShiftClickTest) {
2452 #if defined(OS_MACOSX) 2452 #if defined(OS_MACOSX)
2453 int modifiers = blink::WebInputEvent::MetaKey; 2453 int modifiers = blink::WebInputEvent::MetaKey;
2454 #else 2454 #else
2455 int modifiers = blink::WebInputEvent::ControlKey; 2455 int modifiers = blink::WebInputEvent::ControlKey;
2456 #endif 2456 #endif
2457 modifiers |= blink::WebInputEvent::ShiftKey; 2457 modifiers |= blink::WebInputEvent::ShiftKey;
2458 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; 2458 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2459 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; 2459 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB;
2460 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); 2460 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition);
2461 } 2461 }
2462 2462
2463 // Middle-clicks open in a background tab. 2463 // Middle-clicks open in a background tab.
2464 #if defined(OS_LINUX) 2464 #if defined(OS_LINUX)
2465 // http://crbug.com/396347 2465 // http://crbug.com/396347
2466 #define MAYBE_WindowOpenMiddleClickTest DISABLED_WindowOpenMiddleClickTest 2466 #define MAYBE_WindowOpenMiddleClickTest DISABLED_WindowOpenMiddleClickTest
2467 #else 2467 #else
2468 #define MAYBE_WindowOpenMiddleClickTest WindowOpenMiddleClickTest 2468 #define MAYBE_WindowOpenMiddleClickTest WindowOpenMiddleClickTest
2469 #endif 2469 #endif
2470 IN_PROC_BROWSER_TEST_F(ClickModifierTest, MAYBE_WindowOpenMiddleClickTest) { 2470 IN_PROC_BROWSER_TEST_F(ClickModifierTest, MAYBE_WindowOpenMiddleClickTest) {
2471 int modifiers = 0; 2471 int modifiers = 0;
2472 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonMiddle; 2472 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Middle;
2473 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; 2473 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB;
2474 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); 2474 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition);
2475 } 2475 }
2476 2476
2477 // Shift-middle-clicks open in a foreground tab. 2477 // Shift-middle-clicks open in a foreground tab.
2478 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenShiftMiddleClickTest) { 2478 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenShiftMiddleClickTest) {
2479 int modifiers = blink::WebInputEvent::ShiftKey; 2479 int modifiers = blink::WebInputEvent::ShiftKey;
2480 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonMiddle; 2480 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Middle;
2481 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; 2481 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB;
2482 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); 2482 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition);
2483 } 2483 }
2484 2484
2485 // Tests for clicking on normal links. 2485 // Tests for clicking on normal links.
2486 2486
2487 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefBasicClickTest) { 2487 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefBasicClickTest) {
2488 int modifiers = 0; 2488 int modifiers = 0;
2489 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; 2489 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2490 WindowOpenDisposition disposition = CURRENT_TAB; 2490 WindowOpenDisposition disposition = CURRENT_TAB;
2491 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2491 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2492 } 2492 }
2493 2493
2494 // TODO(ericu): Alt-click behavior on links is platform-dependent and not well 2494 // TODO(ericu): Alt-click behavior on links is platform-dependent and not well
2495 // defined. Should we add tests so we know if it changes? 2495 // defined. Should we add tests so we know if it changes?
2496 2496
2497 // Shift-clicks open in a new window. 2497 // Shift-clicks open in a new window.
2498 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftClickTest) { 2498 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftClickTest) {
2499 int modifiers = blink::WebInputEvent::ShiftKey; 2499 int modifiers = blink::WebInputEvent::ShiftKey;
2500 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; 2500 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2501 WindowOpenDisposition disposition = NEW_WINDOW; 2501 WindowOpenDisposition disposition = NEW_WINDOW;
2502 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2502 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2503 } 2503 }
2504 2504
2505 // Control-clicks open in a background tab. 2505 // Control-clicks open in a background tab.
2506 // On OSX meta [the command key] takes the place of control. 2506 // On OSX meta [the command key] takes the place of control.
2507 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefControlClickTest) { 2507 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefControlClickTest) {
2508 #if defined(OS_MACOSX) 2508 #if defined(OS_MACOSX)
2509 int modifiers = blink::WebInputEvent::MetaKey; 2509 int modifiers = blink::WebInputEvent::MetaKey;
2510 #else 2510 #else
2511 int modifiers = blink::WebInputEvent::ControlKey; 2511 int modifiers = blink::WebInputEvent::ControlKey;
2512 #endif 2512 #endif
2513 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; 2513 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2514 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; 2514 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB;
2515 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2515 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2516 } 2516 }
2517 2517
2518 // Control-shift-clicks open in a foreground tab. 2518 // Control-shift-clicks open in a foreground tab.
2519 // On OSX meta [the command key] takes the place of control. 2519 // On OSX meta [the command key] takes the place of control.
2520 // http://crbug.com/396347 2520 // http://crbug.com/396347
2521 IN_PROC_BROWSER_TEST_F(ClickModifierTest, DISABLED_HrefControlShiftClickTest) { 2521 IN_PROC_BROWSER_TEST_F(ClickModifierTest, DISABLED_HrefControlShiftClickTest) {
2522 #if defined(OS_MACOSX) 2522 #if defined(OS_MACOSX)
2523 int modifiers = blink::WebInputEvent::MetaKey; 2523 int modifiers = blink::WebInputEvent::MetaKey;
2524 #else 2524 #else
2525 int modifiers = blink::WebInputEvent::ControlKey; 2525 int modifiers = blink::WebInputEvent::ControlKey;
2526 #endif 2526 #endif
2527 modifiers |= blink::WebInputEvent::ShiftKey; 2527 modifiers |= blink::WebInputEvent::ShiftKey;
2528 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; 2528 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2529 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; 2529 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB;
2530 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2530 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2531 } 2531 }
2532 2532
2533 // Middle-clicks open in a background tab. 2533 // Middle-clicks open in a background tab.
2534 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefMiddleClickTest) { 2534 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefMiddleClickTest) {
2535 int modifiers = 0; 2535 int modifiers = 0;
2536 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonMiddle; 2536 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Middle;
2537 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; 2537 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB;
2538 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2538 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2539 } 2539 }
2540 2540
2541 // Shift-middle-clicks open in a foreground tab. 2541 // Shift-middle-clicks open in a foreground tab.
2542 // http://crbug.com/396347 2542 // http://crbug.com/396347
2543 IN_PROC_BROWSER_TEST_F(ClickModifierTest, DISABLED_HrefShiftMiddleClickTest) { 2543 IN_PROC_BROWSER_TEST_F(ClickModifierTest, DISABLED_HrefShiftMiddleClickTest) {
2544 int modifiers = blink::WebInputEvent::ShiftKey; 2544 int modifiers = blink::WebInputEvent::ShiftKey;
2545 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonMiddle; 2545 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Middle;
2546 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; 2546 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB;
2547 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2547 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2548 } 2548 }
2549 2549
2550 IN_PROC_BROWSER_TEST_F(BrowserTest, GetSizeForNewRenderView) { 2550 IN_PROC_BROWSER_TEST_F(BrowserTest, GetSizeForNewRenderView) {
2551 // The instant extended NTP has javascript that does not work with 2551 // The instant extended NTP has javascript that does not work with
2552 // ui_test_utils::NavigateToURL. The NTP rvh reloads when the browser tries 2552 // ui_test_utils::NavigateToURL. The NTP rvh reloads when the browser tries
2553 // to navigate away from the page, which causes the WebContents to end up in 2553 // to navigate away from the page, which causes the WebContents to end up in
2554 // an inconsistent state. (is_loaded = true, last_commited_url=ntp, 2554 // an inconsistent state. (is_loaded = true, last_commited_url=ntp,
2555 // visible_url=title1.html) 2555 // visible_url=title1.html)
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
2867 Browser* browser = new Browser(params); 2867 Browser* browser = new Browser(params);
2868 gfx::Rect bounds = browser->window()->GetBounds(); 2868 gfx::Rect bounds = browser->window()->GetBounds();
2869 2869
2870 // Should be EXPECT_EQ, but this width is inconsistent across platforms. 2870 // Should be EXPECT_EQ, but this width is inconsistent across platforms.
2871 // See https://crbug.com/567925. 2871 // See https://crbug.com/567925.
2872 EXPECT_GE(bounds.width(), 100); 2872 EXPECT_GE(bounds.width(), 100);
2873 EXPECT_EQ(122, bounds.height()); 2873 EXPECT_EQ(122, bounds.height());
2874 browser->window()->Close(); 2874 browser->window()->Close();
2875 } 2875 }
2876 } 2876 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698