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

Side by Side Diff: ui/base/ime/input_method_chromeos_unittest.cc

Issue 313053007: Passing BackgroundColorSpan and UnderlineSpan from Clank to Blink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync. Created 6 years, 6 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
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/base/ime/input_method_chromeos.h" 5 #include "ui/base/ime/input_method_chromeos.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #undef Bool 8 #undef Bool
9 #undef FocusIn 9 #undef FocusIn
10 #undef FocusOut 10 #undef FocusOut
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 EXPECT_EQ(kCursorPos, composition_text.selection.start()); 666 EXPECT_EQ(kCursorPos, composition_text.selection.start());
667 EXPECT_EQ(kCursorPos, composition_text.selection.end()); 667 EXPECT_EQ(kCursorPos, composition_text.selection.end());
668 ASSERT_EQ(1UL, composition_text.underlines.size()); 668 ASSERT_EQ(1UL, composition_text.underlines.size());
669 EXPECT_EQ(GetOffsetInUTF16(kSampleText, underline.start_index), 669 EXPECT_EQ(GetOffsetInUTF16(kSampleText, underline.start_index),
670 composition_text.underlines[0].start_offset); 670 composition_text.underlines[0].start_offset);
671 EXPECT_EQ(GetOffsetInUTF16(kSampleText, underline.end_index), 671 EXPECT_EQ(GetOffsetInUTF16(kSampleText, underline.end_index),
672 composition_text.underlines[0].end_offset); 672 composition_text.underlines[0].end_offset);
673 // Single underline represents as black thin line. 673 // Single underline represents as black thin line.
674 EXPECT_EQ(SK_ColorBLACK, composition_text.underlines[0].color); 674 EXPECT_EQ(SK_ColorBLACK, composition_text.underlines[0].color);
675 EXPECT_FALSE(composition_text.underlines[0].thick); 675 EXPECT_FALSE(composition_text.underlines[0].thick);
676 EXPECT_EQ(SK_ColorTRANSPARENT,
677 composition_text.underlines[0].background_color);
676 } 678 }
677 679
678 TEST_F(InputMethodChromeOSTest, ExtractCompositionTextTest_DoubleUnderline) { 680 TEST_F(InputMethodChromeOSTest, ExtractCompositionTextTest_DoubleUnderline) {
679 const uint32 kCursorPos = 2UL; 681 const uint32 kCursorPos = 2UL;
680 682
681 // Set up chromeos composition text with one underline attribute. 683 // Set up chromeos composition text with one underline attribute.
682 chromeos::CompositionText chromeos_composition_text; 684 chromeos::CompositionText chromeos_composition_text;
683 chromeos_composition_text.set_text(kSampleText); 685 chromeos_composition_text.set_text(kSampleText);
684 chromeos::CompositionText::UnderlineAttribute underline; 686 chromeos::CompositionText::UnderlineAttribute underline;
685 underline.type = chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_DOUBLE; 687 underline.type = chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_DOUBLE;
(...skipping 10 matching lines...) Expand all
696 EXPECT_EQ(kCursorPos, composition_text.selection.start()); 698 EXPECT_EQ(kCursorPos, composition_text.selection.start());
697 EXPECT_EQ(kCursorPos, composition_text.selection.end()); 699 EXPECT_EQ(kCursorPos, composition_text.selection.end());
698 ASSERT_EQ(1UL, composition_text.underlines.size()); 700 ASSERT_EQ(1UL, composition_text.underlines.size());
699 EXPECT_EQ(GetOffsetInUTF16(kSampleText, underline.start_index), 701 EXPECT_EQ(GetOffsetInUTF16(kSampleText, underline.start_index),
700 composition_text.underlines[0].start_offset); 702 composition_text.underlines[0].start_offset);
701 EXPECT_EQ(GetOffsetInUTF16(kSampleText, underline.end_index), 703 EXPECT_EQ(GetOffsetInUTF16(kSampleText, underline.end_index),
702 composition_text.underlines[0].end_offset); 704 composition_text.underlines[0].end_offset);
703 // Double underline represents as black thick line. 705 // Double underline represents as black thick line.
704 EXPECT_EQ(SK_ColorBLACK, composition_text.underlines[0].color); 706 EXPECT_EQ(SK_ColorBLACK, composition_text.underlines[0].color);
705 EXPECT_TRUE(composition_text.underlines[0].thick); 707 EXPECT_TRUE(composition_text.underlines[0].thick);
708 EXPECT_EQ(SK_ColorTRANSPARENT,
709 composition_text.underlines[0].background_color);
706 } 710 }
707 711
708 TEST_F(InputMethodChromeOSTest, ExtractCompositionTextTest_ErrorUnderline) { 712 TEST_F(InputMethodChromeOSTest, ExtractCompositionTextTest_ErrorUnderline) {
709 const uint32 kCursorPos = 2UL; 713 const uint32 kCursorPos = 2UL;
710 714
711 // Set up chromeos composition text with one underline attribute. 715 // Set up chromeos composition text with one underline attribute.
712 chromeos::CompositionText chromeos_composition_text; 716 chromeos::CompositionText chromeos_composition_text;
713 chromeos_composition_text.set_text(kSampleText); 717 chromeos_composition_text.set_text(kSampleText);
714 chromeos::CompositionText::UnderlineAttribute underline; 718 chromeos::CompositionText::UnderlineAttribute underline;
715 underline.type = chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_ERROR; 719 underline.type = chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_ERROR;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 EXPECT_EQ(kCursorPos, composition_text.selection.end()); 755 EXPECT_EQ(kCursorPos, composition_text.selection.end());
752 ASSERT_EQ(1UL, composition_text.underlines.size()); 756 ASSERT_EQ(1UL, composition_text.underlines.size());
753 EXPECT_EQ(GetOffsetInUTF16(kSampleText, 757 EXPECT_EQ(GetOffsetInUTF16(kSampleText,
754 chromeos_composition_text.selection_start()), 758 chromeos_composition_text.selection_start()),
755 composition_text.underlines[0].start_offset); 759 composition_text.underlines[0].start_offset);
756 EXPECT_EQ(GetOffsetInUTF16(kSampleText, 760 EXPECT_EQ(GetOffsetInUTF16(kSampleText,
757 chromeos_composition_text.selection_end()), 761 chromeos_composition_text.selection_end()),
758 composition_text.underlines[0].end_offset); 762 composition_text.underlines[0].end_offset);
759 EXPECT_EQ(SK_ColorBLACK, composition_text.underlines[0].color); 763 EXPECT_EQ(SK_ColorBLACK, composition_text.underlines[0].color);
760 EXPECT_TRUE(composition_text.underlines[0].thick); 764 EXPECT_TRUE(composition_text.underlines[0].thick);
765 EXPECT_EQ(SK_ColorTRANSPARENT,
766 composition_text.underlines[0].background_color);
761 } 767 }
762 768
763 TEST_F(InputMethodChromeOSTest, 769 TEST_F(InputMethodChromeOSTest,
764 ExtractCompositionTextTest_SelectionStartWithCursor) { 770 ExtractCompositionTextTest_SelectionStartWithCursor) {
765 const uint32 kCursorPos = 1UL; 771 const uint32 kCursorPos = 1UL;
766 772
767 // Set up chromeos composition text with one underline attribute. 773 // Set up chromeos composition text with one underline attribute.
768 chromeos::CompositionText chromeos_composition_text; 774 chromeos::CompositionText chromeos_composition_text;
769 chromeos_composition_text.set_text(kSampleText); 775 chromeos_composition_text.set_text(kSampleText);
770 chromeos_composition_text.set_selection_start(kCursorPos); 776 chromeos_composition_text.set_selection_start(kCursorPos);
(...skipping 12 matching lines...) Expand all
783 composition_text.selection.end()); 789 composition_text.selection.end());
784 ASSERT_EQ(1UL, composition_text.underlines.size()); 790 ASSERT_EQ(1UL, composition_text.underlines.size());
785 EXPECT_EQ(GetOffsetInUTF16(kSampleText, 791 EXPECT_EQ(GetOffsetInUTF16(kSampleText,
786 chromeos_composition_text.selection_start()), 792 chromeos_composition_text.selection_start()),
787 composition_text.underlines[0].start_offset); 793 composition_text.underlines[0].start_offset);
788 EXPECT_EQ(GetOffsetInUTF16(kSampleText, 794 EXPECT_EQ(GetOffsetInUTF16(kSampleText,
789 chromeos_composition_text.selection_end()), 795 chromeos_composition_text.selection_end()),
790 composition_text.underlines[0].end_offset); 796 composition_text.underlines[0].end_offset);
791 EXPECT_EQ(SK_ColorBLACK, composition_text.underlines[0].color); 797 EXPECT_EQ(SK_ColorBLACK, composition_text.underlines[0].color);
792 EXPECT_TRUE(composition_text.underlines[0].thick); 798 EXPECT_TRUE(composition_text.underlines[0].thick);
799 EXPECT_EQ(SK_ColorTRANSPARENT,
800 composition_text.underlines[0].background_color);
793 } 801 }
794 802
795 TEST_F(InputMethodChromeOSTest, 803 TEST_F(InputMethodChromeOSTest,
796 ExtractCompositionTextTest_SelectionEndWithCursor) { 804 ExtractCompositionTextTest_SelectionEndWithCursor) {
797 const uint32 kCursorPos = 4UL; 805 const uint32 kCursorPos = 4UL;
798 806
799 // Set up chromeos composition text with one underline attribute. 807 // Set up chromeos composition text with one underline attribute.
800 chromeos::CompositionText chromeos_composition_text; 808 chromeos::CompositionText chromeos_composition_text;
801 chromeos_composition_text.set_text(kSampleText); 809 chromeos_composition_text.set_text(kSampleText);
802 chromeos_composition_text.set_selection_start(1UL); 810 chromeos_composition_text.set_selection_start(1UL);
(...skipping 12 matching lines...) Expand all
815 composition_text.selection.end()); 823 composition_text.selection.end());
816 ASSERT_EQ(1UL, composition_text.underlines.size()); 824 ASSERT_EQ(1UL, composition_text.underlines.size());
817 EXPECT_EQ(GetOffsetInUTF16(kSampleText, 825 EXPECT_EQ(GetOffsetInUTF16(kSampleText,
818 chromeos_composition_text.selection_start()), 826 chromeos_composition_text.selection_start()),
819 composition_text.underlines[0].start_offset); 827 composition_text.underlines[0].start_offset);
820 EXPECT_EQ(GetOffsetInUTF16(kSampleText, 828 EXPECT_EQ(GetOffsetInUTF16(kSampleText,
821 chromeos_composition_text.selection_end()), 829 chromeos_composition_text.selection_end()),
822 composition_text.underlines[0].end_offset); 830 composition_text.underlines[0].end_offset);
823 EXPECT_EQ(SK_ColorBLACK, composition_text.underlines[0].color); 831 EXPECT_EQ(SK_ColorBLACK, composition_text.underlines[0].color);
824 EXPECT_TRUE(composition_text.underlines[0].thick); 832 EXPECT_TRUE(composition_text.underlines[0].thick);
833 EXPECT_EQ(SK_ColorTRANSPARENT,
834 composition_text.underlines[0].background_color);
825 } 835 }
826 836
827 TEST_F(InputMethodChromeOSTest, SurroundingText_NoSelectionTest) { 837 TEST_F(InputMethodChromeOSTest, SurroundingText_NoSelectionTest) {
828 ime_->Init(true); 838 ime_->Init(true);
829 // Click a text input form. 839 // Click a text input form.
830 input_type_ = TEXT_INPUT_TYPE_TEXT; 840 input_type_ = TEXT_INPUT_TYPE_TEXT;
831 ime_->OnTextInputTypeChanged(this); 841 ime_->OnTextInputTypeChanged(this);
832 842
833 // Set the TextInputClient behaviors. 843 // Set the TextInputClient behaviors.
834 surrounding_text_ = UTF8ToUTF16("abcdef"); 844 surrounding_text_ = UTF8ToUTF16("abcdef");
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 ime_->ResetContext(); 1062 ime_->ResetContext();
1053 1063
1054 // Do callback. 1064 // Do callback.
1055 mock_ime_engine_handler_->last_passed_callback().Run(true); 1065 mock_ime_engine_handler_->last_passed_callback().Run(true);
1056 1066
1057 EXPECT_EQ(0, ime_->process_key_event_post_ime_call_count()); 1067 EXPECT_EQ(0, ime_->process_key_event_post_ime_call_count());
1058 } 1068 }
1059 // TODO(nona): Introduce ProcessKeyEventPostIME tests(crbug.com/156593). 1069 // TODO(nona): Introduce ProcessKeyEventPostIME tests(crbug.com/156593).
1060 1070
1061 } // namespace ui 1071 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698