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

Side by Side 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 unified diff | Download patch
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/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 EXPECT_EQ(old_text.size(), end); 854 EXPECT_EQ(old_text.size(), end);
855 855
856 // Delete the content 856 // Delete the content
857 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_DELETE, 0)); 857 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_DELETE, 0));
858 EXPECT_TRUE(omnibox_view->IsSelectAll()); 858 EXPECT_TRUE(omnibox_view->IsSelectAll());
859 omnibox_view->GetSelectionBounds(&start, &end); 859 omnibox_view->GetSelectionBounds(&start, &end);
860 EXPECT_EQ(0U, start); 860 EXPECT_EQ(0U, start);
861 EXPECT_EQ(0U, end); 861 EXPECT_EQ(0U, end);
862 EXPECT_TRUE(omnibox_view->GetText().empty()); 862 EXPECT_TRUE(omnibox_view->GetText().empty());
863 863
864 // 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.
865 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0));
866 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_B, 0));
867 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_C, 0));
868
864 // Check if RevertAll() can set text and cursor correctly. 869 // Check if RevertAll() can set text and cursor correctly.
865 omnibox_view->RevertAll(); 870 omnibox_view->RevertAll();
866 EXPECT_FALSE(omnibox_view->IsSelectAll()); 871 EXPECT_FALSE(omnibox_view->IsSelectAll());
867 EXPECT_EQ(old_text, omnibox_view->GetText()); 872 EXPECT_EQ(old_text, omnibox_view->GetText());
868 omnibox_view->GetSelectionBounds(&start, &end); 873 omnibox_view->GetSelectionBounds(&start, &end);
869 EXPECT_EQ(0U, start); 874 EXPECT_EQ(3U, start);
870 EXPECT_EQ(0U, end); 875 EXPECT_EQ(3U, end);
876
877 // 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.
878 // Move the cursor to the end.
879 #if defined(OS_MACOSX)
880 // End doesn't work on Mac trybot.
881 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_E, ui::EF_CONTROL_DOWN));
882 #else
883 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_END, 0));
884 #endif
885 // 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.
886 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0));
887 omnibox_view->RevertAll();
888 // Cursor should be no further than original text.
889 omnibox_view->GetSelectionBounds(&start, &end);
890 EXPECT_EQ(11U, start);
891 EXPECT_EQ(11U, end);
871 } 892 }
872 893
873 // Make sure the cursor position doesn't get set past the last character of 894 // Make sure the cursor position doesn't get set past the last character of
874 // user input text when the URL is longer than the keyword. 895 // user input text when the URL is longer than the keyword.
875 // (http://crbug.com/656209) 896 // (http://crbug.com/656209)
876 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, FocusSearchLongUrl) { 897 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, FocusSearchLongUrl) {
877 OmniboxView* omnibox_view = NULL; 898 OmniboxView* omnibox_view = NULL;
878 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 899 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
879 900
880 ASSERT_GT(strlen(url::kAboutBlankURL), strlen(kSearchKeyword)); 901 ASSERT_GT(strlen(url::kAboutBlankURL), strlen(kSearchKeyword));
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 2020
2000 // Now Shift+Right should do nothing, and Shift+Left should reduce. 2021 // Now Shift+Right should do nothing, and Shift+Left should reduce.
2001 // At the end, so Shift+Right should do nothing. 2022 // At the end, so Shift+Right should do nothing.
2002 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RIGHT, ui::EF_SHIFT_DOWN)); 2023 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RIGHT, ui::EF_SHIFT_DOWN));
2003 EXPECT_EQ(2u, GetSelectionSize(omnibox_view)); 2024 EXPECT_EQ(2u, GetSelectionSize(omnibox_view));
2004 2025
2005 // And Left should reduce by one character. 2026 // And Left should reduce by one character.
2006 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, ui::EF_SHIFT_DOWN)); 2027 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, ui::EF_SHIFT_DOWN));
2007 EXPECT_EQ(1u, GetSelectionSize(omnibox_view)); 2028 EXPECT_EQ(1u, GetSelectionSize(omnibox_view));
2008 } 2029 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698