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

Side by Side Diff: ash/shelf/shelf_layout_manager_unittest.cc

Issue 2200963002: ShelfLayoutManager virtual keyboard - do not change work area of screen if in non-sticky mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ShelfLayoutManager virtual keyboard - do not change work area of screen if in non-sticky mode. Created 4 years, 4 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 (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
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 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 UpdateDisplay("500x400, 500x400"); 2034 UpdateDisplay("500x400, 500x400");
2032 2035
2033 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); 2036 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget();
2034 EXPECT_TRUE(status_area_widget->IsVisible()); 2037 EXPECT_TRUE(status_area_widget->IsVisible());
2035 // Shelf should be in the first display's area. 2038 // Shelf should be in the first display's area.
2036 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); 2039 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen());
2037 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); 2040 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds));
2038 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); 2041 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right());
2039 } 2042 }
2040 2043
2041 } // namespace ash 2044 class ShelfLayoutManagerKeyboardTest : public test::AshTestBase {
2045 public:
2046 ShelfLayoutManagerKeyboardTest() {}
2047 ~ShelfLayoutManagerKeyboardTest() override {}
2048
oshima 2016/08/03 21:22:38 nit: // test::AshTestBase:
hariank 2016/08/03 21:29:37 Done.
2049 void SetUp() override {
2050 test::AshTestBase::SetUp();
2051 UpdateDisplay("800x600");
2052 keyboard::SetAccessibilityKeyboardEnabled(true);
2053 }
2054
2055 void InitKeyboardBounds() {
2056 gfx::Rect work_area(
2057 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
2058 keyboard_bounds_.SetRect(work_area.x(),
2059 work_area.y() + work_area.height() / 2,
2060 work_area.width(), work_area.height() / 2);
2061 }
2062
2063 void EnableNewVKMode() {
2064 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
2065 if (!command_line->HasSwitch(switches::kAshUseNewVKWindowBehavior)) {
2066 command_line->AppendSwitch(switches::kAshUseNewVKWindowBehavior);
2067 }
2068 }
2069
2070 const gfx::Rect& keyboard_bounds() const { return keyboard_bounds_; }
2071
2072 private:
2073 gfx::Rect keyboard_bounds_;
2074
2075 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerKeyboardTest);
2076 };
2077
2078 TEST_F(ShelfLayoutManagerKeyboardTest, ShelfChangeWorkAreaInNonStickyMode) {
2079 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
2080 keyboard::SetAccessibilityKeyboardEnabled(true);
2081 InitKeyboardBounds();
2082 Shell::GetInstance()->CreateKeyboard();
2083 keyboard::KeyboardController* kb_controller =
2084 keyboard::KeyboardController::GetInstance();
2085 gfx::Rect orig_work_area(
2086 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
2087
2088 // Open keyboard in non-sticky mode.
2089 kb_controller->ShowKeyboard(false);
2090 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds());
2091
2092 // Work area should be changed.
2093 EXPECT_NE(orig_work_area,
2094 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
2095
2096 kb_controller->HideKeyboard(
2097 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
2098 layout_manager->OnKeyboardBoundsChanging(gfx::Rect());
2099 EXPECT_EQ(orig_work_area,
2100 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
2101
2102 // Open keyboard in sticky mode.
2103 kb_controller->ShowKeyboard(true);
2104 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds());
2105
2106 // Work area should be changed.
2107 EXPECT_NE(orig_work_area,
2108 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
2109 }
2110
2111 // When kAshUseNewVKWindowBehavior flag enabled, do not change accessibility
2112 // keyboard work area in non-sticky mode.
2113 TEST_F(ShelfLayoutManagerKeyboardTest,
2114 ShelfIgnoreWorkAreaChangeInNonStickyMode) {
2115 // Append flag to ignore work area change in non-sticky mode.
2116 EnableNewVKMode();
2117
2118 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
2119 InitKeyboardBounds();
2120 Shell::GetInstance()->CreateKeyboard();
2121 keyboard::KeyboardController* kb_controller =
2122 keyboard::KeyboardController::GetInstance();
2123 gfx::Rect orig_work_area(
2124 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
2125
2126 // Open keyboard in non-sticky mode.
2127 kb_controller->ShowKeyboard(false);
2128 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds());
2129
2130 // Work area should not be changed.
2131 EXPECT_EQ(orig_work_area,
2132 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
2133
2134 kb_controller->HideKeyboard(
2135 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
2136 layout_manager->OnKeyboardBoundsChanging(gfx::Rect());
2137 EXPECT_EQ(orig_work_area,
2138 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
2139
2140 // Open keyboard in sticky mode.
2141 kb_controller->ShowKeyboard(true);
2142 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds());
2143
2144 // Work area should be changed.
2145 EXPECT_NE(orig_work_area,
2146 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
2147 }
2148
2149 } // namespace ash
OLDNEW
« ash/shelf/shelf_layout_manager.cc ('K') | « ash/shelf/shelf_layout_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698