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

Side by Side Diff: ui/views/focus/focus_manager_unittest.cc

Issue 23475012: Fixes focus traversal bug (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better docs Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/focus/focus_manager.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <utility> 5 #include <utility>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "ui/base/accelerators/accelerator.h" 9 #include "ui/base/accelerators/accelerator.h"
10 #include "ui/base/keycodes/keyboard_codes.h" 10 #include "ui/base/keycodes/keyboard_codes.h"
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 EXPECT_TRUE(GetFocusManager()->RestoreFocusedView()); 822 EXPECT_TRUE(GetFocusManager()->RestoreFocusedView());
823 EXPECT_EQ(&view, GetFocusManager()->GetStoredFocusView()); 823 EXPECT_EQ(&view, GetFocusManager()->GetStoredFocusView());
824 824
825 // Repeat with |true|. 825 // Repeat with |true|.
826 GetFocusManager()->SetFocusedView(&view); 826 GetFocusManager()->SetFocusedView(&view);
827 GetFocusManager()->StoreFocusedView(true); 827 GetFocusManager()->StoreFocusedView(true);
828 EXPECT_TRUE(GetFocusManager()->RestoreFocusedView()); 828 EXPECT_TRUE(GetFocusManager()->RestoreFocusedView());
829 EXPECT_EQ(&view, GetFocusManager()->GetStoredFocusView()); 829 EXPECT_EQ(&view, GetFocusManager()->GetStoredFocusView());
830 } 830 }
831 831
832 // Verifies focus wrapping happens in the same widget.
833 TEST_F(FocusManagerTest, AdvanceFocusStaysInWidget) {
834 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
835 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
836 params.child = true;
837 params.bounds = gfx::Rect(10, 10, 100, 100);
838 params.parent = GetWidget()->GetNativeView();
839 Widget child_widget;
840 child_widget.Init(params);
841
842 View* view1 = new View;
843 view1->set_focusable(true);
844 view1->SetBounds(0, 0, 20, 20);
845 View* view2 = new View;
846 view2->set_focusable(true);
847 view2->SetBounds(20, 0, 20, 20);
848
849 child_widget.client_view()->AddChildView(view1);
850 child_widget.client_view()->AddChildView(view2);
851
852 child_widget.Show();
853
854 // GetFocusManager()->SetFocusedView(view2);
855 view2->RequestFocus();
856 EXPECT_EQ(view2, GetFocusManager()->GetFocusedView());
857 GetFocusManager()->AdvanceFocus(false);
dmazzoni 2013/09/03 16:33:57 Also cycle in the reverse direction for better tes
sky 2013/09/03 16:48:17 Done.
858 EXPECT_EQ(view1, GetFocusManager()->GetFocusedView());
859 }
860
832 } // namespace views 861 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/focus/focus_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698