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

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

Issue 1392713002: Extract content dependency from keyboard code (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/test/base/in_process_browser_test.h" 7 #include "chrome/test/base/in_process_browser_test.h"
8 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
9 #include "ui/base/ime/dummy_text_input_client.h" 9 #include "ui/base/ime/dummy_text_input_client.h"
10 #include "ui/base/ime/input_method.h" 10 #include "ui/base/ime/input_method.h"
11 #include "ui/base/ime/input_method_factory.h" 11 #include "ui/base/ime/input_method_factory.h"
12 #include "ui/keyboard/keyboard_constants.h" 12 #include "ui/keyboard/content/keyboard_constants.h"
13 #include "ui/keyboard/keyboard_controller.h" 13 #include "ui/keyboard/keyboard_controller.h"
14 #include "ui/keyboard/keyboard_controller_proxy.h"
15 #include "ui/keyboard/keyboard_switches.h" 14 #include "ui/keyboard/keyboard_switches.h"
15 #include "ui/keyboard/keyboard_ui.h"
16 #include "ui/keyboard/keyboard_util.h" 16 #include "ui/keyboard/keyboard_util.h"
17 17
18 namespace { 18 namespace {
19 const int kKeyboardHeightForTest = 100; 19 const int kKeyboardHeightForTest = 100;
20 } // namespace 20 } // namespace
21 21
22 class VirtualKeyboardWebContentTest : public InProcessBrowserTest { 22 class VirtualKeyboardWebContentTest : public InProcessBrowserTest {
23 public: 23 public:
24 VirtualKeyboardWebContentTest() {} 24 VirtualKeyboardWebContentTest() {}
25 ~VirtualKeyboardWebContentTest() override {} 25 ~VirtualKeyboardWebContentTest() override {}
26 26
27 void SetUp() override { 27 void SetUp() override {
28 ui::SetUpInputMethodFactoryForTesting(); 28 ui::SetUpInputMethodFactoryForTesting();
29 InProcessBrowserTest::SetUp(); 29 InProcessBrowserTest::SetUp();
30 } 30 }
31 31
32 // Ensure that the virtual keyboard is enabled. 32 // Ensure that the virtual keyboard is enabled.
33 void SetUpCommandLine(base::CommandLine* command_line) override { 33 void SetUpCommandLine(base::CommandLine* command_line) override {
34 command_line->AppendSwitch( 34 command_line->AppendSwitch(
35 keyboard::switches::kEnableVirtualKeyboard); 35 keyboard::switches::kEnableVirtualKeyboard);
36 } 36 }
37 37
38 keyboard::KeyboardControllerProxy* proxy() { 38 keyboard::KeyboardUI* ui() {
39 return keyboard::KeyboardController::GetInstance()->proxy(); 39 return keyboard::KeyboardController::GetInstance()->ui();
40 } 40 }
41 41
42 protected: 42 protected:
43 void FocusEditableNodeAndShowKeyboard(const gfx::Rect& init_bounds) { 43 void FocusEditableNodeAndShowKeyboard(const gfx::Rect& init_bounds) {
44 client.reset(new ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT)); 44 client.reset(new ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT));
45 ui::InputMethod* input_method = proxy()->GetInputMethod(); 45 ui::InputMethod* input_method = ui()->GetInputMethod();
46 input_method->SetFocusedTextInputClient(client.get()); 46 input_method->SetFocusedTextInputClient(client.get());
47 input_method->ShowImeIfNeeded(); 47 input_method->ShowImeIfNeeded();
48 // Mock window.resizeTo that is expected to be called after navigate to a 48 // Mock window.resizeTo that is expected to be called after navigate to a
49 // new virtual keyboard. 49 // new virtual keyboard.
50 proxy()->GetKeyboardWindow()->SetBounds(init_bounds); 50 ui()->GetKeyboardWindow()->SetBounds(init_bounds);
51 } 51 }
52 52
53 void FocusNonEditableNode() { 53 void FocusNonEditableNode() {
54 client.reset(new ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_NONE)); 54 client.reset(new ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_NONE));
55 ui::InputMethod* input_method = proxy()->GetInputMethod(); 55 ui::InputMethod* input_method = ui()->GetInputMethod();
56 input_method->SetFocusedTextInputClient(client.get()); 56 input_method->SetFocusedTextInputClient(client.get());
57 } 57 }
58 58
59 void MockEnableIMEInDifferentExtension(const std::string& url, 59 void MockEnableIMEInDifferentExtension(const std::string& url,
60 const gfx::Rect& init_bounds) { 60 const gfx::Rect& init_bounds) {
61 keyboard::SetOverrideContentUrl(GURL(url)); 61 keyboard::SetOverrideContentUrl(GURL(url));
62 keyboard::KeyboardController::GetInstance()->Reload(); 62 keyboard::KeyboardController::GetInstance()->Reload();
63 // Mock window.resizeTo that is expected to be called after navigate to a 63 // Mock window.resizeTo that is expected to be called after navigate to a
64 // new virtual keyboard. 64 // new virtual keyboard.
65 proxy()->GetKeyboardWindow()->SetBounds(init_bounds); 65 ui()->GetKeyboardWindow()->SetBounds(init_bounds);
66 } 66 }
67 67
68 bool IsKeyboardVisible() const { 68 bool IsKeyboardVisible() const {
69 return keyboard::KeyboardController::GetInstance()->keyboard_visible(); 69 return keyboard::KeyboardController::GetInstance()->keyboard_visible();
70 } 70 }
71 71
72 private: 72 private:
73 scoped_ptr<ui::DummyTextInputClient> client; 73 scoped_ptr<ui::DummyTextInputClient> client;
74 74
75 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardWebContentTest); 75 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardWebContentTest);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 FocusEditableNodeAndShowKeyboard(test_bounds); 113 FocusEditableNodeAndShowKeyboard(test_bounds);
114 keyboard::KeyboardController* controller = 114 keyboard::KeyboardController* controller =
115 keyboard::KeyboardController::GetInstance(); 115 keyboard::KeyboardController::GetInstance();
116 const gfx::Rect& screen_bounds = ash::Shell::GetPrimaryRootWindow()->bounds(); 116 const gfx::Rect& screen_bounds = ash::Shell::GetPrimaryRootWindow()->bounds();
117 gfx::Rect keyboard_bounds = controller->GetContainerWindow()->bounds(); 117 gfx::Rect keyboard_bounds = controller->GetContainerWindow()->bounds();
118 EXPECT_EQ(kKeyboardHeightForTest, keyboard_bounds.height()); 118 EXPECT_EQ(kKeyboardHeightForTest, keyboard_bounds.height());
119 EXPECT_EQ(screen_bounds.height(), 119 EXPECT_EQ(screen_bounds.height(),
120 keyboard_bounds.height() + keyboard_bounds.y()); 120 keyboard_bounds.height() + keyboard_bounds.y());
121 controller->SetKeyboardMode(keyboard::FLOATING); 121 controller->SetKeyboardMode(keyboard::FLOATING);
122 // Move keyboard to a random place. 122 // Move keyboard to a random place.
123 proxy()->GetKeyboardWindow()->SetBounds(gfx::Rect(50, 50, 50, 50)); 123 ui()->GetKeyboardWindow()->SetBounds(gfx::Rect(50, 50, 50, 50));
124 EXPECT_EQ(gfx::Rect(50, 50, 50, 50), 124 EXPECT_EQ(gfx::Rect(50, 50, 50, 50),
125 controller->GetContainerWindow()->bounds()); 125 controller->GetContainerWindow()->bounds());
126 126
127 MockEnableIMEInDifferentExtension("chrome-extension://domain-1", test_bounds); 127 MockEnableIMEInDifferentExtension("chrome-extension://domain-1", test_bounds);
128 keyboard_bounds = controller->GetContainerWindow()->bounds(); 128 keyboard_bounds = controller->GetContainerWindow()->bounds();
129 EXPECT_EQ(kKeyboardHeightForTest, keyboard_bounds.height()); 129 EXPECT_EQ(kKeyboardHeightForTest, keyboard_bounds.height());
130 EXPECT_EQ(screen_bounds.height(), 130 EXPECT_EQ(screen_bounds.height(),
131 keyboard_bounds.height() + keyboard_bounds.y()); 131 keyboard_bounds.height() + keyboard_bounds.y());
132 } 132 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/chrome_shell_delegate.cc ('k') | chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698