| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 MoveCursorTo(model, 17); | 590 MoveCursorTo(model, 17); |
| 591 model.SelectWord(); | 591 model.SelectWord(); |
| 592 SelectWordTestVerifier(model, base::ASCIIToUTF16(" "), 20U); | 592 SelectWordTestVerifier(model, base::ASCIIToUTF16(" "), 20U); |
| 593 | 593 |
| 594 // Test when cursor is at the end. | 594 // Test when cursor is at the end. |
| 595 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); | 595 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); |
| 596 model.SelectWord(); | 596 model.SelectWord(); |
| 597 SelectWordTestVerifier(model, base::ASCIIToUTF16(" "), 24U); | 597 SelectWordTestVerifier(model, base::ASCIIToUTF16(" "), 24U); |
| 598 } | 598 } |
| 599 | 599 |
| 600 TEST_F(TextfieldModelTest, SelectToStartTest) { |
| 601 TextfieldModel model(nullptr); |
| 602 model.Append(base::ASCIIToUTF16("Hello, World!")); |
| 603 MoveCursorTo(model, 5); |
| 604 model.MoveCursorToStart(true); |
| 605 EXPECT_EQ(model.GetSelectedText(), base::ASCIIToUTF16("Hello")); |
| 606 EXPECT_EQ(model.GetCursorPosition(), 0U); |
| 607 } |
| 608 |
| 609 TEST_F(TextfieldModelTest, SelectToEndTest) { |
| 610 TextfieldModel model(nullptr); |
| 611 model.Append(base::ASCIIToUTF16("Hello, World!")); |
| 612 MoveCursorTo(model, 7); |
| 613 model.MoveCursorToEnd(true); |
| 614 EXPECT_EQ(model.GetSelectedText(), base::ASCIIToUTF16("World!")); |
| 615 EXPECT_EQ(model.GetCursorPosition(), 13U); |
| 616 } |
| 617 |
| 600 // TODO(xji): temporarily disable in platform Win since the complex script | 618 // TODO(xji): temporarily disable in platform Win since the complex script |
| 601 // characters and Chinese characters are turned into empty square due to font | 619 // characters and Chinese characters are turned into empty square due to font |
| 602 // regression. | 620 // regression. |
| 603 #if defined(OS_LINUX) | 621 #if defined(OS_LINUX) |
| 604 TEST_F(TextfieldModelTest, SelectWordTest_MixScripts) { | 622 TEST_F(TextfieldModelTest, SelectWordTest_MixScripts) { |
| 605 TextfieldModel model(NULL); | 623 TextfieldModel model(NULL); |
| 606 std::vector<WordAndCursor> word_and_cursor; | 624 std::vector<WordAndCursor> word_and_cursor; |
| 607 word_and_cursor.push_back(WordAndCursor(L"a\x05d0", 2)); | 625 word_and_cursor.push_back(WordAndCursor(L"a\x05d0", 2)); |
| 608 word_and_cursor.push_back(WordAndCursor(L"a\x05d0", 2)); | 626 word_and_cursor.push_back(WordAndCursor(L"a\x05d0", 2)); |
| 609 word_and_cursor.push_back(WordAndCursor(L"\x05d1\x05d2", 5)); | 627 word_and_cursor.push_back(WordAndCursor(L"\x05d1\x05d2", 5)); |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1582 // Test 7 | 1600 // Test 7 |
| 1583 // Clipboard text with lots of spaces between words should have all spaces | 1601 // Clipboard text with lots of spaces between words should have all spaces |
| 1584 // replaced with a single space. | 1602 // replaced with a single space. |
| 1585 ui::ScopedClipboardWriter(ui::CLIPBOARD_TYPE_COPY_PASTE) | 1603 ui::ScopedClipboardWriter(ui::CLIPBOARD_TYPE_COPY_PASTE) |
| 1586 .WriteText(base::ASCIIToUTF16("FOO BAR")); | 1604 .WriteText(base::ASCIIToUTF16("FOO BAR")); |
| 1587 EXPECT_TRUE(model.Paste()); | 1605 EXPECT_TRUE(model.Paste()); |
| 1588 EXPECT_STR_EQ("FOO BAR", model.text()); | 1606 EXPECT_STR_EQ("FOO BAR", model.text()); |
| 1589 } | 1607 } |
| 1590 | 1608 |
| 1591 } // namespace views | 1609 } // namespace views |
| OLD | NEW |