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

Unified Diff: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc

Issue 2891653003: [omnibox] Break out SetCaretPos() method and enhance browser test (Closed)
Patch Set: Better Mac call Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
index f50e5aa2b21729397151b593e7bb21a91071dcc9..dc2b74ff18cd95cee9528ef360b9048f712ec183 100644
--- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
+++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
@@ -861,13 +861,34 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, BasicTextOperations) {
EXPECT_EQ(0U, end);
EXPECT_TRUE(omnibox_view->GetText().empty());
+ // Add a small amount of text.
Peter Kasting 2017/05/18 18:38:34 Nit: "...to move the cursor to a nonzero value."
Kevin Bailey 2017/05/18 19:48:16 Done.
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0));
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_B, 0));
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_C, 0));
+
// Check if RevertAll() can set text and cursor correctly.
omnibox_view->RevertAll();
EXPECT_FALSE(omnibox_view->IsSelectAll());
EXPECT_EQ(old_text, omnibox_view->GetText());
omnibox_view->GetSelectionBounds(&start, &end);
- EXPECT_EQ(0U, start);
- EXPECT_EQ(0U, end);
+ EXPECT_EQ(3U, start);
+ EXPECT_EQ(3U, end);
+
+ // Check if cursor gets reverted safely.
Peter Kasting 2017/05/18 18:38:34 Nit: Maybe "Check that reverting clamps the cursor
Kevin Bailey 2017/05/18 19:48:17 Done.
+ // Move the cursor to the end.
+#if defined(OS_MACOSX)
+ // End doesn't work on Mac trybot.
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_E, ui::EF_CONTROL_DOWN));
+#else
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_END, 0));
+#endif
+ // Add a small amount of text.
Peter Kasting 2017/05/18 18:38:34 Nit: "...to push the cursor past where the text en
Kevin Bailey 2017/05/18 19:48:16 Done.
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0));
+ omnibox_view->RevertAll();
+ // Cursor should be no further than original text.
+ omnibox_view->GetSelectionBounds(&start, &end);
+ EXPECT_EQ(11U, start);
+ EXPECT_EQ(11U, end);
}
// Make sure the cursor position doesn't get set past the last character of

Powered by Google App Engine
This is Rietveld 408576698