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

Side by Side Diff: ui/views/corewm/focus_controller_unittest.cc

Issue 11414304: Fleshes out the basic set of focus rules a bit more. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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/corewm/base_focus_rules.cc ('k') | ui/views/corewm/window_modality_controller.h » ('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/corewm/focus_controller.h" 5 #include "ui/views/corewm/focus_controller.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "ui/aura/client/activation_client.h" 9 #include "ui/aura/client/activation_client.h"
10 #include "ui/aura/root_window.h" 10 #include "ui/aura/root_window.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 class TestFocusRules : public BaseFocusRules { 78 class TestFocusRules : public BaseFocusRules {
79 public: 79 public:
80 TestFocusRules() : focus_restriction_(NULL) {} 80 TestFocusRules() : focus_restriction_(NULL) {}
81 81
82 // Restricts focus and activation to this window and its child hierarchy. 82 // Restricts focus and activation to this window and its child hierarchy.
83 void set_focus_restriction(aura::Window* focus_restriction) { 83 void set_focus_restriction(aura::Window* focus_restriction) {
84 focus_restriction_ = focus_restriction; 84 focus_restriction_ = focus_restriction;
85 } 85 }
86 86
87 // Overridden from BaseFocusRules: 87 // Overridden from BaseFocusRules:
88 virtual bool SupportsChildActivation(aura::Window* window) OVERRIDE {
89 // In FocusControllerTests, only the RootWindow has activatable children.
90 return window->GetRootWindow() == window;
91 }
88 virtual bool CanActivateWindow(aura::Window* window) OVERRIDE { 92 virtual bool CanActivateWindow(aura::Window* window) OVERRIDE {
89 // Restricting focus to a non-activatable child window means the activatable 93 // Restricting focus to a non-activatable child window means the activatable
90 // parent outside the focus restriction is activatable. 94 // parent outside the focus restriction is activatable.
91 bool can_activate = CanFocusOrActivate(window) || 95 bool can_activate =
92 window->Contains(GetActivatableWindow(focus_restriction_)); 96 CanFocusOrActivate(window) || window->Contains(focus_restriction_);
93 return can_activate ? BaseFocusRules::CanActivateWindow(window) : false; 97 return can_activate ? BaseFocusRules::CanActivateWindow(window) : false;
94 } 98 }
95 virtual bool CanFocusWindow(aura::Window* window) OVERRIDE { 99 virtual bool CanFocusWindow(aura::Window* window) OVERRIDE {
96 return CanFocusOrActivate(window) ? 100 return CanFocusOrActivate(window) ?
97 BaseFocusRules::CanFocusWindow(window) : false; 101 BaseFocusRules::CanFocusWindow(window) : false;
98 } 102 }
99 virtual aura::Window* GetActivatableWindow(aura::Window* window) OVERRIDE { 103 virtual aura::Window* GetActivatableWindow(aura::Window* window) OVERRIDE {
100 return BaseFocusRules::GetActivatableWindow( 104 return BaseFocusRules::GetActivatableWindow(
101 CanFocusOrActivate(window) ? window : focus_restriction_); 105 CanFocusOrActivate(window) ? window : focus_restriction_);
102 } 106 }
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusToChildOfInactiveWindow); 736 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusToChildOfInactiveWindow);
733 737
734 // - Verifies that FocusRules determine what can be focused. 738 // - Verifies that FocusRules determine what can be focused.
735 ALL_FOCUS_TESTS(FocusRulesOverride); 739 ALL_FOCUS_TESTS(FocusRulesOverride);
736 740
737 // - Verifies that FocusRules determine what can be activated. 741 // - Verifies that FocusRules determine what can be activated.
738 TARGET_FOCUS_TESTS(ActivationRulesOverride); 742 TARGET_FOCUS_TESTS(ActivationRulesOverride);
739 743
740 } // namespace corewm 744 } // namespace corewm
741 } // namespace views 745 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/corewm/base_focus_rules.cc ('k') | ui/views/corewm/window_modality_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698