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

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

Issue 2228833002: MacViews: Fix behavior of move and select commands when selection direction changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use_text_commands
Patch Set: Created 4 years, 4 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 SendKeyEvent(ui::VKEY_Z, true, false); 825 SendKeyEvent(ui::VKEY_Z, true, false);
826 SendKeyEvent(ui::VKEY_E, true, false); 826 SendKeyEvent(ui::VKEY_E, true, false);
827 SendKeyEvent(ui::VKEY_R, true, false); 827 SendKeyEvent(ui::VKEY_R, true, false);
828 SendKeyEvent(ui::VKEY_O, true, false); 828 SendKeyEvent(ui::VKEY_O, true, false);
829 SendKeyEvent(ui::VKEY_SPACE, false, false); 829 SendKeyEvent(ui::VKEY_SPACE, false, false);
830 EXPECT_STR_EQ("ZERO two three", textfield_->text()); 830 EXPECT_STR_EQ("ZERO two three", textfield_->text());
831 831
832 SendEndEvent(true); 832 SendEndEvent(true);
833 EXPECT_STR_EQ("two three", textfield_->GetSelectedText()); 833 EXPECT_STR_EQ("two three", textfield_->GetSelectedText());
834 SendHomeEvent(true); 834 SendHomeEvent(true);
835
836 // On Mac, the existing selection should be extended.
837 #if defined(OS_MACOSX)
838 EXPECT_STR_EQ("ZERO two three", textfield_->GetSelectedText());
839 #else
835 EXPECT_STR_EQ("ZERO ", textfield_->GetSelectedText()); 840 EXPECT_STR_EQ("ZERO ", textfield_->GetSelectedText());
841 #endif
836 } 842 }
837 843
838 TEST_F(TextfieldTest, InsertionDeletionTest) { 844 TEST_F(TextfieldTest, InsertionDeletionTest) {
839 // Insert a test string in a textfield. 845 // Insert a test string in a textfield.
840 InitTextfield(); 846 InitTextfield();
841 for (size_t i = 0; i < 10; i++) 847 for (size_t i = 0; i < 10; i++)
842 SendKeyEvent(static_cast<ui::KeyboardCode>(ui::VKEY_A + i)); 848 SendKeyEvent(static_cast<ui::KeyboardCode>(ui::VKEY_A + i));
843 EXPECT_STR_EQ("abcdefghij", textfield_->text()); 849 EXPECT_STR_EQ("abcdefghij", textfield_->text());
844 850
845 // Test the delete and backspace keys. 851 // Test the delete and backspace keys.
(...skipping 1907 matching lines...) Expand 10 before | Expand all | Expand 10 after
2753 2759
2754 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 2760 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
2755 ui::AXViewState state_protected; 2761 ui::AXViewState state_protected;
2756 textfield_->GetAccessibleState(&state_protected); 2762 textfield_->GetAccessibleState(&state_protected);
2757 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); 2763 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role);
2758 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); 2764 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value);
2759 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); 2765 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED));
2760 } 2766 }
2761 2767
2762 } // namespace views 2768 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698