| OLD | NEW |
| 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 "ash/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
| 8 #include "ash/common/accelerators/accelerator_controller.h" | 8 #include "ash/common/accelerators/accelerator_controller.h" |
| 9 #include "ash/common/accelerators/accelerator_table.h" | 9 #include "ash/common/accelerators/accelerator_table.h" |
| 10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "ui/aura/window.h" | 37 #include "ui/aura/window.h" |
| 38 #include "ui/aura/window_event_dispatcher.h" | 38 #include "ui/aura/window_event_dispatcher.h" |
| 39 #include "ui/compositor/layer.h" | 39 #include "ui/compositor/layer.h" |
| 40 #include "ui/compositor/layer_animator.h" | 40 #include "ui/compositor/layer_animator.h" |
| 41 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 41 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 42 #include "ui/display/display.h" | 42 #include "ui/display/display.h" |
| 43 #include "ui/display/manager/display_layout.h" | 43 #include "ui/display/manager/display_layout.h" |
| 44 #include "ui/display/screen.h" | 44 #include "ui/display/screen.h" |
| 45 #include "ui/events/gesture_detection/gesture_configuration.h" | 45 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 46 #include "ui/events/test/event_generator.h" | 46 #include "ui/events/test/event_generator.h" |
| 47 #include "ui/keyboard/keyboard_controller.h" |
| 48 #include "ui/keyboard/keyboard_ui.h" |
| 49 #include "ui/keyboard/keyboard_util.h" |
| 47 #include "ui/views/view.h" | 50 #include "ui/views/view.h" |
| 48 #include "ui/views/widget/widget.h" | 51 #include "ui/views/widget/widget.h" |
| 49 | 52 |
| 50 #if defined(OS_WIN) | 53 #if defined(OS_WIN) |
| 51 #include "base/win/windows_version.h" | 54 #include "base/win/windows_version.h" |
| 52 #endif | 55 #endif |
| 53 | 56 |
| 54 namespace ash { | 57 namespace ash { |
| 55 namespace { | 58 namespace { |
| 56 | 59 |
| (...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 UpdateDisplay("500x400, 500x400"); | 1932 UpdateDisplay("500x400, 500x400"); |
| 1930 | 1933 |
| 1931 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); | 1934 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); |
| 1932 EXPECT_TRUE(status_area_widget->IsVisible()); | 1935 EXPECT_TRUE(status_area_widget->IsVisible()); |
| 1933 // Shelf should be in the first display's area. | 1936 // Shelf should be in the first display's area. |
| 1934 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); | 1937 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); |
| 1935 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); | 1938 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); |
| 1936 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); | 1939 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); |
| 1937 } | 1940 } |
| 1938 | 1941 |
| 1939 } // namespace ash | 1942 class ShelfLayoutManagerKeyboardTest : public test::AshTestBase { |
| 1943 public: |
| 1944 ShelfLayoutManagerKeyboardTest() {} |
| 1945 ~ShelfLayoutManagerKeyboardTest() override {} |
| 1946 |
| 1947 // test::AshTestBase: |
| 1948 void SetUp() override { |
| 1949 test::AshTestBase::SetUp(); |
| 1950 UpdateDisplay("800x600"); |
| 1951 keyboard::SetAccessibilityKeyboardEnabled(true); |
| 1952 } |
| 1953 |
| 1954 void InitKeyboardBounds() { |
| 1955 gfx::Rect work_area( |
| 1956 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 1957 keyboard_bounds_.SetRect(work_area.x(), |
| 1958 work_area.y() + work_area.height() / 2, |
| 1959 work_area.width(), work_area.height() / 2); |
| 1960 } |
| 1961 |
| 1962 void EnableNewVKMode() { |
| 1963 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 1964 if (!command_line->HasSwitch(switches::kAshUseNewVKWindowBehavior)) { |
| 1965 command_line->AppendSwitch(switches::kAshUseNewVKWindowBehavior); |
| 1966 } |
| 1967 } |
| 1968 |
| 1969 const gfx::Rect& keyboard_bounds() const { return keyboard_bounds_; } |
| 1970 |
| 1971 private: |
| 1972 gfx::Rect keyboard_bounds_; |
| 1973 |
| 1974 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerKeyboardTest); |
| 1975 }; |
| 1976 |
| 1977 TEST_F(ShelfLayoutManagerKeyboardTest, ShelfChangeWorkAreaInNonStickyMode) { |
| 1978 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1979 keyboard::SetAccessibilityKeyboardEnabled(true); |
| 1980 InitKeyboardBounds(); |
| 1981 Shell::GetInstance()->CreateKeyboard(); |
| 1982 keyboard::KeyboardController* kb_controller = |
| 1983 keyboard::KeyboardController::GetInstance(); |
| 1984 gfx::Rect orig_work_area( |
| 1985 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 1986 |
| 1987 // Open keyboard in non-sticky mode. |
| 1988 kb_controller->ShowKeyboard(false); |
| 1989 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); |
| 1990 |
| 1991 // Work area should be changed. |
| 1992 EXPECT_NE(orig_work_area, |
| 1993 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 1994 |
| 1995 kb_controller->HideKeyboard( |
| 1996 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); |
| 1997 layout_manager->OnKeyboardBoundsChanging(gfx::Rect()); |
| 1998 EXPECT_EQ(orig_work_area, |
| 1999 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 2000 |
| 2001 // Open keyboard in sticky mode. |
| 2002 kb_controller->ShowKeyboard(true); |
| 2003 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); |
| 2004 |
| 2005 // Work area should be changed. |
| 2006 EXPECT_NE(orig_work_area, |
| 2007 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 2008 } |
| 2009 |
| 2010 // When kAshUseNewVKWindowBehavior flag enabled, do not change accessibility |
| 2011 // keyboard work area in non-sticky mode. |
| 2012 TEST_F(ShelfLayoutManagerKeyboardTest, |
| 2013 ShelfIgnoreWorkAreaChangeInNonStickyMode) { |
| 2014 // Append flag to ignore work area change in non-sticky mode. |
| 2015 EnableNewVKMode(); |
| 2016 |
| 2017 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 2018 InitKeyboardBounds(); |
| 2019 Shell::GetInstance()->CreateKeyboard(); |
| 2020 keyboard::KeyboardController* kb_controller = |
| 2021 keyboard::KeyboardController::GetInstance(); |
| 2022 gfx::Rect orig_work_area( |
| 2023 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 2024 |
| 2025 // Open keyboard in non-sticky mode. |
| 2026 kb_controller->ShowKeyboard(false); |
| 2027 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); |
| 2028 |
| 2029 // Work area should not be changed. |
| 2030 EXPECT_EQ(orig_work_area, |
| 2031 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 2032 |
| 2033 kb_controller->HideKeyboard( |
| 2034 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); |
| 2035 layout_manager->OnKeyboardBoundsChanging(gfx::Rect()); |
| 2036 EXPECT_EQ(orig_work_area, |
| 2037 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 2038 |
| 2039 // Open keyboard in sticky mode. |
| 2040 kb_controller->ShowKeyboard(true); |
| 2041 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); |
| 2042 |
| 2043 // Work area should be changed. |
| 2044 EXPECT_NE(orig_work_area, |
| 2045 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 2046 } |
| 2047 |
| 2048 } // namespace ash |
| OLD | NEW |