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

Side by Side Diff: chrome/browser/ui/ash/keyboard_controller_browsertest.cc

Issue 1323053005: Fix cropped floating gesture candidate window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/shell.h" 5 #include "ash/shell.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "chrome/browser/apps/app_browsertest_util.h"
8 #include "chrome/browser/profiles/profile_manager.h"
7 #include "chrome/test/base/in_process_browser_test.h" 9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "content/public/browser/render_widget_host_view.h"
8 #include "content/public/browser/web_contents.h" 11 #include "content/public/browser/web_contents.h"
12 #include "extensions/browser/app_window/app_window.h"
13 #include "extensions/common/extension.h"
14 #include "extensions/common/extension_builder.h"
15 #include "extensions/common/value_builder.h"
9 #include "ui/base/ime/dummy_text_input_client.h" 16 #include "ui/base/ime/dummy_text_input_client.h"
10 #include "ui/base/ime/input_method.h" 17 #include "ui/base/ime/input_method.h"
11 #include "ui/base/ime/input_method_factory.h" 18 #include "ui/base/ime/input_method_factory.h"
12 #include "ui/keyboard/keyboard_constants.h" 19 #include "ui/keyboard/keyboard_constants.h"
13 #include "ui/keyboard/keyboard_controller.h" 20 #include "ui/keyboard/keyboard_controller.h"
14 #include "ui/keyboard/keyboard_controller_proxy.h" 21 #include "ui/keyboard/keyboard_controller_proxy.h"
15 #include "ui/keyboard/keyboard_switches.h" 22 #include "ui/keyboard/keyboard_switches.h"
16 #include "ui/keyboard/keyboard_util.h" 23 #include "ui/keyboard/keyboard_util.h"
17 24
18 namespace { 25 namespace {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 proxy()->GetKeyboardWindow()->SetBounds(gfx::Rect(50, 50, 50, 50)); 130 proxy()->GetKeyboardWindow()->SetBounds(gfx::Rect(50, 50, 50, 50));
124 EXPECT_EQ(gfx::Rect(50, 50, 50, 50), 131 EXPECT_EQ(gfx::Rect(50, 50, 50, 50),
125 controller->GetContainerWindow()->bounds()); 132 controller->GetContainerWindow()->bounds());
126 133
127 MockEnableIMEInDifferentExtension("chrome-extension://domain-1", test_bounds); 134 MockEnableIMEInDifferentExtension("chrome-extension://domain-1", test_bounds);
128 keyboard_bounds = controller->GetContainerWindow()->bounds(); 135 keyboard_bounds = controller->GetContainerWindow()->bounds();
129 EXPECT_EQ(kKeyboardHeightForTest, keyboard_bounds.height()); 136 EXPECT_EQ(kKeyboardHeightForTest, keyboard_bounds.height());
130 EXPECT_EQ(screen_bounds.height(), 137 EXPECT_EQ(screen_bounds.height(),
131 keyboard_bounds.height() + keyboard_bounds.y()); 138 keyboard_bounds.height() + keyboard_bounds.y());
132 } 139 }
140
141 class VirtualKeyboardAppWindowTest : public extensions::PlatformAppBrowserTest {
142 public:
143 VirtualKeyboardAppWindowTest() {}
144 ~VirtualKeyboardAppWindowTest() override {}
145
146 // Ensure that the virtual keyboard is enabled.
147 void SetUpCommandLine(base::CommandLine* command_line) override {
148 command_line->AppendSwitch(
149 keyboard::switches::kEnableVirtualKeyboard);
150 }
151
152 private:
153 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardAppWindowTest);
154 };
155
156 // Tests that ime window won't overscroll. See crbug.com/529880.
157 IN_PROC_BROWSER_TEST_F(VirtualKeyboardAppWindowTest,
158 DisableOverscrollForImeWindow) {
159 scoped_refptr<extensions::Extension> extension =
160 extensions::ExtensionBuilder()
161 .SetManifest(extensions::DictionaryBuilder()
162 .Set("name", "test extension")
163 .Set("version", "1")
164 .Set("manifest_version", 2))
165 .Build();
166
167 extensions::AppWindow::CreateParams non_ime_params;
168 non_ime_params.frame = extensions::AppWindow::FRAME_NONE;
169 extensions::AppWindow* non_ime_app_window =
170 CreateAppWindowFromParams(extension.get(), non_ime_params);
171 int non_ime_window_visible_height = non_ime_app_window->web_contents()
172 ->GetRenderWidgetHostView()->GetVisibleViewportSize().height();
173
174 extensions::AppWindow::CreateParams ime_params;
175 ime_params.frame = extensions::AppWindow::FRAME_NONE;
176 ime_params.is_ime_window = true;
177 extensions::AppWindow* ime_app_window =
178 CreateAppWindowFromParams(extension.get(), ime_params);
179 int ime_window_visible_height = ime_app_window->web_contents()
180 ->GetRenderWidgetHostView()->GetVisibleViewportSize().height();
181
182 ASSERT_EQ(non_ime_window_visible_height, ime_window_visible_height);
183 ASSERT_TRUE(ime_window_visible_height > 0);
184
185 int screen_height = ash::Shell::GetPrimaryRootWindow()->bounds().height();
186 gfx::Rect test_bounds(0, 0, 0, screen_height - ime_window_visible_height + 1);
187 keyboard::KeyboardController* controller =
188 keyboard::KeyboardController::GetInstance();
189 controller->ShowKeyboard(true);
190 controller->proxy()->GetKeyboardWindow()->SetBounds(test_bounds);
191 gfx::Rect keyboard_bounds = controller->GetContainerWindow()->bounds();
192 // Starts overscroll.
193 controller->NotifyKeyboardBoundsChanging(keyboard_bounds);
194
195 // Non ime window should have smaller visible view port due to overlap with
196 // virtual keyboard.
197 EXPECT_LT(non_ime_app_window->web_contents()->GetRenderWidgetHostView()
198 ->GetVisibleViewportSize().height(),
199 non_ime_window_visible_height);
200 // Ime window should have not be affected by virtual keyboard.
201 EXPECT_EQ(ime_app_window->web_contents()->GetRenderWidgetHostView()
202 ->GetVisibleViewportSize().height(),
203 ime_window_visible_height);
204 }
205
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698