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

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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 ui::SHOW_STATE_FULLSCREEN); 164 ui::SHOW_STATE_FULLSCREEN);
165 165
166 gfx::Size window_size = widget_->GetWindowBoundsInScreen().size(); 166 gfx::Size window_size = widget_->GetWindowBoundsInScreen().size();
167 content_view_ = new views::NativeViewHost(); 167 content_view_ = new views::NativeViewHost();
168 content_view_->SetBounds(0, 0, window_size.width(), window_size.height()); 168 content_view_->SetBounds(0, 0, window_size.width(), window_size.height());
169 widget_->GetContentsView()->AddChildView(content_view_); 169 widget_->GetContentsView()->AddChildView(content_view_);
170 170
171 top_container_ = new views::View(); 171 top_container_ = new views::View();
172 top_container_->SetBounds( 172 top_container_->SetBounds(
173 0, 0, window_size.width(), 100); 173 0, 0, window_size.width(), 100);
174 top_container_->SetFocusable(true); 174 top_container_->SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
175 widget_->GetContentsView()->AddChildView(top_container_); 175 widget_->GetContentsView()->AddChildView(top_container_);
176 176
177 delegate_.reset( 177 delegate_.reset(
178 new MockImmersiveFullscreenControllerDelegate(top_container_)); 178 new MockImmersiveFullscreenControllerDelegate(top_container_));
179 controller_.reset(new ImmersiveFullscreenController); 179 controller_.reset(new ImmersiveFullscreenController);
180 controller_->Init(delegate_.get(), widget_, top_container_); 180 controller_->Init(delegate_.get(), widget_, top_container_);
181 controller_->SetupForTest(); 181 controller_->SetupForTest();
182 182
183 // The mouse is moved so that it is not over |top_container_| by 183 // The mouse is moved so that it is not over |top_container_| by
184 // AshTestBase. 184 // AshTestBase.
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 // Windows. (crbug.com/79493) 794 // Windows. (crbug.com/79493)
795 #if !defined(OS_WIN) 795 #if !defined(OS_WIN)
796 796
797 // Test how focus and activation affects whether the top-of-window views are 797 // Test how focus and activation affects whether the top-of-window views are
798 // revealed. 798 // revealed.
799 TEST_F(ImmersiveFullscreenControllerTest, Focus) { 799 TEST_F(ImmersiveFullscreenControllerTest, Focus) {
800 // Add views to the view hierarchy which we will focus and unfocus during the 800 // Add views to the view hierarchy which we will focus and unfocus during the
801 // test. 801 // test.
802 views::View* child_view = new views::View(); 802 views::View* child_view = new views::View();
803 child_view->SetBounds(0, 0, 10, 10); 803 child_view->SetBounds(0, 0, 10, 10);
804 child_view->SetFocusable(true); 804 child_view->SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
805 top_container()->AddChildView(child_view); 805 top_container()->AddChildView(child_view);
806 views::View* unrelated_view = new views::View(); 806 views::View* unrelated_view = new views::View();
807 unrelated_view->SetBounds(0, 100, 10, 10); 807 unrelated_view->SetBounds(0, 100, 10, 10);
808 unrelated_view->SetFocusable(true); 808 unrelated_view->SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
809 top_container()->parent()->AddChildView(unrelated_view); 809 top_container()->parent()->AddChildView(unrelated_view);
810 views::FocusManager* focus_manager = 810 views::FocusManager* focus_manager =
811 top_container()->GetWidget()->GetFocusManager(); 811 top_container()->GetWidget()->GetFocusManager();
812 812
813 SetEnabled(true); 813 SetEnabled(true);
814 814
815 // 1) Test that the top-of-window views stay revealed as long as either a 815 // 1) Test that the top-of-window views stay revealed as long as either a
816 // |child_view| has focus or the mouse is hovered above the top-of-window 816 // |child_view| has focus or the mouse is hovered above the top-of-window
817 // views. 817 // views.
818 AttemptReveal(MODALITY_MOUSE); 818 AttemptReveal(MODALITY_MOUSE);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); 1064 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
1065 1065
1066 // Disabling immersive fullscreen maintains the user's auto-hide selection. 1066 // Disabling immersive fullscreen maintains the user's auto-hide selection.
1067 SetEnabled(false); 1067 SetEnabled(false);
1068 window()->SetProperty(aura::client::kShowStateKey, 1068 window()->SetProperty(aura::client::kShowStateKey,
1069 ui::SHOW_STATE_NORMAL); 1069 ui::SHOW_STATE_NORMAL);
1070 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); 1070 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
1071 } 1071 }
1072 1072
1073 } // namespase ash 1073 } // namespase ash
OLDNEW
« no previous file with comments | « ash/system/user/button_from_view.cc ('k') | chrome/browser/apps/guest_view/web_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698