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

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

Issue 12238002: Views Textfield: Copy on Ctrl+Insert, fix and disable overtype. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Expand unit tests. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/textfield/native_textfield_views.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 (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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/auto_reset.h" 8 #include "base/auto_reset.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 SendKeyEvent(ui::VKEY_Z, false, true); 1299 SendKeyEvent(ui::VKEY_Z, false, true);
1300 EXPECT_STR_EQ("abc", textfield_->text()); 1300 EXPECT_STR_EQ("abc", textfield_->text());
1301 SendKeyEvent(ui::VKEY_Y, false, true); 1301 SendKeyEvent(ui::VKEY_Y, false, true);
1302 EXPECT_STR_EQ("ab", textfield_->text()); 1302 EXPECT_STR_EQ("ab", textfield_->text());
1303 SendKeyEvent(ui::VKEY_Y, false, true); 1303 SendKeyEvent(ui::VKEY_Y, false, true);
1304 EXPECT_STR_EQ("b", textfield_->text()); 1304 EXPECT_STR_EQ("b", textfield_->text());
1305 SendKeyEvent(ui::VKEY_Y, false, true); 1305 SendKeyEvent(ui::VKEY_Y, false, true);
1306 EXPECT_STR_EQ("", textfield_->text()); 1306 EXPECT_STR_EQ("", textfield_->text());
1307 SendKeyEvent(ui::VKEY_Y, false, true); 1307 SendKeyEvent(ui::VKEY_Y, false, true);
1308 EXPECT_STR_EQ("", textfield_->text()); 1308 EXPECT_STR_EQ("", textfield_->text());
1309 }
1309 1310
1310 // Insert 1311 TEST_F(NativeTextfieldViewsTest, CopyPasteShortcuts) {
1312 InitTextfield(Textfield::STYLE_DEFAULT);
1313 // Ensure [Ctrl]+[c] copies and [Ctrl]+[v] pastes.
1314 textfield_->SetText(ASCIIToUTF16("abc"));
1315 textfield_->SelectAll(false);
1316 SendKeyEvent(ui::VKEY_C, false, true);
1317 EXPECT_STR_EQ("abc", string16(GetClipboardText()));
1318 SendKeyEvent(ui::VKEY_HOME);
1319 SendKeyEvent(ui::VKEY_V, false, true);
1320 EXPECT_STR_EQ("abcabc", textfield_->text());
1321
1322 // Ensure [Ctrl]+[Insert] copies and [Shift]+[Insert] pastes.
1311 textfield_->SetText(ASCIIToUTF16("123")); 1323 textfield_->SetText(ASCIIToUTF16("123"));
1324 textfield_->SelectAll(false);
1325 SendKeyEvent(ui::VKEY_INSERT, false, true);
1326 EXPECT_STR_EQ("123", string16(GetClipboardText()));
1327 SendKeyEvent(ui::VKEY_HOME);
1328 SendKeyEvent(ui::VKEY_INSERT, true, false);
1329 EXPECT_STR_EQ("123123", textfield_->text());
1330 // Ensure [Ctrl]+[Shift]+[Insert] is a no-op.
1331 textfield_->SelectAll(false);
1332 SendKeyEvent(ui::VKEY_INSERT, true, true);
1333 EXPECT_STR_EQ("123", string16(GetClipboardText()));
1334 EXPECT_STR_EQ("123123", textfield_->text());
1335 }
1336
1337 TEST_F(NativeTextfieldViewsTest, OvertypeMode) {
1338 InitTextfield(Textfield::STYLE_DEFAULT);
1339 // Overtype mode should be disabled (no-op [Insert]).
1340 textfield_->SetText(ASCIIToUTF16("2"));
1312 SendKeyEvent(ui::VKEY_HOME); 1341 SendKeyEvent(ui::VKEY_HOME);
1313 SendKeyEvent(ui::VKEY_INSERT); 1342 SendKeyEvent(ui::VKEY_INSERT);
1314 SendKeyEvent(ui::VKEY_A); 1343 SendKeyEvent(ui::VKEY_1, false, false);
1315 EXPECT_STR_EQ("a23", textfield_->text()); 1344 EXPECT_STR_EQ("12", textfield_->text());
1316 SendKeyEvent(ui::VKEY_B);
1317 EXPECT_STR_EQ("ab3", textfield_->text());
1318 SendKeyEvent(ui::VKEY_Z, false, true);
1319 EXPECT_STR_EQ("123", textfield_->text());
1320 SendKeyEvent(ui::VKEY_Y, false, true);
1321 EXPECT_STR_EQ("ab3", textfield_->text());
1322 } 1345 }
1323 1346
1324 TEST_F(NativeTextfieldViewsTest, TextCursorDisplayTest) { 1347 TEST_F(NativeTextfieldViewsTest, TextCursorDisplayTest) {
1325 InitTextfield(Textfield::STYLE_DEFAULT); 1348 InitTextfield(Textfield::STYLE_DEFAULT);
1326 // LTR-RTL string in LTR context. 1349 // LTR-RTL string in LTR context.
1327 SendKeyEvent('a'); 1350 SendKeyEvent('a');
1328 EXPECT_STR_EQ("a", textfield_->text()); 1351 EXPECT_STR_EQ("a", textfield_->text());
1329 int x = GetCursorBounds().x(); 1352 int x = GetCursorBounds().x();
1330 int prev_x = x; 1353 int prev_x = x;
1331 1354
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 EXPECT_EQ(char_rect[i], actual_rect) << " i=" << i; 1696 EXPECT_EQ(char_rect[i], actual_rect) << " i=" << i;
1674 } 1697 }
1675 1698
1676 // Return false if the index is out of range. 1699 // Return false if the index is out of range.
1677 EXPECT_FALSE(client->GetCompositionCharacterBounds(char_count, &rect)); 1700 EXPECT_FALSE(client->GetCompositionCharacterBounds(char_count, &rect));
1678 EXPECT_FALSE(client->GetCompositionCharacterBounds(char_count + 1, &rect)); 1701 EXPECT_FALSE(client->GetCompositionCharacterBounds(char_count + 1, &rect));
1679 EXPECT_FALSE(client->GetCompositionCharacterBounds(char_count + 100, &rect)); 1702 EXPECT_FALSE(client->GetCompositionCharacterBounds(char_count + 100, &rect));
1680 } 1703 }
1681 1704
1682 } // namespace views 1705 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/native_textfield_views.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698