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

Side by Side Diff: ash/wm/immersive_fullscreen_controller_unittest.cc

Issue 1898633004: Views: Add new SetFocusBehavior method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/wm/immersive_fullscreen_controller.h" 5 #include "ash/wm/immersive_fullscreen_controller.h"
6 6
7 #include "ash/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/display/mouse_cursor_event_filter.h" 8 #include "ash/display/mouse_cursor_event_filter.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ui::SHOW_STATE_FULLSCREEN); 154 ui::SHOW_STATE_FULLSCREEN);
155 155
156 gfx::Size window_size = widget_->GetWindowBoundsInScreen().size(); 156 gfx::Size window_size = widget_->GetWindowBoundsInScreen().size();
157 content_view_ = new views::NativeViewHost(); 157 content_view_ = new views::NativeViewHost();
158 content_view_->SetBounds(0, 0, window_size.width(), window_size.height()); 158 content_view_->SetBounds(0, 0, window_size.width(), window_size.height());
159 widget_->GetContentsView()->AddChildView(content_view_); 159 widget_->GetContentsView()->AddChildView(content_view_);
160 160
161 top_container_ = new views::View(); 161 top_container_ = new views::View();
162 top_container_->SetBounds( 162 top_container_->SetBounds(
163 0, 0, window_size.width(), 100); 163 0, 0, window_size.width(), 100);
164 top_container_->SetFocusable(true); 164 top_container_->SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
165 widget_->GetContentsView()->AddChildView(top_container_); 165 widget_->GetContentsView()->AddChildView(top_container_);
166 166
167 delegate_.reset( 167 delegate_.reset(
168 new MockImmersiveFullscreenControllerDelegate(top_container_)); 168 new MockImmersiveFullscreenControllerDelegate(top_container_));
169 controller_.reset(new ImmersiveFullscreenController); 169 controller_.reset(new ImmersiveFullscreenController);
170 controller_->Init(delegate_.get(), widget_, top_container_); 170 controller_->Init(delegate_.get(), widget_, top_container_);
171 controller_->SetupForTest(); 171 controller_->SetupForTest();
172 172
173 // The mouse is moved so that it is not over |top_container_| by 173 // The mouse is moved so that it is not over |top_container_| by
174 // AshTestBase. 174 // AshTestBase.
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 // Windows. (crbug.com/79493) 784 // Windows. (crbug.com/79493)
785 #if !defined(OS_WIN) 785 #if !defined(OS_WIN)
786 786
787 // Test how focus and activation affects whether the top-of-window views are 787 // Test how focus and activation affects whether the top-of-window views are
788 // revealed. 788 // revealed.
789 TEST_F(ImmersiveFullscreenControllerTest, Focus) { 789 TEST_F(ImmersiveFullscreenControllerTest, Focus) {
790 // Add views to the view hierarchy which we will focus and unfocus during the 790 // Add views to the view hierarchy which we will focus and unfocus during the
791 // test. 791 // test.
792 views::View* child_view = new views::View(); 792 views::View* child_view = new views::View();
793 child_view->SetBounds(0, 0, 10, 10); 793 child_view->SetBounds(0, 0, 10, 10);
794 child_view->SetFocusable(true); 794 child_view->SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
795 top_container()->AddChildView(child_view); 795 top_container()->AddChildView(child_view);
796 views::View* unrelated_view = new views::View(); 796 views::View* unrelated_view = new views::View();
797 unrelated_view->SetBounds(0, 100, 10, 10); 797 unrelated_view->SetBounds(0, 100, 10, 10);
798 unrelated_view->SetFocusable(true); 798 unrelated_view->SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
799 top_container()->parent()->AddChildView(unrelated_view); 799 top_container()->parent()->AddChildView(unrelated_view);
800 views::FocusManager* focus_manager = 800 views::FocusManager* focus_manager =
801 top_container()->GetWidget()->GetFocusManager(); 801 top_container()->GetWidget()->GetFocusManager();
802 802
803 SetEnabled(true); 803 SetEnabled(true);
804 804
805 // 1) Test that the top-of-window views stay revealed as long as either a 805 // 1) Test that the top-of-window views stay revealed as long as either a
806 // |child_view| has focus or the mouse is hovered above the top-of-window 806 // |child_view| has focus or the mouse is hovered above the top-of-window
807 // views. 807 // views.
808 AttemptReveal(MODALITY_MOUSE); 808 AttemptReveal(MODALITY_MOUSE);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); 1054 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
1055 1055
1056 // Disabling immersive fullscreen maintains the user's auto-hide selection. 1056 // Disabling immersive fullscreen maintains the user's auto-hide selection.
1057 SetEnabled(false); 1057 SetEnabled(false);
1058 window()->SetProperty(aura::client::kShowStateKey, 1058 window()->SetProperty(aura::client::kShowStateKey,
1059 ui::SHOW_STATE_NORMAL); 1059 ui::SHOW_STATE_NORMAL);
1060 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); 1060 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
1061 } 1061 }
1062 1062
1063 } // namespase ash 1063 } // namespase ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698