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

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

Issue 2505943002: MacViews: Fix accelerator handling while Omnibox is in focus. (Closed)
Patch Set: Fix tapted's review issues. Created 4 years 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 440
441 // Since the window type is activatable, showing the widget will also 441 // Since the window type is activatable, showing the widget will also
442 // activate it. Calling Activate directly is insufficient, since that does 442 // activate it. Calling Activate directly is insufficient, since that does
443 // not also _focus_ an aura::Window (i.e. using the FocusClient). Both the 443 // not also _focus_ an aura::Window (i.e. using the FocusClient). Both the
444 // widget and the textfield must have focus to properly handle input. 444 // widget and the textfield must have focus to properly handle input.
445 widget_->Show(); 445 widget_->Show();
446 textfield_->RequestFocus(); 446 textfield_->RequestFocus();
447 447
448 event_generator_.reset( 448 event_generator_.reset(
449 new ui::test::EventGenerator(widget_->GetNativeWindow())); 449 new ui::test::EventGenerator(widget_->GetNativeWindow()));
450 event_generator_->set_target(ui::test::EventGenerator::Target::WINDOW);
450 } 451 }
451 ui::MenuModel* GetContextMenuModel() { 452 ui::MenuModel* GetContextMenuModel() {
452 test_api_->UpdateContextMenu(); 453 test_api_->UpdateContextMenu();
453 return test_api_->context_menu_contents(); 454 return test_api_->context_menu_contents();
454 } 455 }
455 456
456 // True if native Mac keystrokes should be used (to avoid ifdef litter). 457 // True if native Mac keystrokes should be used (to avoid ifdef litter).
457 bool TestingNativeMac() { 458 bool TestingNativeMac() {
458 #if defined(OS_MACOSX) 459 #if defined(OS_MACOSX)
459 return true; 460 return true;
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 EXPECT_TRUE(textfield_->key_handled()); 1246 EXPECT_TRUE(textfield_->key_handled());
1246 textfield_->clear(); 1247 textfield_->clear();
1247 1248
1248 SendEndEvent(shift); 1249 SendEndEvent(shift);
1249 EXPECT_TRUE(textfield_->key_received()); 1250 EXPECT_TRUE(textfield_->key_received());
1250 EXPECT_TRUE(textfield_->key_handled()); 1251 EXPECT_TRUE(textfield_->key_handled());
1251 textfield_->clear(); 1252 textfield_->clear();
1252 1253
1253 // F20 key won't be handled. 1254 // F20 key won't be handled.
1254 SendKeyEvent(ui::VKEY_F20); 1255 SendKeyEvent(ui::VKEY_F20);
1255 #if defined(OS_MACOSX)
1256 // On Mac, key combinations that don't map to editing commands are forwarded
1257 // on to the next responder, usually ending up at the window, which will beep.
1258 EXPECT_FALSE(textfield_->key_received());
1259 #else
1260 EXPECT_TRUE(textfield_->key_received()); 1256 EXPECT_TRUE(textfield_->key_received());
1261 #endif
1262 EXPECT_FALSE(textfield_->key_handled()); 1257 EXPECT_FALSE(textfield_->key_handled());
1263 textfield_->clear(); 1258 textfield_->clear();
1264 } 1259 }
1265 1260
1266 // Tests that default key bindings are handled even with a delegate installed. 1261 // Tests that default key bindings are handled even with a delegate installed.
1267 TEST_F(TextfieldTest, OnKeyPressBinding) { 1262 TEST_F(TextfieldTest, OnKeyPressBinding) {
1268 InitTextfield(); 1263 InitTextfield();
1269 1264
1270 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 1265 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
1271 // Install a TextEditKeyBindingsDelegateAuraLinux that does nothing. 1266 // Install a TextEditKeyBindingsDelegateAuraLinux that does nothing.
(...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after
3008 ui::AXNodeData node_data_protected; 3003 ui::AXNodeData node_data_protected;
3009 node_data_protected.state = 0; 3004 node_data_protected.state = 0;
3010 textfield_->GetAccessibleNodeData(&node_data_protected); 3005 textfield_->GetAccessibleNodeData(&node_data_protected);
3011 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, node_data_protected.role); 3006 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, node_data_protected.role);
3012 EXPECT_EQ(ASCIIToUTF16("********"), 3007 EXPECT_EQ(ASCIIToUTF16("********"),
3013 node_data_protected.GetString16Attribute(ui::AX_ATTR_VALUE)); 3008 node_data_protected.GetString16Attribute(ui::AX_ATTR_VALUE));
3014 EXPECT_TRUE(node_data_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); 3009 EXPECT_TRUE(node_data_protected.HasStateFlag(ui::AX_STATE_PROTECTED));
3015 } 3010 }
3016 3011
3017 } // namespace views 3012 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698