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

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

Issue 103493005: Rename View::set_focusable and View::set_accessibility_focusable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a few missing files Created 7 years 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_unittest_win.cc ('k') | ui/views/touchui/touch_editing_menu.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 (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 "ui/views/focus/focus_manager.h" 5 #include "ui/views/focus/focus_manager.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "ui/base/models/combobox_model.h" 10 #include "ui/base/models/combobox_model.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 FocusSearch* focus_search_; 129 FocusSearch* focus_search_;
130 }; 130 };
131 131
132 // BorderView is a view containing a native window with its own view hierarchy. 132 // BorderView is a view containing a native window with its own view hierarchy.
133 // It is interesting to test focus traversal from a view hierarchy to an inner 133 // It is interesting to test focus traversal from a view hierarchy to an inner
134 // view hierarchy. 134 // view hierarchy.
135 class BorderView : public NativeViewHost { 135 class BorderView : public NativeViewHost {
136 public: 136 public:
137 explicit BorderView(View* child) : child_(child), widget_(NULL) { 137 explicit BorderView(View* child) : child_(child), widget_(NULL) {
138 DCHECK(child); 138 DCHECK(child);
139 set_focusable(false); 139 SetFocusable(false);
140 } 140 }
141 141
142 virtual ~BorderView() {} 142 virtual ~BorderView() {}
143 143
144 virtual internal::RootView* GetContentsRootView() { 144 virtual internal::RootView* GetContentsRootView() {
145 return static_cast<internal::RootView*>(widget_->GetRootView()); 145 return static_cast<internal::RootView*>(widget_->GetRootView());
146 } 146 }
147 147
148 virtual FocusTraversable* GetFocusTraversable() OVERRIDE { 148 virtual FocusTraversable* GetFocusTraversable() OVERRIDE {
149 return static_cast<internal::RootView*>(widget_->GetRootView()); 149 return static_cast<internal::RootView*>(widget_->GetRootView());
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 538
539 search_border_view_ = new BorderView(contents); 539 search_border_view_ = new BorderView(contents);
540 search_border_view_->set_id(kSearchContainerID); 540 search_border_view_->set_id(kSearchContainerID);
541 541
542 GetContentsView()->AddChildView(search_border_view_); 542 GetContentsView()->AddChildView(search_border_view_);
543 search_border_view_->SetBounds(300, y, 240, 50); 543 search_border_view_->SetBounds(300, y, 240, 50);
544 544
545 y += 60; 545 y += 60;
546 546
547 contents = new View(); 547 contents = new View();
548 contents->set_focusable(true); 548 contents->SetFocusable(true);
549 contents->set_background(Background::CreateSolidBackground(SK_ColorBLUE)); 549 contents->set_background(Background::CreateSolidBackground(SK_ColorBLUE));
550 contents->set_id(kThumbnailContainerID); 550 contents->set_id(kThumbnailContainerID);
551 button = new LabelButton(NULL, ASCIIToUTF16("Star")); 551 button = new LabelButton(NULL, ASCIIToUTF16("Star"));
552 button->SetStyle(Button::STYLE_NATIVE_TEXTBUTTON); 552 button->SetStyle(Button::STYLE_NATIVE_TEXTBUTTON);
553 contents->AddChildView(button); 553 contents->AddChildView(button);
554 button->SetBounds(5, 5, 50, 30); 554 button->SetBounds(5, 5, 50, 30);
555 button->set_id(kThumbnailStarID); 555 button->set_id(kThumbnailStarID);
556 button = new LabelButton(NULL, ASCIIToUTF16("SuperStar")); 556 button = new LabelButton(NULL, ASCIIToUTF16("SuperStar"));
557 button->SetStyle(Button::STYLE_NATIVE_TEXTBUTTON); 557 button->SetStyle(Button::STYLE_NATIVE_TEXTBUTTON);
558 contents->AddChildView(button); 558 contents->AddChildView(button);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 // Now test the right container, but this time with accessibility mode. 751 // Now test the right container, but this time with accessibility mode.
752 // Make some links not focusable, but mark one of them as 752 // Make some links not focusable, but mark one of them as
753 // "accessibility focusable", so it should show up in the traversal. 753 // "accessibility focusable", so it should show up in the traversal.
754 const int kRightTraversalIDs[] = { 754 const int kRightTraversalIDs[] = {
755 kBroccoliButtonID, kDinerGameLinkID, kRidiculeLinkID, 755 kBroccoliButtonID, kDinerGameLinkID, kRidiculeLinkID,
756 kClosetLinkID, kVisitingLinkID, kAmelieLinkID, kJoyeuxNoelLinkID, 756 kClosetLinkID, kVisitingLinkID, kAmelieLinkID, kJoyeuxNoelLinkID,
757 kCampingLinkID, kBriceDeNiceLinkID, kTaxiLinkID, kAsterixLinkID }; 757 kCampingLinkID, kBriceDeNiceLinkID, kTaxiLinkID, kAsterixLinkID };
758 758
759 FocusSearch focus_search_right(right_container_, true, true); 759 FocusSearch focus_search_right(right_container_, true, true);
760 right_container_->EnablePaneFocus(&focus_search_right); 760 right_container_->EnablePaneFocus(&focus_search_right);
761 FindViewByID(kRosettaLinkID)->set_focusable(false); 761 FindViewByID(kRosettaLinkID)->SetFocusable(false);
762 FindViewByID(kStupeurEtTremblementLinkID)->set_focusable(false); 762 FindViewByID(kStupeurEtTremblementLinkID)->SetFocusable(false);
763 FindViewByID(kDinerGameLinkID)->set_accessibility_focusable(true); 763 FindViewByID(kDinerGameLinkID)->SetAccessibilityFocusable(true);
764 FindViewByID(kDinerGameLinkID)->set_focusable(false); 764 FindViewByID(kDinerGameLinkID)->SetFocusable(false);
765 FindViewByID(kAsterixLinkID)->RequestFocus(); 765 FindViewByID(kAsterixLinkID)->RequestFocus();
766 766
767 // Traverse the focus hierarchy within the pane several times. 767 // Traverse the focus hierarchy within the pane several times.
768 for (int i = 0; i < 3; ++i) { 768 for (int i = 0; i < 3; ++i) {
769 for (size_t j = 0; j < arraysize(kRightTraversalIDs); j++) { 769 for (size_t j = 0; j < arraysize(kRightTraversalIDs); j++) {
770 GetFocusManager()->AdvanceFocus(false); 770 GetFocusManager()->AdvanceFocus(false);
771 View* focused_view = GetFocusManager()->GetFocusedView(); 771 View* focused_view = GetFocusManager()->GetFocusedView();
772 EXPECT_TRUE(focused_view != NULL); 772 EXPECT_TRUE(focused_view != NULL);
773 if (focused_view) 773 if (focused_view)
774 EXPECT_EQ(kRightTraversalIDs[j], focused_view->id()); 774 EXPECT_EQ(kRightTraversalIDs[j], focused_view->id());
775 } 775 }
776 } 776 }
777 777
778 // Traverse in reverse order. 778 // Traverse in reverse order.
779 FindViewByID(kBroccoliButtonID)->RequestFocus(); 779 FindViewByID(kBroccoliButtonID)->RequestFocus();
780 for (int i = 0; i < 3; ++i) { 780 for (int i = 0; i < 3; ++i) {
781 for (int j = arraysize(kRightTraversalIDs) - 1; j >= 0; --j) { 781 for (int j = arraysize(kRightTraversalIDs) - 1; j >= 0; --j) {
782 GetFocusManager()->AdvanceFocus(true); 782 GetFocusManager()->AdvanceFocus(true);
783 View* focused_view = GetFocusManager()->GetFocusedView(); 783 View* focused_view = GetFocusManager()->GetFocusedView();
784 EXPECT_TRUE(focused_view != NULL); 784 EXPECT_TRUE(focused_view != NULL);
785 if (focused_view) 785 if (focused_view)
786 EXPECT_EQ(kRightTraversalIDs[j], focused_view->id()); 786 EXPECT_EQ(kRightTraversalIDs[j], focused_view->id());
787 } 787 }
788 } 788 }
789 } 789 }
790 790
791 } // namespace views 791 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/focus/focus_manager_unittest_win.cc ('k') | ui/views/touchui/touch_editing_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698