OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |