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

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

Issue 951433002: MacViews: Handle Tab properly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20150129-MacViews-Bringup5
Patch Set: Still need insertTexT: Created 5 years, 9 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
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 <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 EXPECT_EQ(1, GetFocusedView()->id()); 836 EXPECT_EQ(1, GetFocusedView()->id());
837 837
838 // Test if clicking on textfield view sets the focus. 838 // Test if clicking on textfield view sets the focus.
839 widget_->GetFocusManager()->AdvanceFocus(true); 839 widget_->GetFocusManager()->AdvanceFocus(true);
840 EXPECT_EQ(3, GetFocusedView()->id()); 840 EXPECT_EQ(3, GetFocusedView()->id());
841 ui::MouseEvent click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), 841 ui::MouseEvent click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(),
842 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 842 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
843 ui::EF_LEFT_MOUSE_BUTTON); 843 ui::EF_LEFT_MOUSE_BUTTON);
844 textfield_->OnMousePressed(click); 844 textfield_->OnMousePressed(click);
845 EXPECT_EQ(1, GetFocusedView()->id()); 845 EXPECT_EQ(1, GetFocusedView()->id());
846
847 // Tab/Shift+Tab should also cycle focus, not insert a tab character.
848 SendKeyEvent(ui::VKEY_TAB, false, false);
849 EXPECT_EQ(2, GetFocusedView()->id());
850 SendKeyEvent(ui::VKEY_TAB, false, false);
851 EXPECT_EQ(3, GetFocusedView()->id());
852 // Cycle back to the first textfield.
853 SendKeyEvent(ui::VKEY_TAB, false, false);
854 EXPECT_EQ(1, GetFocusedView()->id());
855
856 SendKeyEvent(ui::VKEY_TAB, true, false);
857 EXPECT_EQ(3, GetFocusedView()->id());
858 SendKeyEvent(ui::VKEY_TAB, true, false);
859 EXPECT_EQ(2, GetFocusedView()->id());
860 SendKeyEvent(ui::VKEY_TAB, true, false);
861 EXPECT_EQ(1, GetFocusedView()->id());
862 // Cycle back to the last textfield.
863 SendKeyEvent(ui::VKEY_TAB, true, false);
864 EXPECT_EQ(3, GetFocusedView()->id());
846 } 865 }
847 866
848 TEST_F(TextfieldTest, ContextMenuDisplayTest) { 867 TEST_F(TextfieldTest, ContextMenuDisplayTest) {
849 InitTextfield(); 868 InitTextfield();
850 EXPECT_TRUE(textfield_->context_menu_controller()); 869 EXPECT_TRUE(textfield_->context_menu_controller());
851 textfield_->SetText(ASCIIToUTF16("hello world")); 870 textfield_->SetText(ASCIIToUTF16("hello world"));
852 ui::Clipboard::GetForCurrentThread()->Clear(ui::CLIPBOARD_TYPE_COPY_PASTE); 871 ui::Clipboard::GetForCurrentThread()->Clear(ui::CLIPBOARD_TYPE_COPY_PASTE);
853 textfield_->ClearEditHistory(); 872 textfield_->ClearEditHistory();
854 EXPECT_TRUE(GetContextMenuModel()); 873 EXPECT_TRUE(GetContextMenuModel());
855 VerifyTextfieldContextMenuContents(false, false, GetContextMenuModel()); 874 VerifyTextfieldContextMenuContents(false, false, GetContextMenuModel());
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 2320
2302 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 2321 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
2303 ui::AXViewState state_protected; 2322 ui::AXViewState state_protected;
2304 textfield_->GetAccessibleState(&state_protected); 2323 textfield_->GetAccessibleState(&state_protected);
2305 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); 2324 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role);
2306 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); 2325 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value);
2307 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); 2326 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED));
2308 } 2327 }
2309 2328
2310 } // namespace views 2329 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698