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

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: More checks 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
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | no next file » | 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 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
1348 input_method_->Clear();
1341 textfield_->SetReadOnly(false); 1349 textfield_->SetReadOnly(false);
1350 EXPECT_TRUE(input_method_->text_input_type_changed());
1351 EXPECT_EQ(text_input_client, textfield_->GetTextInputClient());
1352 EXPECT_NE(ui::TEXT_INPUT_TYPE_NONE, text_input_client->GetTextInputType());
1353
1342 input_method_->Clear(); 1354 input_method_->Clear();
1343 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 1355 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
1344 EXPECT_TRUE(input_method_->text_input_type_changed()); 1356 EXPECT_TRUE(input_method_->text_input_type_changed());
1345 EXPECT_TRUE(textfield_->GetTextInputClient()); 1357 EXPECT_TRUE(textfield_->GetTextInputClient());
1346 } 1358 }
1347 1359
1348 TEST_F(TextfieldTest, UndoRedoTest) { 1360 TEST_F(TextfieldTest, UndoRedoTest) {
1349 InitTextfield(); 1361 InitTextfield();
1350 SendKeyEvent(ui::VKEY_A); 1362 SendKeyEvent(ui::VKEY_A);
1351 EXPECT_STR_EQ("a", textfield_->text()); 1363 EXPECT_STR_EQ("a", textfield_->text());
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 2245
2234 // Tap again on selection and check if touch selection handles are still 2246 // Tap again on selection and check if touch selection handles are still
2235 // present and selection is changed to a cursor at tap location. 2247 // present and selection is changed to a cursor at tap location.
2236 Tap(tap_point); 2248 Tap(tap_point);
2237 textfield_->GetSelectionRange(&range); 2249 textfield_->GetSelectionRange(&range);
2238 EXPECT_TRUE(test_api_->touch_selection_controller()); 2250 EXPECT_TRUE(test_api_->touch_selection_controller());
2239 EXPECT_EQ(tap_range, range); 2251 EXPECT_EQ(tap_range, range);
2240 } 2252 }
2241 2253
2242 } // namespace views 2254 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698