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

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

Issue 1907253002: MacViews: Implement move and move*AndModifySelection commands. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 4 years, 7 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
« no previous file with comments | « ui/views/cocoa/bridged_native_widget_unittest.mm ('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 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 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 SendHomeEvent(shift); 985 SendHomeEvent(shift);
986 EXPECT_TRUE(textfield_->key_received()); 986 EXPECT_TRUE(textfield_->key_received());
987 EXPECT_TRUE(textfield_->key_handled()); 987 EXPECT_TRUE(textfield_->key_handled());
988 textfield_->clear(); 988 textfield_->clear();
989 989
990 SendEndEvent(shift); 990 SendEndEvent(shift);
991 EXPECT_TRUE(textfield_->key_received()); 991 EXPECT_TRUE(textfield_->key_received());
992 EXPECT_TRUE(textfield_->key_handled()); 992 EXPECT_TRUE(textfield_->key_handled());
993 textfield_->clear(); 993 textfield_->clear();
994 994
995 // F20, up/down key won't be handled. 995 // F20 key won't be handled.
996 SendKeyEvent(ui::VKEY_F20); 996 SendKeyEvent(ui::VKEY_F20);
997 #if defined(OS_MACOSX) 997 #if defined(OS_MACOSX)
998 // On Mac, key combinations that don't map to editing commands are forwarded 998 // On Mac, key combinations that don't map to editing commands are forwarded
999 // on to the next responder, usually ending up at the window, which will beep. 999 // on to the next responder, usually ending up at the window, which will beep.
1000 EXPECT_FALSE(textfield_->key_received()); 1000 EXPECT_FALSE(textfield_->key_received());
1001 #else 1001 #else
1002 EXPECT_TRUE(textfield_->key_received()); 1002 EXPECT_TRUE(textfield_->key_received());
1003 #endif 1003 #endif
1004 EXPECT_FALSE(textfield_->key_handled()); 1004 EXPECT_FALSE(textfield_->key_handled());
1005 textfield_->clear(); 1005 textfield_->clear();
1006 1006
1007 // Up/Down keys won't be handled except on Mac where they map to move
1008 // commands.
1007 SendKeyEvent(ui::VKEY_UP); 1009 SendKeyEvent(ui::VKEY_UP);
1008 EXPECT_TRUE(textfield_->key_received()); 1010 EXPECT_TRUE(textfield_->key_received());
1011 #if defined(OS_MACOSX)
1012 EXPECT_TRUE(textfield_->key_handled());
1013 #else
1009 EXPECT_FALSE(textfield_->key_handled()); 1014 EXPECT_FALSE(textfield_->key_handled());
1015 #endif
1010 textfield_->clear(); 1016 textfield_->clear();
1011 1017
1012 SendKeyEvent(ui::VKEY_DOWN); 1018 SendKeyEvent(ui::VKEY_DOWN);
1013 EXPECT_TRUE(textfield_->key_received()); 1019 EXPECT_TRUE(textfield_->key_received());
1020 #if defined(OS_MACOSX)
1021 EXPECT_TRUE(textfield_->key_handled());
1022 #else
1014 EXPECT_FALSE(textfield_->key_handled()); 1023 EXPECT_FALSE(textfield_->key_handled());
1024 #endif
1015 textfield_->clear(); 1025 textfield_->clear();
1016 } 1026 }
1017 1027
1018 // Tests that default key bindings are handled even with a delegate installed. 1028 // Tests that default key bindings are handled even with a delegate installed.
1019 TEST_F(TextfieldTest, OnKeyPressBinding) { 1029 TEST_F(TextfieldTest, OnKeyPressBinding) {
1020 InitTextfield(); 1030 InitTextfield();
1021 1031
1022 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 1032 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
1023 // Install a TextEditKeyBindingsDelegateAuraLinux that does nothing. 1033 // Install a TextEditKeyBindingsDelegateAuraLinux that does nothing.
1024 class TestDelegate : public ui::TextEditKeyBindingsDelegateAuraLinux { 1034 class TestDelegate : public ui::TextEditKeyBindingsDelegateAuraLinux {
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after
2644 2654
2645 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 2655 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
2646 ui::AXViewState state_protected; 2656 ui::AXViewState state_protected;
2647 textfield_->GetAccessibleState(&state_protected); 2657 textfield_->GetAccessibleState(&state_protected);
2648 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); 2658 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role);
2649 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); 2659 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value);
2650 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); 2660 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED));
2651 } 2661 }
2652 2662
2653 } // namespace views 2663 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/cocoa/bridged_native_widget_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698