OLD | NEW |
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 Loading... |
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 // Tests for clicking on normal links. | 2463 // Tests for clicking on normal links. |
2464 | 2464 |
2465 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefBasicClickTest) { | 2465 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefBasicClickTest) { |
2466 int modifiers = 0; | 2466 int modifiers = 0; |
2467 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; | 2467 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left; |
2468 WindowOpenDisposition disposition = CURRENT_TAB; | 2468 WindowOpenDisposition disposition = CURRENT_TAB; |
2469 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2469 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
2470 } | 2470 } |
2471 | 2471 |
2472 // TODO(ericu): Alt-click behavior on links is platform-dependent and not well | 2472 // TODO(ericu): Alt-click behavior on links is platform-dependent and not well |
2473 // defined. Should we add tests so we know if it changes? | 2473 // defined. Should we add tests so we know if it changes? |
2474 | 2474 |
2475 // Shift-clicks open in a new window. | 2475 // Shift-clicks open in a new window. |
2476 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftClickTest) { | 2476 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftClickTest) { |
2477 int modifiers = blink::WebInputEvent::ShiftKey; | 2477 int modifiers = blink::WebInputEvent::ShiftKey; |
2478 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; | 2478 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left; |
2479 WindowOpenDisposition disposition = NEW_WINDOW; | 2479 WindowOpenDisposition disposition = NEW_WINDOW; |
2480 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2480 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
2481 } | 2481 } |
2482 | 2482 |
2483 // Control-clicks open in a background tab. | 2483 // Control-clicks open in a background tab. |
2484 // On OSX meta [the command key] takes the place of control. | 2484 // On OSX meta [the command key] takes the place of control. |
2485 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefControlClickTest) { | 2485 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefControlClickTest) { |
2486 #if defined(OS_MACOSX) | 2486 #if defined(OS_MACOSX) |
2487 int modifiers = blink::WebInputEvent::MetaKey; | 2487 int modifiers = blink::WebInputEvent::MetaKey; |
2488 #else | 2488 #else |
2489 int modifiers = blink::WebInputEvent::ControlKey; | 2489 int modifiers = blink::WebInputEvent::ControlKey; |
2490 #endif | 2490 #endif |
2491 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; | 2491 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left; |
2492 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; | 2492 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; |
2493 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2493 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
2494 } | 2494 } |
2495 | 2495 |
2496 // Control-shift-clicks open in a foreground tab. | 2496 // Control-shift-clicks open in a foreground tab. |
2497 // On OSX meta [the command key] takes the place of control. | 2497 // On OSX meta [the command key] takes the place of control. |
2498 // http://crbug.com/396347 | 2498 // http://crbug.com/396347 |
2499 IN_PROC_BROWSER_TEST_F(ClickModifierTest, DISABLED_HrefControlShiftClickTest) { | 2499 IN_PROC_BROWSER_TEST_F(ClickModifierTest, DISABLED_HrefControlShiftClickTest) { |
2500 #if defined(OS_MACOSX) | 2500 #if defined(OS_MACOSX) |
2501 int modifiers = blink::WebInputEvent::MetaKey; | 2501 int modifiers = blink::WebInputEvent::MetaKey; |
2502 #else | 2502 #else |
2503 int modifiers = blink::WebInputEvent::ControlKey; | 2503 int modifiers = blink::WebInputEvent::ControlKey; |
2504 #endif | 2504 #endif |
2505 modifiers |= blink::WebInputEvent::ShiftKey; | 2505 modifiers |= blink::WebInputEvent::ShiftKey; |
2506 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; | 2506 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left; |
2507 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; | 2507 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; |
2508 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2508 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
2509 } | 2509 } |
2510 | 2510 |
2511 // Middle-clicks open in a background tab. | 2511 // Middle-clicks open in a background tab. |
2512 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefMiddleClickTest) { | 2512 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefMiddleClickTest) { |
2513 int modifiers = 0; | 2513 int modifiers = 0; |
2514 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonMiddle; | 2514 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Middle; |
2515 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; | 2515 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; |
2516 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2516 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
2517 } | 2517 } |
2518 | 2518 |
2519 // Shift-middle-clicks open in a foreground tab. | 2519 // Shift-middle-clicks open in a foreground tab. |
2520 // http://crbug.com/396347 | 2520 // http://crbug.com/396347 |
2521 IN_PROC_BROWSER_TEST_F(ClickModifierTest, DISABLED_HrefShiftMiddleClickTest) { | 2521 IN_PROC_BROWSER_TEST_F(ClickModifierTest, DISABLED_HrefShiftMiddleClickTest) { |
2522 int modifiers = blink::WebInputEvent::ShiftKey; | 2522 int modifiers = blink::WebInputEvent::ShiftKey; |
2523 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonMiddle; | 2523 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Middle; |
2524 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; | 2524 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; |
2525 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2525 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
2526 } | 2526 } |
2527 | 2527 |
2528 IN_PROC_BROWSER_TEST_F(BrowserTest, GetSizeForNewRenderView) { | 2528 IN_PROC_BROWSER_TEST_F(BrowserTest, GetSizeForNewRenderView) { |
2529 // The instant extended NTP has javascript that does not work with | 2529 // The instant extended NTP has javascript that does not work with |
2530 // ui_test_utils::NavigateToURL. The NTP rvh reloads when the browser tries | 2530 // ui_test_utils::NavigateToURL. The NTP rvh reloads when the browser tries |
2531 // to navigate away from the page, which causes the WebContents to end up in | 2531 // to navigate away from the page, which causes the WebContents to end up in |
2532 // an inconsistent state. (is_loaded = true, last_commited_url=ntp, | 2532 // an inconsistent state. (is_loaded = true, last_commited_url=ntp, |
2533 // visible_url=title1.html) | 2533 // visible_url=title1.html) |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2845 Browser* browser = new Browser(params); | 2845 Browser* browser = new Browser(params); |
2846 gfx::Rect bounds = browser->window()->GetBounds(); | 2846 gfx::Rect bounds = browser->window()->GetBounds(); |
2847 | 2847 |
2848 // Should be EXPECT_EQ, but this width is inconsistent across platforms. | 2848 // Should be EXPECT_EQ, but this width is inconsistent across platforms. |
2849 // See https://crbug.com/567925. | 2849 // See https://crbug.com/567925. |
2850 EXPECT_GE(bounds.width(), 100); | 2850 EXPECT_GE(bounds.width(), 100); |
2851 EXPECT_EQ(122, bounds.height()); | 2851 EXPECT_EQ(122, bounds.height()); |
2852 browser->window()->Close(); | 2852 browser->window()->Close(); |
2853 } | 2853 } |
2854 } | 2854 } |
OLD | NEW |