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

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

Issue 2829823002: [Textfield] Consider select all status for select all context menu (Closed)
Patch Set: Cleanup test code Created 3 years, 8 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/textfield/textfield.cc ('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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 642 ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(),
643 ui::EventTimeForNow(), 643 ui::EventTimeForNow(),
644 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_IS_NON_CLIENT, 644 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_IS_NON_CLIENT,
645 ui::EF_LEFT_MOUSE_BUTTON); 645 ui::EF_LEFT_MOUSE_BUTTON);
646 textfield_->OnMouseReleased(release); 646 textfield_->OnMouseReleased(release);
647 } 647 }
648 648
649 void VerifyTextfieldContextMenuContents(bool textfield_has_selection, 649 void VerifyTextfieldContextMenuContents(bool textfield_has_selection,
650 bool can_undo, 650 bool can_undo,
651 ui::MenuModel* menu) { 651 ui::MenuModel* menu) {
652 const auto& text = textfield_->text();
653 const bool is_all_selected = !text.empty() &&
654 textfield_->GetSelectedRange().length() == text.length();
655
652 EXPECT_EQ(can_undo, menu->IsEnabledAt(0 /* UNDO */)); 656 EXPECT_EQ(can_undo, menu->IsEnabledAt(0 /* UNDO */));
653 EXPECT_TRUE(menu->IsEnabledAt(1 /* Separator */)); 657 EXPECT_TRUE(menu->IsEnabledAt(1 /* Separator */));
654 EXPECT_EQ(textfield_has_selection, menu->IsEnabledAt(2 /* CUT */)); 658 EXPECT_EQ(textfield_has_selection, menu->IsEnabledAt(2 /* CUT */));
655 EXPECT_EQ(textfield_has_selection, menu->IsEnabledAt(3 /* COPY */)); 659 EXPECT_EQ(textfield_has_selection, menu->IsEnabledAt(3 /* COPY */));
656 EXPECT_NE(GetClipboardText(ui::CLIPBOARD_TYPE_COPY_PASTE).empty(), 660 EXPECT_NE(GetClipboardText(ui::CLIPBOARD_TYPE_COPY_PASTE).empty(),
657 menu->IsEnabledAt(4 /* PASTE */)); 661 menu->IsEnabledAt(4 /* PASTE */));
658 EXPECT_EQ(textfield_has_selection, menu->IsEnabledAt(5 /* DELETE */)); 662 EXPECT_EQ(textfield_has_selection, menu->IsEnabledAt(5 /* DELETE */));
659 EXPECT_TRUE(menu->IsEnabledAt(6 /* Separator */)); 663 EXPECT_TRUE(menu->IsEnabledAt(6 /* Separator */));
660 EXPECT_TRUE(menu->IsEnabledAt(7 /* SELECT ALL */)); 664 EXPECT_EQ(!is_all_selected, menu->IsEnabledAt(7 /* SELECT ALL */));
661 } 665 }
662 666
663 void PressMouseButton(ui::EventFlags mouse_button_flags, int extra_flags) { 667 void PressMouseButton(ui::EventFlags mouse_button_flags, int extra_flags) {
664 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, mouse_position_, mouse_position_, 668 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, mouse_position_, mouse_position_,
665 ui::EventTimeForNow(), mouse_button_flags, 669 ui::EventTimeForNow(), mouse_button_flags,
666 mouse_button_flags | extra_flags); 670 mouse_button_flags | extra_flags);
667 textfield_->OnMousePressed(press); 671 textfield_->OnMousePressed(press);
668 } 672 }
669 673
670 void ReleaseMouseButton(ui::EventFlags mouse_button_flags) { 674 void ReleaseMouseButton(ui::EventFlags mouse_button_flags) {
(...skipping 2446 matching lines...) Expand 10 before | Expand all | Expand 10 after
3117 InitTextfield(); 3121 InitTextfield();
3118 3122
3119 textfield_->SetCursorEnabled(false); 3123 textfield_->SetCursorEnabled(false);
3120 EXPECT_FALSE(test_api_->IsCursorVisible()); 3124 EXPECT_FALSE(test_api_->IsCursorVisible());
3121 3125
3122 textfield_->SetCursorEnabled(true); 3126 textfield_->SetCursorEnabled(true);
3123 EXPECT_TRUE(test_api_->IsCursorVisible()); 3127 EXPECT_TRUE(test_api_->IsCursorVisible());
3124 } 3128 }
3125 3129
3126 } // namespace views 3130 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698