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

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

Issue 108063004: Give up focus if the focused view becomes unfocusable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Extracted to common code into FocusManager class 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
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/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 params.context = CurrentContext(); 124 params.context = CurrentContext();
125 widget_->Init(params); 125 widget_->Init(params);
126 widget_->Show(); 126 widget_->Show();
127 127
128 window()->SetProperty(aura::client::kShowStateKey, 128 window()->SetProperty(aura::client::kShowStateKey,
129 ui::SHOW_STATE_FULLSCREEN); 129 ui::SHOW_STATE_FULLSCREEN);
130 130
131 top_container_ = new views::View(); 131 top_container_ = new views::View();
132 top_container_->SetBounds( 132 top_container_->SetBounds(
133 0, 0, widget_->GetWindowBoundsInScreen().width(), 100); 133 0, 0, widget_->GetWindowBoundsInScreen().width(), 100);
134 top_container_->set_focusable(true); 134 top_container_->SetFocusable(true);
135 widget_->GetContentsView()->AddChildView(top_container_); 135 widget_->GetContentsView()->AddChildView(top_container_);
136 136
137 delegate_.reset( 137 delegate_.reset(
138 new MockImmersiveFullscreenControllerDelegate(top_container_)); 138 new MockImmersiveFullscreenControllerDelegate(top_container_));
139 controller_.reset(new ImmersiveFullscreenController); 139 controller_.reset(new ImmersiveFullscreenController);
140 controller_->Init(delegate_.get(), widget_, top_container_); 140 controller_->Init(delegate_.get(), widget_, top_container_);
141 controller_->SetupForTest(); 141 controller_->SetupForTest();
142 142
143 // The mouse is moved so that it is not over |top_container_| by 143 // The mouse is moved so that it is not over |top_container_| by
144 // AshTestBase. 144 // AshTestBase.
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 // Windows. (crbug.com/79493) 671 // Windows. (crbug.com/79493)
672 #if !defined(OS_WIN) 672 #if !defined(OS_WIN)
673 673
674 // Test how focus and activation affects whether the top-of-window views are 674 // Test how focus and activation affects whether the top-of-window views are
675 // revealed. 675 // revealed.
676 TEST_F(ImmersiveFullscreenControllerTest, Focus) { 676 TEST_F(ImmersiveFullscreenControllerTest, Focus) {
677 // Add views to the view hierarchy which we will focus and unfocus during the 677 // Add views to the view hierarchy which we will focus and unfocus during the
678 // test. 678 // test.
679 views::View* child_view = new views::View(); 679 views::View* child_view = new views::View();
680 child_view->SetBounds(0, 0, 10, 10); 680 child_view->SetBounds(0, 0, 10, 10);
681 child_view->set_focusable(true); 681 child_view->SetFocusable(true);
682 top_container()->AddChildView(child_view); 682 top_container()->AddChildView(child_view);
683 views::View* unrelated_view = new views::View(); 683 views::View* unrelated_view = new views::View();
684 unrelated_view->SetBounds(0, 100, 10, 10); 684 unrelated_view->SetBounds(0, 100, 10, 10);
685 unrelated_view->set_focusable(true); 685 unrelated_view->SetFocusable(true);
686 top_container()->parent()->AddChildView(unrelated_view); 686 top_container()->parent()->AddChildView(unrelated_view);
687 views::FocusManager* focus_manager = 687 views::FocusManager* focus_manager =
688 top_container()->GetWidget()->GetFocusManager(); 688 top_container()->GetWidget()->GetFocusManager();
689 689
690 controller()->SetEnabled(true); 690 controller()->SetEnabled(true);
691 691
692 // 1) Test that the top-of-window views stay revealed as long as either a 692 // 1) Test that the top-of-window views stay revealed as long as either a
693 // |child_view| has focus or the mouse is hovered above the top-of-window 693 // |child_view| has focus or the mouse is hovered above the top-of-window
694 // views. 694 // views.
695 AttemptReveal(MODALITY_MOUSE); 695 AttemptReveal(MODALITY_MOUSE);
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 // Disabling immersive fullscreen maintains the user's auto-hide selection. 943 // Disabling immersive fullscreen maintains the user's auto-hide selection.
944 controller()->SetEnabled(false); 944 controller()->SetEnabled(false);
945 window()->SetProperty(aura::client::kShowStateKey, 945 window()->SetProperty(aura::client::kShowStateKey,
946 ui::SHOW_STATE_NORMAL); 946 ui::SHOW_STATE_NORMAL);
947 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); 947 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
948 } 948 }
949 949
950 } // namespase ash 950 } // namespase ash
951 951
952 #endif // defined(OS_CHROMEOS) 952 #endif // defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698