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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc

Issue 2163153002: Don't test Cmd+Alt+v in the Omnibox on macOS Sierra (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/scoped_observer.h" 10 #include "base/scoped_observer.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "components/toolbar/test_toolbar_model.h" 47 #include "components/toolbar/test_toolbar_model.h"
48 #include "content/public/browser/notification_service.h" 48 #include "content/public/browser/notification_service.h"
49 #include "content/public/browser/web_contents.h" 49 #include "content/public/browser/web_contents.h"
50 #include "net/dns/mock_host_resolver.h" 50 #include "net/dns/mock_host_resolver.h"
51 #include "ui/base/clipboard/clipboard.h" 51 #include "ui/base/clipboard/clipboard.h"
52 #include "ui/base/clipboard/scoped_clipboard_writer.h" 52 #include "ui/base/clipboard/scoped_clipboard_writer.h"
53 #include "ui/events/event_constants.h" 53 #include "ui/events/event_constants.h"
54 #include "ui/events/keycodes/keyboard_codes.h" 54 #include "ui/events/keycodes/keyboard_codes.h"
55 #include "ui/gfx/geometry/point.h" 55 #include "ui/gfx/geometry/point.h"
56 56
57 #if defined(OS_MACOSX)
58 #include "base/mac/mac_util.h"
59 #endif
60
57 using base::ASCIIToUTF16; 61 using base::ASCIIToUTF16;
58 using base::UTF16ToUTF8; 62 using base::UTF16ToUTF8;
59 using base::Time; 63 using base::Time;
60 using base::TimeDelta; 64 using base::TimeDelta;
61 using bookmarks::BookmarkModel; 65 using bookmarks::BookmarkModel;
62 66
63 namespace { 67 namespace {
64 68
65 const char kSearchKeyword[] = "foo"; 69 const char kSearchKeyword[] = "foo";
66 const char kSearchKeyword2[] = "footest.com"; 70 const char kSearchKeyword2[] = "footest.com";
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 omnibox_view->CloseOmniboxPopup(); 1631 omnibox_view->CloseOmniboxPopup();
1628 EXPECT_FALSE(popup_model->IsOpen()); 1632 EXPECT_FALSE(popup_model->IsOpen());
1629 1633
1630 // Pasting amid text should yield the expected text and re-open the popup. 1634 // Pasting amid text should yield the expected text and re-open the popup.
1631 omnibox_view->SetWindowTextAndCaretPos(ASCIIToUTF16("abcd"), 2, false, false); 1635 omnibox_view->SetWindowTextAndCaretPos(ASCIIToUTF16("abcd"), 2, false, false);
1632 SetClipboardText(ASCIIToUTF16("123")); 1636 SetClipboardText(ASCIIToUTF16("123"));
1633 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, kCtrlOrCmdMask)); 1637 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, kCtrlOrCmdMask));
1634 EXPECT_EQ(ASCIIToUTF16("ab123cd"), omnibox_view->GetText()); 1638 EXPECT_EQ(ASCIIToUTF16("ab123cd"), omnibox_view->GetText());
1635 EXPECT_TRUE(popup_model->IsOpen()); 1639 EXPECT_TRUE(popup_model->IsOpen());
1636 1640
1637 // Ctrl/Cmd+Alt+V should not paste. 1641 bool run_alt_paste_test = true;
1638 ASSERT_NO_FATAL_FAILURE( 1642 #if defined(OS_MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED == MAC_OS_X_VERSION_10_7
1639 SendKey(ui::VKEY_V, kCtrlOrCmdMask | ui::EF_ALT_DOWN)); 1643 // On macOS 10.12 Sierra Cmd+Alt+v actually does paste due to an OS bug. In
1640 EXPECT_EQ(ASCIIToUTF16("ab123cd"), omnibox_view->GetText()); 1644 // addition, the synthetic test event causes a segfault inside AppKit. A real,
1645 // keyboard-generated event does not crash (but incorrectly pastes). Revisit
1646 // this when bumping the deployment target. See http://crbug.com/629595.
1647 run_alt_paste_test = !base::mac::IsOSLaterThanElCapitan_DontCallThis();
1648 #endif
1649 if (run_alt_paste_test) {
1650 // Ctrl/Cmd+Alt+V should not paste.
1651 ASSERT_NO_FATAL_FAILURE(
1652 SendKey(ui::VKEY_V, kCtrlOrCmdMask | ui::EF_ALT_DOWN));
1653 EXPECT_EQ(ASCIIToUTF16("ab123cd"), omnibox_view->GetText());
1654 }
1641 // TODO(msw): Test that AltGr+V does not paste. 1655 // TODO(msw): Test that AltGr+V does not paste.
1642 } 1656 }
1643 1657
1644 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, CopyURLToClipboard) { 1658 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, CopyURLToClipboard) {
1645 // Set permanent text thus making sure that omnibox treats 'google.com' 1659 // Set permanent text thus making sure that omnibox treats 'google.com'
1646 // as URL (not as ordinary user input). 1660 // as URL (not as ordinary user input).
1647 TestToolbarModel* test_toolbar_model = new TestToolbarModel; 1661 TestToolbarModel* test_toolbar_model = new TestToolbarModel;
1648 std::unique_ptr<ToolbarModel> toolbar_model(test_toolbar_model); 1662 std::unique_ptr<ToolbarModel> toolbar_model(test_toolbar_model);
1649 test_toolbar_model->set_text(ASCIIToUTF16("http://www.google.com/")); 1663 test_toolbar_model->set_text(ASCIIToUTF16("http://www.google.com/"));
1650 browser()->swap_toolbar_models(&toolbar_model); 1664 browser()->swap_toolbar_models(&toolbar_model);
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 2002
1989 // Now Shift+Right should do nothing, and Shift+Left should reduce. 2003 // Now Shift+Right should do nothing, and Shift+Left should reduce.
1990 // At the end, so Shift+Right should do nothing. 2004 // At the end, so Shift+Right should do nothing.
1991 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RIGHT, ui::EF_SHIFT_DOWN)); 2005 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RIGHT, ui::EF_SHIFT_DOWN));
1992 EXPECT_EQ(2u, GetSelectionSize(omnibox_view)); 2006 EXPECT_EQ(2u, GetSelectionSize(omnibox_view));
1993 2007
1994 // And Left should reduce by one character. 2008 // And Left should reduce by one character.
1995 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, ui::EF_SHIFT_DOWN)); 2009 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, ui::EF_SHIFT_DOWN));
1996 EXPECT_EQ(1u, GetSelectionSize(omnibox_view)); 2010 EXPECT_EQ(1u, GetSelectionSize(omnibox_view));
1997 } 2011 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698