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

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

Issue 2829823002: [Textfield] Consider select all status for select all context menu (Closed)
Patch Set: Add test for empty text Created 3 years, 8 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 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 // Select line towards right. 941 // Select line towards right.
942 SendEndEvent(true); 942 SendEndEvent(true);
943 #if defined(OS_MACOSX) 943 #if defined(OS_MACOSX)
944 EXPECT_EQ(textfield_->text(), textfield_->GetSelectedText()); 944 EXPECT_EQ(textfield_->text(), textfield_->GetSelectedText());
945 #else 945 #else
946 EXPECT_STR_EQ("67 89", textfield_->GetSelectedText()); 946 EXPECT_STR_EQ("67 89", textfield_->GetSelectedText());
947 #endif 947 #endif
948 EXPECT_FALSE(textfield_->GetSelectedRange().is_reversed()); 948 EXPECT_FALSE(textfield_->GetSelectedRange().is_reversed());
949 } 949 }
950 950
951 TEST_F(TextfieldTest, IsAllSelected) {
952 InitTextfield();
953 EXPECT_FALSE(textfield_->IsAllSelected());
954
955 textfield_->SetText(ASCIIToUTF16("12 34567 89"));
956 textfield_->SelectAll(false);
957 EXPECT_TRUE(textfield_->IsAllSelected());
958
959 textfield_->SetSelectionRange(gfx::Range(0, 2));
960 EXPECT_FALSE(textfield_->IsAllSelected());
961
962 textfield_->SetText(base::string16());
Peter Kasting 2017/04/20 00:08:30 Maybe after this we should SelectAll(), before che
simonhong 2017/04/20 13:11:51 We don't need to that because when different text
963 EXPECT_FALSE(textfield_->IsAllSelected());
964 }
965
951 TEST_F(TextfieldTest, MoveUpDownAndModifySelection) { 966 TEST_F(TextfieldTest, MoveUpDownAndModifySelection) {
952 InitTextfield(); 967 InitTextfield();
953 textfield_->SetText(ASCIIToUTF16("12 34567 89")); 968 textfield_->SetText(ASCIIToUTF16("12 34567 89"));
954 textfield_->SetSelectionRange(gfx::Range(6)); 969 textfield_->SetSelectionRange(gfx::Range(6));
955 970
956 // Up/Down keys won't be handled except on Mac where they map to move 971 // Up/Down keys won't be handled except on Mac where they map to move
957 // commands. 972 // commands.
958 SendKeyEvent(ui::VKEY_UP); 973 SendKeyEvent(ui::VKEY_UP);
959 EXPECT_TRUE(textfield_->key_received()); 974 EXPECT_TRUE(textfield_->key_received());
960 #if defined(OS_MACOSX) 975 #if defined(OS_MACOSX)
(...skipping 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after
3117 InitTextfield(); 3132 InitTextfield();
3118 3133
3119 textfield_->SetCursorEnabled(false); 3134 textfield_->SetCursorEnabled(false);
3120 EXPECT_FALSE(test_api_->IsCursorVisible()); 3135 EXPECT_FALSE(test_api_->IsCursorVisible());
3121 3136
3122 textfield_->SetCursorEnabled(true); 3137 textfield_->SetCursorEnabled(true);
3123 EXPECT_TRUE(test_api_->IsCursorVisible()); 3138 EXPECT_TRUE(test_api_->IsCursorVisible());
3124 } 3139 }
3125 3140
3126 } // namespace views 3141 } // namespace views
OLDNEW
« ui/views/controls/textfield/textfield.cc ('K') | « ui/views/controls/textfield/textfield.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698