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

Side by Side Diff: ui/views/controls/textfield/textfield_unittest.cc

Issue 819223002: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years 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 | « ui/ozone/platform_selection.cc ('k') | ui/views/examples/examples_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/views/controls/textfield/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 // Long_Press gesture in Textfield can initiate a drag and drop now. 1914 // Long_Press gesture in Textfield can initiate a drag and drop now.
1915 TEST_F(TextfieldTest, TestLongPressInitiatesDragDrop) { 1915 TEST_F(TextfieldTest, TestLongPressInitiatesDragDrop) {
1916 InitTextfield(); 1916 InitTextfield();
1917 textfield_->SetText(ASCIIToUTF16("Hello string world")); 1917 textfield_->SetText(ASCIIToUTF16("Hello string world"));
1918 1918
1919 // Ensure the textfield will provide selected text for drag data. 1919 // Ensure the textfield will provide selected text for drag data.
1920 textfield_->SelectRange(gfx::Range(6, 12)); 1920 textfield_->SelectRange(gfx::Range(6, 12));
1921 const gfx::Point kStringPoint(GetCursorPositionX(9), 0); 1921 const gfx::Point kStringPoint(GetCursorPositionX(9), 0);
1922 1922
1923 // Enable touch-drag-drop to make long press effective. 1923 // Enable touch-drag-drop to make long press effective.
1924 CommandLine::ForCurrentProcess()->AppendSwitch( 1924 base::CommandLine::ForCurrentProcess()->AppendSwitch(
1925 switches::kEnableTouchDragDrop); 1925 switches::kEnableTouchDragDrop);
1926 1926
1927 // Create a long press event in the selected region should start a drag. 1927 // Create a long press event in the selected region should start a drag.
1928 GestureEventForTest long_press( 1928 GestureEventForTest long_press(
1929 kStringPoint.x(), 1929 kStringPoint.x(),
1930 kStringPoint.y(), 1930 kStringPoint.y(),
1931 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 1931 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
1932 textfield_->OnGestureEvent(&long_press); 1932 textfield_->OnGestureEvent(&long_press);
1933 EXPECT_TRUE(textfield_->CanStartDragForView(NULL, kStringPoint, 1933 EXPECT_TRUE(textfield_->CanStartDragForView(NULL, kStringPoint,
1934 kStringPoint)); 1934 kStringPoint));
(...skipping 26 matching lines...) Expand all
1961 SendKeyEvent('X'); 1961 SendKeyEvent('X');
1962 1962
1963 EXPECT_FALSE(controller.target()); 1963 EXPECT_FALSE(controller.target());
1964 } 1964 }
1965 1965
1966 class TextfieldTouchSelectionTest : public TextfieldTest { 1966 class TextfieldTouchSelectionTest : public TextfieldTest {
1967 public: 1967 public:
1968 // TextfieldTest: 1968 // TextfieldTest:
1969 void SetUp() override { 1969 void SetUp() override {
1970 TextfieldTest::SetUp(); 1970 TextfieldTest::SetUp();
1971 CommandLine::ForCurrentProcess()->AppendSwitch( 1971 base::CommandLine::ForCurrentProcess()->AppendSwitch(
1972 switches::kEnableTouchEditing); 1972 switches::kEnableTouchEditing);
1973 } 1973 }
1974 1974
1975 protected: 1975 protected:
1976 // Simulates a complete tap. 1976 // Simulates a complete tap.
1977 void Tap(const gfx::Point& point) { 1977 void Tap(const gfx::Point& point) {
1978 GestureEventForTest begin( 1978 GestureEventForTest begin(
1979 point.x(), point.y(), ui::GestureEventDetails(ui::ET_GESTURE_BEGIN)); 1979 point.x(), point.y(), ui::GestureEventDetails(ui::ET_GESTURE_BEGIN));
1980 textfield_->OnGestureEvent(&begin); 1980 textfield_->OnGestureEvent(&begin);
1981 1981
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 ASSERT_TRUE(switches::IsTouchDragDropEnabled()); 2035 ASSERT_TRUE(switches::IsTouchDragDropEnabled());
2036 GestureEventForTest long_press_2( 2036 GestureEventForTest long_press_2(
2037 x, 0, ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 2037 x, 0, ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
2038 textfield_->OnGestureEvent(&long_press_2); 2038 textfield_->OnGestureEvent(&long_press_2);
2039 EXPECT_STR_EQ("hello", textfield_->GetSelectedText()); 2039 EXPECT_STR_EQ("hello", textfield_->GetSelectedText());
2040 EXPECT_FALSE(test_api_->touch_selection_controller()); 2040 EXPECT_FALSE(test_api_->touch_selection_controller());
2041 EXPECT_FALSE(long_press_2.handled()); 2041 EXPECT_FALSE(long_press_2.handled());
2042 2042
2043 // After disabling touch drag drop, long pressing again in the selection 2043 // After disabling touch drag drop, long pressing again in the selection
2044 // region should not do anything. 2044 // region should not do anything.
2045 CommandLine::ForCurrentProcess()->AppendSwitch( 2045 base::CommandLine::ForCurrentProcess()->AppendSwitch(
2046 switches::kDisableTouchDragDrop); 2046 switches::kDisableTouchDragDrop);
2047 ASSERT_FALSE(switches::IsTouchDragDropEnabled()); 2047 ASSERT_FALSE(switches::IsTouchDragDropEnabled());
2048 GestureEventForTest long_press_3( 2048 GestureEventForTest long_press_3(
2049 x, 0, ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 2049 x, 0, ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
2050 textfield_->OnGestureEvent(&long_press_3); 2050 textfield_->OnGestureEvent(&long_press_3);
2051 EXPECT_STR_EQ("hello", textfield_->GetSelectedText()); 2051 EXPECT_STR_EQ("hello", textfield_->GetSelectedText());
2052 EXPECT_FALSE(test_api_->touch_selection_controller()); 2052 EXPECT_FALSE(test_api_->touch_selection_controller());
2053 EXPECT_FALSE(long_press_3.handled()); 2053 EXPECT_FALSE(long_press_3.handled());
2054 } 2054 }
2055 #endif 2055 #endif
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 2101
2102 // Tap again on selection and check if touch selection handles are still 2102 // Tap again on selection and check if touch selection handles are still
2103 // present and selection is changed to a cursor at tap location. 2103 // present and selection is changed to a cursor at tap location.
2104 Tap(tap_point); 2104 Tap(tap_point);
2105 textfield_->GetSelectionRange(&range); 2105 textfield_->GetSelectionRange(&range);
2106 EXPECT_TRUE(test_api_->touch_selection_controller()); 2106 EXPECT_TRUE(test_api_->touch_selection_controller());
2107 EXPECT_EQ(tap_range, range); 2107 EXPECT_EQ(tap_range, range);
2108 } 2108 }
2109 2109
2110 } // namespace views 2110 } // namespace views
OLDNEW
« no previous file with comments | « ui/ozone/platform_selection.cc ('k') | ui/views/examples/examples_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698