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

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

Issue 1925943002: Add views_unittests to Mac10.{9,9(dbg),10,11} and asan bots (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yipe - cater for r401862 and r401987 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/views/controls/styled_label_unittest.cc ('k') | ui/views/widget/widget_unittest.cc » ('j') | 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 TEST_F(TextfieldTest, FocusTraversalTest) { 1131 // Disabled on Mac (synthesized event bug). http://crbug.com/623420.
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) {
1132 InitTextfields(3); 1138 InitTextfields(3);
1133 textfield_->RequestFocus(); 1139 textfield_->RequestFocus();
1134 1140
1135 EXPECT_EQ(1, GetFocusedView()->id()); 1141 EXPECT_EQ(1, GetFocusedView()->id());
1136 widget_->GetFocusManager()->AdvanceFocus(false); 1142 widget_->GetFocusManager()->AdvanceFocus(false);
1137 EXPECT_EQ(2, GetFocusedView()->id()); 1143 EXPECT_EQ(2, GetFocusedView()->id());
1138 widget_->GetFocusManager()->AdvanceFocus(false); 1144 widget_->GetFocusManager()->AdvanceFocus(false);
1139 EXPECT_EQ(3, GetFocusedView()->id()); 1145 EXPECT_EQ(3, GetFocusedView()->id());
1140 // Cycle back to the first textfield. 1146 // Cycle back to the first textfield.
1141 widget_->GetFocusManager()->AdvanceFocus(false); 1147 widget_->GetFocusManager()->AdvanceFocus(false);
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 1585
1580 // Text field is unmodifiable and selection shouldn't change. 1586 // Text field is unmodifiable and selection shouldn't change.
1581 SendKeyEvent(ui::VKEY_DELETE); 1587 SendKeyEvent(ui::VKEY_DELETE);
1582 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); 1588 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText());
1583 SendKeyEvent(ui::VKEY_BACK); 1589 SendKeyEvent(ui::VKEY_BACK);
1584 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); 1590 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText());
1585 SendKeyEvent(ui::VKEY_T); 1591 SendKeyEvent(ui::VKEY_T);
1586 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); 1592 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText());
1587 } 1593 }
1588 1594
1589 TEST_F(TextfieldTest, TextInputClientTest) { 1595 // Disabled on Mac (synthesized event bug). http://crbug.com/623420.
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) {
1590 InitTextfield(); 1602 InitTextfield();
1591 ui::TextInputClient* client = textfield_; 1603 ui::TextInputClient* client = textfield_;
1592 EXPECT_TRUE(client); 1604 EXPECT_TRUE(client);
1593 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, client->GetTextInputType()); 1605 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, client->GetTextInputType());
1594 1606
1595 textfield_->SetText(ASCIIToUTF16("0123456789")); 1607 textfield_->SetText(ASCIIToUTF16("0123456789"));
1596 gfx::Range range; 1608 gfx::Range range;
1597 EXPECT_TRUE(client->GetTextRange(&range)); 1609 EXPECT_TRUE(client->GetTextRange(&range));
1598 EXPECT_EQ(0U, range.start()); 1610 EXPECT_EQ(0U, range.start());
1599 EXPECT_EQ(10U, range.end()); 1611 EXPECT_EQ(10U, range.end());
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 // the default font. 2495 // the default font.
2484 textfield_->SetText(UTF8ToUTF16("\xE0\xB9\x91")); 2496 textfield_->SetText(UTF8ToUTF16("\xE0\xB9\x91"));
2485 const int new_baseline = textfield_->GetBaseline(); 2497 const int new_baseline = textfield_->GetBaseline();
2486 2498
2487 // Regardless of the text, the baseline must be the same. 2499 // Regardless of the text, the baseline must be the same.
2488 EXPECT_EQ(new_baseline, old_baseline); 2500 EXPECT_EQ(new_baseline, old_baseline);
2489 } 2501 }
2490 2502
2491 // Tests that a textfield view can be destroyed from OnKeyEvent() on its 2503 // Tests that a textfield view can be destroyed from OnKeyEvent() on its
2492 // controller and it does not crash. 2504 // controller and it does not crash.
2493 TEST_F(TextfieldTest, DestroyingTextfieldFromOnKeyEvent) { 2505 // Disabled on Mac (synthesized event bug). http://crbug.com/623420.
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) {
2494 InitTextfield(); 2514 InitTextfield();
2495 2515
2496 // The controller assumes ownership of the textfield. 2516 // The controller assumes ownership of the textfield.
2497 TextfieldDestroyerController controller(textfield_); 2517 TextfieldDestroyerController controller(textfield_);
2498 EXPECT_TRUE(controller.target()); 2518 EXPECT_TRUE(controller.target());
2499 2519
2500 // Send a key to trigger OnKeyEvent(). 2520 // Send a key to trigger OnKeyEvent().
2501 SendKeyEvent(ui::VKEY_RETURN); 2521 SendKeyEvent(ui::VKEY_RETURN);
2502 2522
2503 EXPECT_FALSE(controller.target()); 2523 EXPECT_FALSE(controller.target());
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 2678
2659 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 2679 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
2660 ui::AXViewState state_protected; 2680 ui::AXViewState state_protected;
2661 textfield_->GetAccessibleState(&state_protected); 2681 textfield_->GetAccessibleState(&state_protected);
2662 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); 2682 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role);
2663 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); 2683 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value);
2664 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); 2684 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED));
2665 } 2685 }
2666 2686
2667 } // namespace views 2687 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/styled_label_unittest.cc ('k') | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698