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

Unified Diff: chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc

Issue 27458002: Allow setting different hit test bounds overrides for mouse and touch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc
diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc b/chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc
index f24f95d724b01a36cb569ee320212d1b0e22f1c1..991b3fc55ef74a1551e0e4f779169c353d6ef551 100644
--- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc
+++ b/chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h"
#include "ash/display/display_manager.h"
+#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "chrome/app/chrome_command_ids.h"
@@ -17,11 +18,13 @@
#include "chrome/browser/ui/views/frame/top_container_view.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/browser/ui/views/toolbar_view.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/window.h"
+#include "ui/base/ui_base_types.h"
#include "ui/gfx/animation/slide_animation.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/webview/webview.h"
@@ -48,9 +51,6 @@ class MockImmersiveModeControllerDelegate
virtual void SetImmersiveStyle(bool immersive) OVERRIDE {
immersive_style_ = immersive;
}
- virtual content::WebContents* GetWebContents() OVERRIDE {
- return NULL;
- }
private:
bool immersive_style_;
@@ -58,6 +58,21 @@ class MockImmersiveModeControllerDelegate
DISALLOW_COPY_AND_ASSIGN(MockImmersiveModeControllerDelegate);
};
+// View which consumes all touch events.
+class TouchEventConsumerView : public views::View {
+ public:
+ TouchEventConsumerView() {
+ }
+ virtual ~TouchEventConsumerView() {
+ }
+
+ virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE {
+ event->SetHandled();
+ }
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TouchEventConsumerView);
+};
+
/////////////////////////////////////////////////////////////////////////////
class ImmersiveModeControllerAshTest : public ash::test::AshTestBase {
@@ -96,14 +111,16 @@ class ImmersiveModeControllerAshTest : public ash::test::AshTestBase {
widget_ = new views::Widget();
views::Widget::InitParams params;
params.context = CurrentContext();
- params.bounds = gfx::Rect(0, 0, 500, 500);
widget_->Init(params);
widget_->Show();
+ widget_->GetNativeWindow()->SetProperty(aura::client::kShowStateKey,
+ ui::SHOW_STATE_FULLSCREEN);
+
top_container_ = new views::View();
- top_container_->SetBounds(0, 0, 500, 100);
+ top_container_->SetBounds(
+ 0, 0, widget_->GetWindowBoundsInScreen().width(), 100);
top_container_->set_focusable(true);
-
widget_->GetContentsView()->AddChildView(top_container_);
controller_->Init(delegate_.get(), widget_, top_container_);
@@ -251,6 +268,12 @@ TEST_F(ImmersiveModeControllerAshTest, ImmersiveModeControllerAsh) {
// Test mouse event processing for top-of-screen reveal triggering.
TEST_F(ImmersiveModeControllerAshTest, OnMouseEvent) {
// Set up initial state.
+ UpdateDisplay("800x600,800x600");
+ ash::DisplayLayout display_layout(ash::DisplayLayout::RIGHT, 0);
+ ash::Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
+ display_layout);
+
+ // Set up initial state.
controller()->SetEnabled(true);
ASSERT_TRUE(controller()->IsEnabled());
ASSERT_FALSE(controller()->IsRevealed());
@@ -302,8 +325,7 @@ TEST_F(ImmersiveModeControllerAshTest, OnMouseEvent) {
EXPECT_EQ(top_edge_pos.x() + 100, mouse_x_when_hit_top());
// Moving off the top edge horizontally stops the timer.
- EXPECT_GT(CurrentContext()->bounds().width(), top_container()->width());
- event_generator.MoveMouseTo(top_container_bounds_in_screen.right(),
+ event_generator.MoveMouseTo(top_container_bounds_in_screen.right() + 1,
top_container_bounds_in_screen.y());
EXPECT_FALSE(top_edge_hover_timer_running());
@@ -975,4 +997,50 @@ TEST_F(ImmersiveModeControllerAshTestWithBrowserView, ExitUponRestore) {
EXPECT_FALSE(controller()->IsEnabled());
}
+// Test that it is still possible to reveal and hide the top-of-window views
+// via a gesture when a child window consumes touch events.
+TEST_F(ImmersiveModeControllerAshTestWithBrowserView,
+ RevealViaGestureChildWindowConsumesTouchEvents) {
+ views::Widget* browser_widget = browser_view()->GetWidget();
+
+ // Create a child widget which consumes all touch events.
+ views::Widget::InitParams child_params(
+ views::Widget::InitParams::TYPE_CONTROL);
+ child_params.ownership =
+ views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ child_params.parent = browser_widget->GetNativeView();
+ child_params.bounds =
+ gfx::Rect(browser_widget->GetWindowBoundsInScreen().size());
+ scoped_ptr<views::Widget> child_widget(new views::Widget());
+ child_widget->Init(child_params);
+ child_widget->SetContentsView(new TouchEventConsumerView());
+ child_widget->Show();
+
+ ASSERT_FALSE(controller()->IsEnabled());
+ chrome::ToggleFullscreenMode(browser());
+ ASSERT_TRUE(controller()->IsEnabled());
+ EXPECT_FALSE(controller()->IsRevealed());
+
+ gfx::Rect top_container_bounds_in_root =
+ ash::ScreenAsh::ConvertRectFromScreen(
+ browser_widget->GetNativeView()->GetRootWindow(),
+ browser_view()->top_container()->GetBoundsInScreen());
+
+ gfx::Point top(top_container_bounds_in_root.origin());
+ gfx::Point bottom = top + gfx::Vector2d(0, 100);
+ aura::test::EventGenerator generator(
+ browser_widget->GetNativeView()->GetRootWindow());
+ generator.GestureScrollSequence(top,
+ bottom,
+ base::TimeDelta::FromMilliseconds(10),
+ 3);
+ EXPECT_TRUE(controller()->IsRevealed());
+
+ generator.GestureScrollSequence(bottom,
+ top,
+ base::TimeDelta::FromMilliseconds(10),
+ 3);
+ EXPECT_FALSE(controller()->IsRevealed());
+}
+
#endif // defined(OS_CHROMEOS)

Powered by Google App Engine
This is Rietveld 408576698