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

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

Issue 2101903002: MacViews: Modify cocoa_test_event_utils::SynthesizeKeyEvent to use the correct event timestamp value (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Correct header order. Created 4 years, 5 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/events/test/cocoa_test_event_utils.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 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 1121
1122 // Ctrl+Left to move the cursor to the beginning of the first word. 1122 // Ctrl+Left to move the cursor to the beginning of the first word.
1123 SendWordEvent(ui::VKEY_LEFT, shift); 1123 SendWordEvent(ui::VKEY_LEFT, shift);
1124 // Ctrl+Left again should move the cursor back to the very beginning. 1124 // Ctrl+Left again should move the cursor back to the very beginning.
1125 SendWordEvent(ui::VKEY_LEFT, shift); 1125 SendWordEvent(ui::VKEY_LEFT, shift);
1126 SendKeyEvent(ui::VKEY_DELETE); 1126 SendKeyEvent(ui::VKEY_DELETE);
1127 EXPECT_STR_EQ("one two", textfield_->text()); 1127 EXPECT_STR_EQ("one two", textfield_->text());
1128 EXPECT_STR_EQ("one two", last_contents_); 1128 EXPECT_STR_EQ("one two", last_contents_);
1129 } 1129 }
1130 1130
1131 // Disabled on Mac (synthesized event bug). http://crbug.com/623420. 1131 TEST_F(TextfieldTest, FocusTraversalTest) {
1132 #if defined(OS_MACOSX)
1133 #define MAYBE_FocusTraversalTest DISABLED_FocusTraversalTest
1134 #else
1135 #define MAYBE_FocusTraversalTest FocusTraversalTest
1136 #endif
1137 TEST_F(TextfieldTest, MAYBE_FocusTraversalTest) {
1138 InitTextfields(3); 1132 InitTextfields(3);
1139 textfield_->RequestFocus(); 1133 textfield_->RequestFocus();
1140 1134
1141 EXPECT_EQ(1, GetFocusedView()->id()); 1135 EXPECT_EQ(1, GetFocusedView()->id());
1142 widget_->GetFocusManager()->AdvanceFocus(false); 1136 widget_->GetFocusManager()->AdvanceFocus(false);
1143 EXPECT_EQ(2, GetFocusedView()->id()); 1137 EXPECT_EQ(2, GetFocusedView()->id());
1144 widget_->GetFocusManager()->AdvanceFocus(false); 1138 widget_->GetFocusManager()->AdvanceFocus(false);
1145 EXPECT_EQ(3, GetFocusedView()->id()); 1139 EXPECT_EQ(3, GetFocusedView()->id());
1146 // Cycle back to the first textfield. 1140 // Cycle back to the first textfield.
1147 widget_->GetFocusManager()->AdvanceFocus(false); 1141 widget_->GetFocusManager()->AdvanceFocus(false);
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 1579
1586 // Text field is unmodifiable and selection shouldn't change. 1580 // Text field is unmodifiable and selection shouldn't change.
1587 SendKeyEvent(ui::VKEY_DELETE); 1581 SendKeyEvent(ui::VKEY_DELETE);
1588 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); 1582 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText());
1589 SendKeyEvent(ui::VKEY_BACK); 1583 SendKeyEvent(ui::VKEY_BACK);
1590 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); 1584 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText());
1591 SendKeyEvent(ui::VKEY_T); 1585 SendKeyEvent(ui::VKEY_T);
1592 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); 1586 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText());
1593 } 1587 }
1594 1588
1595 // Disabled on Mac (synthesized event bug). http://crbug.com/623420. 1589 TEST_F(TextfieldTest, TextInputClientTest) {
1596 #if defined(OS_MACOSX)
1597 #define MAYBE_TextInputClientTest DISABLED_TextInputClientTest
1598 #else
1599 #define MAYBE_TextInputClientTest TextInputClientTest
1600 #endif
1601 TEST_F(TextfieldTest, MAYBE_TextInputClientTest) {
1602 InitTextfield(); 1590 InitTextfield();
1603 ui::TextInputClient* client = textfield_; 1591 ui::TextInputClient* client = textfield_;
1604 EXPECT_TRUE(client); 1592 EXPECT_TRUE(client);
1605 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, client->GetTextInputType()); 1593 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, client->GetTextInputType());
1606 1594
1607 textfield_->SetText(ASCIIToUTF16("0123456789")); 1595 textfield_->SetText(ASCIIToUTF16("0123456789"));
1608 gfx::Range range; 1596 gfx::Range range;
1609 EXPECT_TRUE(client->GetTextRange(&range)); 1597 EXPECT_TRUE(client->GetTextRange(&range));
1610 EXPECT_EQ(0U, range.start()); 1598 EXPECT_EQ(0U, range.start());
1611 EXPECT_EQ(10U, range.end()); 1599 EXPECT_EQ(10U, range.end());
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
2495 // the default font. 2483 // the default font.
2496 textfield_->SetText(UTF8ToUTF16("\xE0\xB9\x91")); 2484 textfield_->SetText(UTF8ToUTF16("\xE0\xB9\x91"));
2497 const int new_baseline = textfield_->GetBaseline(); 2485 const int new_baseline = textfield_->GetBaseline();
2498 2486
2499 // Regardless of the text, the baseline must be the same. 2487 // Regardless of the text, the baseline must be the same.
2500 EXPECT_EQ(new_baseline, old_baseline); 2488 EXPECT_EQ(new_baseline, old_baseline);
2501 } 2489 }
2502 2490
2503 // Tests that a textfield view can be destroyed from OnKeyEvent() on its 2491 // Tests that a textfield view can be destroyed from OnKeyEvent() on its
2504 // controller and it does not crash. 2492 // controller and it does not crash.
2505 // Disabled on Mac (synthesized event bug). http://crbug.com/623420. 2493 TEST_F(TextfieldTest, DestroyingTextfieldFromOnKeyEvent) {
2506 #if defined(OS_MACOSX)
2507 #define MAYBE_DestroyingTextfieldFromOnKeyEvent \
2508 DISABLED_DestroyingTextfieldFromOnKeyEvent
2509 #else
2510 #define MAYBE_DestroyingTextfieldFromOnKeyEvent \
2511 DestroyingTextfieldFromOnKeyEvent
2512 #endif
2513 TEST_F(TextfieldTest, MAYBE_DestroyingTextfieldFromOnKeyEvent) {
2514 InitTextfield(); 2494 InitTextfield();
2515 2495
2516 // The controller assumes ownership of the textfield. 2496 // The controller assumes ownership of the textfield.
2517 TextfieldDestroyerController controller(textfield_); 2497 TextfieldDestroyerController controller(textfield_);
2518 EXPECT_TRUE(controller.target()); 2498 EXPECT_TRUE(controller.target());
2519 2499
2520 // Send a key to trigger OnKeyEvent(). 2500 // Send a key to trigger OnKeyEvent().
2521 SendKeyEvent(ui::VKEY_RETURN); 2501 SendKeyEvent(ui::VKEY_RETURN);
2522 2502
2523 EXPECT_FALSE(controller.target()); 2503 EXPECT_FALSE(controller.target());
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2678 2658
2679 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 2659 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
2680 ui::AXViewState state_protected; 2660 ui::AXViewState state_protected;
2681 textfield_->GetAccessibleState(&state_protected); 2661 textfield_->GetAccessibleState(&state_protected);
2682 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); 2662 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role);
2683 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); 2663 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value);
2684 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); 2664 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED));
2685 } 2665 }
2686 2666
2687 } // namespace views 2667 } // namespace views
OLDNEW
« no previous file with comments | « ui/events/test/cocoa_test_event_utils.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698