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

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

Issue 919543003: Make Textfield::GetTextInputClient() return non-null, even if readonly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20150211-MacViews-TextfileTest-B-split-input-method
Patch Set: Created 5 years, 10 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 <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 // On{Before,After}UserAction should be called by whatever user action 1327 // On{Before,After}UserAction should be called by whatever user action
1328 // triggers clearing or setting a selection if appropriate. 1328 // triggers clearing or setting a selection if appropriate.
1329 on_before_user_action_ = on_after_user_action_ = 0; 1329 on_before_user_action_ = on_after_user_action_ = 0;
1330 textfield_->clear(); 1330 textfield_->clear();
1331 textfield_->ClearSelection(); 1331 textfield_->ClearSelection();
1332 textfield_->SelectAll(false); 1332 textfield_->SelectAll(false);
1333 EXPECT_EQ(0, on_before_user_action_); 1333 EXPECT_EQ(0, on_before_user_action_);
1334 EXPECT_EQ(0, on_after_user_action_); 1334 EXPECT_EQ(0, on_after_user_action_);
1335 1335
1336 input_method_->Clear(); 1336 input_method_->Clear();
1337
1338 // Changing the Textfield to readonly shouldn't change the input client, since
1339 // it's still required for selections and clipboard copy.
1340 ui::TextInputClient* text_input_client = textfield_->GetTextInputClient();
1341 EXPECT_TRUE(text_input_client);
1342 EXPECT_NE(ui::TEXT_INPUT_TYPE_NONE, text_input_client->GetTextInputType());
1337 textfield_->SetReadOnly(true); 1343 textfield_->SetReadOnly(true);
1338 EXPECT_TRUE(input_method_->text_input_type_changed()); 1344 EXPECT_TRUE(input_method_->text_input_type_changed());
1339 EXPECT_FALSE(textfield_->GetTextInputClient()); 1345 EXPECT_EQ(text_input_client, textfield_->GetTextInputClient());
1346 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, text_input_client->GetTextInputType());
1340 1347
1341 textfield_->SetReadOnly(false); 1348 textfield_->SetReadOnly(false);
msw 2015/02/11 16:45:00 nit: add EXPECT_TRUE(input_method_->text_input_typ
tapted 2015/02/11 23:29:08 Done.
1349 EXPECT_NE(ui::TEXT_INPUT_TYPE_NONE, text_input_client->GetTextInputType());
1350
1342 input_method_->Clear(); 1351 input_method_->Clear();
1343 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 1352 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
1344 EXPECT_TRUE(input_method_->text_input_type_changed()); 1353 EXPECT_TRUE(input_method_->text_input_type_changed());
1345 EXPECT_TRUE(textfield_->GetTextInputClient()); 1354 EXPECT_TRUE(textfield_->GetTextInputClient());
1346 } 1355 }
1347 1356
1348 TEST_F(TextfieldTest, UndoRedoTest) { 1357 TEST_F(TextfieldTest, UndoRedoTest) {
1349 InitTextfield(); 1358 InitTextfield();
1350 SendKeyEvent(ui::VKEY_A); 1359 SendKeyEvent(ui::VKEY_A);
1351 EXPECT_STR_EQ("a", textfield_->text()); 1360 EXPECT_STR_EQ("a", textfield_->text());
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 2242
2234 // Tap again on selection and check if touch selection handles are still 2243 // Tap again on selection and check if touch selection handles are still
2235 // present and selection is changed to a cursor at tap location. 2244 // present and selection is changed to a cursor at tap location.
2236 Tap(tap_point); 2245 Tap(tap_point);
2237 textfield_->GetSelectionRange(&range); 2246 textfield_->GetSelectionRange(&range);
2238 EXPECT_TRUE(test_api_->touch_selection_controller()); 2247 EXPECT_TRUE(test_api_->touch_selection_controller());
2239 EXPECT_EQ(tap_range, range); 2248 EXPECT_EQ(tap_range, range);
2240 } 2249 }
2241 2250
2242 } // namespace views 2251 } // 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