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/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1395 // Looks like the undo manager doesn't support restoring selection. | 1395 // Looks like the undo manager doesn't support restoring selection. |
1396 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN)); | 1396 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN)); |
1397 EXPECT_FALSE(omnibox_view->IsSelectAll()); | 1397 EXPECT_FALSE(omnibox_view->IsSelectAll()); |
1398 | 1398 |
1399 // The cursor should be at the end. | 1399 // The cursor should be at the end. |
1400 size_t start, end; | 1400 size_t start, end; |
1401 omnibox_view->GetSelectionBounds(&start, &end); | 1401 omnibox_view->GetSelectionBounds(&start, &end); |
1402 EXPECT_EQ(old_text.size(), start); | 1402 EXPECT_EQ(old_text.size(), start); |
1403 EXPECT_EQ(old_text.size(), end); | 1403 EXPECT_EQ(old_text.size(), end); |
1404 | 1404 |
1405 // Delete two characters. | 1405 // Delete three characters; "about:bl" should not trigger inline autocomplete. |
Peter Kasting
2014/05/30 21:06:16
Hmm... I wonder if it would be more future-proof t
msw
2014/05/31 02:43:24
This works for now, and it shouldn't be hard to fi
| |
1406 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 1406 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
1407 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 1407 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
1408 EXPECT_EQ(old_text.substr(0, old_text.size() - 2), omnibox_view->GetText()); | 1408 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
1409 EXPECT_EQ(old_text.substr(0, old_text.size() - 3), omnibox_view->GetText()); | |
1409 | 1410 |
1410 // Undo delete. | 1411 // Undo delete. |
1411 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN)); | 1412 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN)); |
1412 EXPECT_EQ(old_text, omnibox_view->GetText()); | 1413 EXPECT_EQ(old_text, omnibox_view->GetText()); |
1413 | 1414 |
1414 // Redo delete. | 1415 // Redo delete. |
1415 ASSERT_NO_FATAL_FAILURE( | 1416 ASSERT_NO_FATAL_FAILURE( |
1416 SendKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN)); | 1417 SendKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN)); |
1417 EXPECT_EQ(old_text.substr(0, old_text.size() - 2), omnibox_view->GetText()); | 1418 EXPECT_EQ(old_text.substr(0, old_text.size() - 3), omnibox_view->GetText()); |
1418 | 1419 |
1419 // Delete everything. | 1420 // Delete everything. |
1420 omnibox_view->SelectAll(true); | 1421 omnibox_view->SelectAll(true); |
1421 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 1422 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
1422 EXPECT_TRUE(omnibox_view->GetText().empty()); | 1423 EXPECT_TRUE(omnibox_view->GetText().empty()); |
1423 | 1424 |
1424 // Undo delete everything. | 1425 // Undo delete everything. |
1425 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN)); | 1426 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN)); |
1426 EXPECT_EQ(old_text.substr(0, old_text.size() - 2), omnibox_view->GetText()); | 1427 EXPECT_EQ(old_text.substr(0, old_text.size() - 3), omnibox_view->GetText()); |
1427 | 1428 |
1428 // Undo delete two characters. | 1429 // Undo delete two characters. |
1429 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN)); | 1430 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_Z, ui::EF_CONTROL_DOWN)); |
1430 EXPECT_EQ(old_text, omnibox_view->GetText()); | 1431 EXPECT_EQ(old_text, omnibox_view->GetText()); |
1431 } | 1432 } |
1432 | 1433 |
1433 // See http://crosbug.com/10306 | 1434 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, BackspaceDeleteHalfWidthKatakana) { |
1434 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, | |
1435 BackspaceDeleteHalfWidthKatakana) { | |
1436 OmniboxView* omnibox_view = NULL; | 1435 OmniboxView* omnibox_view = NULL; |
1437 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 1436 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
1438 // Insert text: ダ | 1437 // Insert text: ダ |
1439 omnibox_view->SetUserText(base::UTF8ToUTF16("\357\276\200\357\276\236")); | 1438 omnibox_view->SetUserText(base::UTF8ToUTF16("\357\276\200\357\276\236")); |
1440 | 1439 |
1441 // Move the cursor to the end. | 1440 // Move the cursor to the end. |
1442 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_END, 0)); | 1441 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_END, 0)); |
1443 | 1442 |
1444 // Backspace should delete one character. | 1443 // Backspace should delete one character; see http://crbug.com/192743 |
Peter Kasting
2014/05/30 21:06:16
Nit: I'd omit the bug reference.
msw
2014/05/31 02:43:24
Done.
| |
1445 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 1444 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
1446 EXPECT_EQ(base::UTF8ToUTF16("\357\276\200"), omnibox_view->GetText()); | 1445 EXPECT_EQ(base::UTF8ToUTF16("\357\276\200"), omnibox_view->GetText()); |
1447 } | 1446 } |
1448 #endif // defined(TOOLKIT_VIEWS) | 1447 #endif // defined(TOOLKIT_VIEWS) |
1449 | 1448 |
1450 // Flaky test. crbug.com/356850 | 1449 // Flaky test. crbug.com/356850 |
1451 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, | 1450 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, |
1452 DISABLED_DoesNotUpdateAutocompleteOnBlur) { | 1451 DISABLED_DoesNotUpdateAutocompleteOnBlur) { |
1453 OmniboxView* omnibox_view = NULL; | 1452 OmniboxView* omnibox_view = NULL; |
1454 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 1453 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1493 | 1492 |
1494 // Close the popup and select all. | 1493 // Close the popup and select all. |
1495 omnibox_view->CloseOmniboxPopup(); | 1494 omnibox_view->CloseOmniboxPopup(); |
1496 omnibox_view->SelectAll(false); | 1495 omnibox_view->SelectAll(false); |
1497 EXPECT_FALSE(popup_model->IsOpen()); | 1496 EXPECT_FALSE(popup_model->IsOpen()); |
1498 | 1497 |
1499 // Pasting the same text again over itself should re-open the popup. | 1498 // Pasting the same text again over itself should re-open the popup. |
1500 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, kCtrlOrCmdMask)); | 1499 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, kCtrlOrCmdMask)); |
1501 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 1500 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
1502 EXPECT_EQ(ASCIIToUTF16(kSearchText), omnibox_view->GetText()); | 1501 EXPECT_EQ(ASCIIToUTF16(kSearchText), omnibox_view->GetText()); |
1503 // This fails on GTK, see http://crbug.com/131179 | |
1504 #if !defined(TOOLKIT_GTK) | |
1505 EXPECT_TRUE(popup_model->IsOpen()); | 1502 EXPECT_TRUE(popup_model->IsOpen()); |
1506 #endif | |
1507 omnibox_view->CloseOmniboxPopup(); | 1503 omnibox_view->CloseOmniboxPopup(); |
1508 EXPECT_FALSE(popup_model->IsOpen()); | 1504 EXPECT_FALSE(popup_model->IsOpen()); |
1509 | 1505 |
1510 // Pasting amid text should yield the expected text and re-open the popup. | 1506 // Pasting amid text should yield the expected text and re-open the popup. |
1511 omnibox_view->SetWindowTextAndCaretPos(ASCIIToUTF16("abcd"), 2, false, false); | 1507 omnibox_view->SetWindowTextAndCaretPos(ASCIIToUTF16("abcd"), 2, false, false); |
1512 SetClipboardText(ASCIIToUTF16("123")); | 1508 SetClipboardText(ASCIIToUTF16("123")); |
1513 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, kCtrlOrCmdMask)); | 1509 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, kCtrlOrCmdMask)); |
1514 EXPECT_EQ(ASCIIToUTF16("ab123cd"), omnibox_view->GetText()); | 1510 EXPECT_EQ(ASCIIToUTF16("ab123cd"), omnibox_view->GetText()); |
1515 EXPECT_TRUE(popup_model->IsOpen()); | 1511 EXPECT_TRUE(popup_model->IsOpen()); |
1516 | 1512 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1785 omnibox_view->Update(); | 1781 omnibox_view->Update(); |
1786 EXPECT_EQ(url_c, omnibox_view->GetText()); | 1782 EXPECT_EQ(url_c, omnibox_view->GetText()); |
1787 } | 1783 } |
1788 | 1784 |
1789 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscDisablesSearchTermReplacement) { | 1785 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscDisablesSearchTermReplacement) { |
1790 browser()->toolbar_model()->set_url_replacement_enabled(true); | 1786 browser()->toolbar_model()->set_url_replacement_enabled(true); |
1791 chrome::FocusLocationBar(browser()); | 1787 chrome::FocusLocationBar(browser()); |
1792 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); | 1788 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); |
1793 EXPECT_FALSE(browser()->toolbar_model()->url_replacement_enabled()); | 1789 EXPECT_FALSE(browser()->toolbar_model()->url_replacement_enabled()); |
1794 } | 1790 } |
OLD | NEW |