Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1574 #endif | 1574 #endif |
| 1575 omnibox_view->CloseOmniboxPopup(); | 1575 omnibox_view->CloseOmniboxPopup(); |
| 1576 EXPECT_FALSE(popup_model->IsOpen()); | 1576 EXPECT_FALSE(popup_model->IsOpen()); |
| 1577 | 1577 |
| 1578 // Pasting amid text should yield the expected text and re-open the popup. | 1578 // Pasting amid text should yield the expected text and re-open the popup. |
| 1579 omnibox_view->SetWindowTextAndCaretPos(ASCIIToUTF16("abcd"), 2, false, false); | 1579 omnibox_view->SetWindowTextAndCaretPos(ASCIIToUTF16("abcd"), 2, false, false); |
| 1580 SetClipboardText(ASCIIToUTF16("123")); | 1580 SetClipboardText(ASCIIToUTF16("123")); |
| 1581 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, kCtrlOrCmdMask)); | 1581 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, kCtrlOrCmdMask)); |
| 1582 EXPECT_EQ(ASCIIToUTF16("ab123cd"), omnibox_view->GetText()); | 1582 EXPECT_EQ(ASCIIToUTF16("ab123cd"), omnibox_view->GetText()); |
| 1583 EXPECT_TRUE(popup_model->IsOpen()); | 1583 EXPECT_TRUE(popup_model->IsOpen()); |
| 1584 | |
| 1585 // The Alt key should stifle the Control+V or Command+V paste shortcut. | |
|
Peter Kasting
2013/10/08 02:38:53
Nit: Simpler and clearer: "Ctrl-alt-v should not p
msw
2013/10/08 03:37:48
Done.
| |
| 1586 ASSERT_NO_FATAL_FAILURE( | |
| 1587 SendKey(ui::VKEY_V, kCtrlOrCmdMask | ui::EF_ALT_DOWN)); | |
| 1588 EXPECT_EQ(ASCIIToUTF16("ab123cd"), omnibox_view->GetText()); | |
| 1589 // TODO(msw): Test that AltGr+V does not invoke paste. | |
| 1584 } | 1590 } |
| 1585 | 1591 |
| 1586 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, CopyURLToClipboard) { | 1592 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, CopyURLToClipboard) { |
| 1587 // Set permanent text thus making sure that omnibox treats 'google.com' | 1593 // Set permanent text thus making sure that omnibox treats 'google.com' |
| 1588 // as URL (not as ordinary user input). | 1594 // as URL (not as ordinary user input). |
| 1589 TestToolbarModel* test_toolbar_model = new TestToolbarModel; | 1595 TestToolbarModel* test_toolbar_model = new TestToolbarModel; |
| 1590 scoped_ptr<ToolbarModel> toolbar_model(test_toolbar_model); | 1596 scoped_ptr<ToolbarModel> toolbar_model(test_toolbar_model); |
| 1591 test_toolbar_model->set_text(ASCIIToUTF16("http://www.google.com/")); | 1597 test_toolbar_model->set_text(ASCIIToUTF16("http://www.google.com/")); |
| 1592 browser()->swap_toolbar_models(&toolbar_model); | 1598 browser()->swap_toolbar_models(&toolbar_model); |
| 1593 OmniboxView* omnibox_view = NULL; | 1599 OmniboxView* omnibox_view = NULL; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1850 omnibox_view->Update(); | 1856 omnibox_view->Update(); |
| 1851 EXPECT_EQ(url_c, omnibox_view->GetText()); | 1857 EXPECT_EQ(url_c, omnibox_view->GetText()); |
| 1852 } | 1858 } |
| 1853 | 1859 |
| 1854 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, InputResetsSearchTermReplacement) { | 1860 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, InputResetsSearchTermReplacement) { |
| 1855 browser()->toolbar_model()->set_search_term_replacement_enabled(false); | 1861 browser()->toolbar_model()->set_search_term_replacement_enabled(false); |
| 1856 chrome::FocusLocationBar(browser()); | 1862 chrome::FocusLocationBar(browser()); |
| 1857 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0)); | 1863 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0)); |
| 1858 EXPECT_TRUE(browser()->toolbar_model()->search_term_replacement_enabled()); | 1864 EXPECT_TRUE(browser()->toolbar_model()->search_term_replacement_enabled()); |
| 1859 } | 1865 } |
| OLD | NEW |