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

Side by Side Diff: ui/keyboard/keyboard_controller_unittest.cc

Issue 623293004: replace OVERRIDE and FINAL with override and final in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 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
« no previous file with comments | « ui/keyboard/keyboard_controller_proxy.cc ('k') | ui/keyboard/keyboard_layout_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/keyboard/keyboard_controller.h" 5 #include "ui/keyboard/keyboard_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 : root_(root) { 61 : root_(root) {
62 root_->AddPreTargetHandler(this); 62 root_->AddPreTargetHandler(this);
63 } 63 }
64 64
65 virtual ~TestFocusController() { 65 virtual ~TestFocusController() {
66 root_->RemovePreTargetHandler(this); 66 root_->RemovePreTargetHandler(this);
67 } 67 }
68 68
69 private: 69 private:
70 // Overridden from ui::EventHandler: 70 // Overridden from ui::EventHandler:
71 virtual void OnEvent(ui::Event* event) OVERRIDE { 71 virtual void OnEvent(ui::Event* event) override {
72 aura::Window* target = static_cast<aura::Window*>(event->target()); 72 aura::Window* target = static_cast<aura::Window*>(event->target());
73 if (event->type() == ui::ET_MOUSE_PRESSED || 73 if (event->type() == ui::ET_MOUSE_PRESSED ||
74 event->type() == ui::ET_TOUCH_PRESSED) { 74 event->type() == ui::ET_TOUCH_PRESSED) {
75 aura::client::GetFocusClient(target)->FocusWindow(target); 75 aura::client::GetFocusClient(target)->FocusWindow(target);
76 } 76 }
77 } 77 }
78 78
79 aura::Window* root_; 79 aura::Window* root_;
80 DISALLOW_COPY_AND_ASSIGN(TestFocusController); 80 DISALLOW_COPY_AND_ASSIGN(TestFocusController);
81 }; 81 };
82 82
83 class TestKeyboardControllerProxy : public KeyboardControllerProxy { 83 class TestKeyboardControllerProxy : public KeyboardControllerProxy {
84 public: 84 public:
85 TestKeyboardControllerProxy() 85 TestKeyboardControllerProxy()
86 : input_method_( 86 : input_method_(
87 ui::CreateInputMethod(NULL, gfx::kNullAcceleratedWidget)) {} 87 ui::CreateInputMethod(NULL, gfx::kNullAcceleratedWidget)) {}
88 88
89 virtual ~TestKeyboardControllerProxy() { 89 virtual ~TestKeyboardControllerProxy() {
90 // Destroy the window before the delegate. 90 // Destroy the window before the delegate.
91 window_.reset(); 91 window_.reset();
92 } 92 }
93 93
94 // Overridden from KeyboardControllerProxy: 94 // Overridden from KeyboardControllerProxy:
95 virtual bool HasKeyboardWindow() const OVERRIDE { return window_; } 95 virtual bool HasKeyboardWindow() const override { return window_; }
96 virtual aura::Window* GetKeyboardWindow() OVERRIDE { 96 virtual aura::Window* GetKeyboardWindow() override {
97 if (!window_) { 97 if (!window_) {
98 window_.reset(new aura::Window(&delegate_)); 98 window_.reset(new aura::Window(&delegate_));
99 window_->Init(aura::WINDOW_LAYER_NOT_DRAWN); 99 window_->Init(aura::WINDOW_LAYER_NOT_DRAWN);
100 window_->set_owned_by_parent(false); 100 window_->set_owned_by_parent(false);
101 } 101 }
102 return window_.get(); 102 return window_.get();
103 } 103 }
104 virtual content::BrowserContext* GetBrowserContext() OVERRIDE { return NULL; } 104 virtual content::BrowserContext* GetBrowserContext() override { return NULL; }
105 virtual ui::InputMethod* GetInputMethod() OVERRIDE { 105 virtual ui::InputMethod* GetInputMethod() override {
106 return input_method_.get(); 106 return input_method_.get();
107 } 107 }
108 virtual void RequestAudioInput(content::WebContents* web_contents, 108 virtual void RequestAudioInput(content::WebContents* web_contents,
109 const content::MediaStreamRequest& request, 109 const content::MediaStreamRequest& request,
110 const content::MediaResponseCallback& callback) OVERRIDE { return; } 110 const content::MediaResponseCallback& callback) override { return; }
111 virtual void LoadSystemKeyboard() OVERRIDE {}; 111 virtual void LoadSystemKeyboard() override {};
112 virtual void ReloadKeyboardIfNeeded() OVERRIDE {}; 112 virtual void ReloadKeyboardIfNeeded() override {};
113 113
114 private: 114 private:
115 scoped_ptr<aura::Window> window_; 115 scoped_ptr<aura::Window> window_;
116 aura::test::TestWindowDelegate delegate_; 116 aura::test::TestWindowDelegate delegate_;
117 scoped_ptr<ui::InputMethod> input_method_; 117 scoped_ptr<ui::InputMethod> input_method_;
118 118
119 DISALLOW_COPY_AND_ASSIGN(TestKeyboardControllerProxy); 119 DISALLOW_COPY_AND_ASSIGN(TestKeyboardControllerProxy);
120 }; 120 };
121 121
122 // Keeps a count of all the events a window receives. 122 // Keeps a count of all the events a window receives.
123 class EventObserver : public ui::EventHandler { 123 class EventObserver : public ui::EventHandler {
124 public: 124 public:
125 EventObserver() {} 125 EventObserver() {}
126 virtual ~EventObserver() {} 126 virtual ~EventObserver() {}
127 127
128 int GetEventCount(ui::EventType type) { 128 int GetEventCount(ui::EventType type) {
129 return event_counts_[type]; 129 return event_counts_[type];
130 } 130 }
131 131
132 private: 132 private:
133 // Overridden from ui::EventHandler: 133 // Overridden from ui::EventHandler:
134 virtual void OnEvent(ui::Event* event) OVERRIDE { 134 virtual void OnEvent(ui::Event* event) override {
135 ui::EventHandler::OnEvent(event); 135 ui::EventHandler::OnEvent(event);
136 event_counts_[event->type()]++; 136 event_counts_[event->type()]++;
137 } 137 }
138 138
139 std::map<ui::EventType, int> event_counts_; 139 std::map<ui::EventType, int> event_counts_;
140 DISALLOW_COPY_AND_ASSIGN(EventObserver); 140 DISALLOW_COPY_AND_ASSIGN(EventObserver);
141 }; 141 };
142 142
143 class KeyboardContainerObserver : public aura::WindowObserver { 143 class KeyboardContainerObserver : public aura::WindowObserver {
144 public: 144 public:
145 explicit KeyboardContainerObserver(aura::Window* window) : window_(window) { 145 explicit KeyboardContainerObserver(aura::Window* window) : window_(window) {
146 window_->AddObserver(this); 146 window_->AddObserver(this);
147 } 147 }
148 virtual ~KeyboardContainerObserver() { 148 virtual ~KeyboardContainerObserver() {
149 window_->RemoveObserver(this); 149 window_->RemoveObserver(this);
150 } 150 }
151 151
152 private: 152 private:
153 virtual void OnWindowVisibilityChanged(aura::Window* window, 153 virtual void OnWindowVisibilityChanged(aura::Window* window,
154 bool visible) OVERRIDE { 154 bool visible) override {
155 if (!visible) 155 if (!visible)
156 base::MessageLoop::current()->Quit(); 156 base::MessageLoop::current()->Quit();
157 } 157 }
158 158
159 aura::Window* window_; 159 aura::Window* window_;
160 160
161 DISALLOW_COPY_AND_ASSIGN(KeyboardContainerObserver); 161 DISALLOW_COPY_AND_ASSIGN(KeyboardContainerObserver);
162 }; 162 };
163 163
164 } // namespace 164 } // namespace
165 165
166 class KeyboardControllerTest : public testing::Test { 166 class KeyboardControllerTest : public testing::Test {
167 public: 167 public:
168 KeyboardControllerTest() {} 168 KeyboardControllerTest() {}
169 virtual ~KeyboardControllerTest() {} 169 virtual ~KeyboardControllerTest() {}
170 170
171 virtual void SetUp() OVERRIDE { 171 virtual void SetUp() override {
172 // The ContextFactory must exist before any Compositors are created. 172 // The ContextFactory must exist before any Compositors are created.
173 bool enable_pixel_output = false; 173 bool enable_pixel_output = false;
174 ui::ContextFactory* context_factory = 174 ui::ContextFactory* context_factory =
175 ui::InitializeContextFactoryForTests(enable_pixel_output); 175 ui::InitializeContextFactoryForTests(enable_pixel_output);
176 176
177 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); 177 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
178 aura_test_helper_->SetUp(context_factory); 178 aura_test_helper_->SetUp(context_factory);
179 new wm::DefaultActivationClient(aura_test_helper_->root_window()); 179 new wm::DefaultActivationClient(aura_test_helper_->root_window());
180 ui::SetUpInputMethodFactoryForTesting(); 180 ui::SetUpInputMethodFactoryForTesting();
181 if (::switches::IsTextInputFocusManagerEnabled()) 181 if (::switches::IsTextInputFocusManagerEnabled())
182 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL); 182 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL);
183 focus_controller_.reset(new TestFocusController(root_window())); 183 focus_controller_.reset(new TestFocusController(root_window()));
184 proxy_ = new TestKeyboardControllerProxy(); 184 proxy_ = new TestKeyboardControllerProxy();
185 controller_.reset(new KeyboardController(proxy_)); 185 controller_.reset(new KeyboardController(proxy_));
186 } 186 }
187 187
188 virtual void TearDown() OVERRIDE { 188 virtual void TearDown() override {
189 controller_.reset(); 189 controller_.reset();
190 focus_controller_.reset(); 190 focus_controller_.reset();
191 if (::switches::IsTextInputFocusManagerEnabled()) 191 if (::switches::IsTextInputFocusManagerEnabled())
192 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL); 192 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL);
193 aura_test_helper_->TearDown(); 193 aura_test_helper_->TearDown();
194 ui::TerminateContextFactoryForTests(); 194 ui::TerminateContextFactoryForTests();
195 } 195 }
196 196
197 aura::Window* root_window() { return aura_test_helper_->root_window(); } 197 aura::Window* root_window() { return aura_test_helper_->root_window(); }
198 KeyboardControllerProxy* proxy() { return proxy_; } 198 KeyboardControllerProxy* proxy() { return proxy_; }
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 base::MessageLoop::current()->Run(); 492 base::MessageLoop::current()->Run();
493 EXPECT_FALSE(keyboard_container->IsVisible()); 493 EXPECT_FALSE(keyboard_container->IsVisible());
494 } 494 }
495 495
496 class KeyboardControllerAnimationTest : public KeyboardControllerTest, 496 class KeyboardControllerAnimationTest : public KeyboardControllerTest,
497 public KeyboardControllerObserver { 497 public KeyboardControllerObserver {
498 public: 498 public:
499 KeyboardControllerAnimationTest() {} 499 KeyboardControllerAnimationTest() {}
500 virtual ~KeyboardControllerAnimationTest() {} 500 virtual ~KeyboardControllerAnimationTest() {}
501 501
502 virtual void SetUp() OVERRIDE { 502 virtual void SetUp() override {
503 // We cannot short-circuit animations for this test. 503 // We cannot short-circuit animations for this test.
504 ui::ScopedAnimationDurationScaleMode test_duration_mode( 504 ui::ScopedAnimationDurationScaleMode test_duration_mode(
505 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); 505 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
506 506
507 KeyboardControllerTest::SetUp(); 507 KeyboardControllerTest::SetUp();
508 508
509 const gfx::Rect& root_bounds = root_window()->bounds(); 509 const gfx::Rect& root_bounds = root_window()->bounds();
510 keyboard_container()->SetBounds(root_bounds); 510 keyboard_container()->SetBounds(root_bounds);
511 root_window()->AddChild(keyboard_container()); 511 root_window()->AddChild(keyboard_container());
512 controller()->AddObserver(this); 512 controller()->AddObserver(this);
513 } 513 }
514 514
515 virtual void TearDown() OVERRIDE { 515 virtual void TearDown() override {
516 controller()->RemoveObserver(this); 516 controller()->RemoveObserver(this);
517 KeyboardControllerTest::TearDown(); 517 KeyboardControllerTest::TearDown();
518 } 518 }
519 519
520 protected: 520 protected:
521 // KeyboardControllerObserver overrides 521 // KeyboardControllerObserver overrides
522 virtual void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) OVERRIDE { 522 virtual void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override {
523 notified_bounds_ = new_bounds; 523 notified_bounds_ = new_bounds;
524 } 524 }
525 525
526 const gfx::Rect& notified_bounds() { return notified_bounds_; } 526 const gfx::Rect& notified_bounds() { return notified_bounds_; }
527 527
528 aura::Window* keyboard_container() { 528 aura::Window* keyboard_container() {
529 return controller()->GetContainerWindow(); 529 return controller()->GetContainerWindow();
530 } 530 }
531 531
532 aura::Window* keyboard_window() { 532 aura::Window* keyboard_window() {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 // Before hide animation finishes, show keyboard again. 596 // Before hide animation finishes, show keyboard again.
597 ShowKeyboard(); 597 ShowKeyboard();
598 RunAnimationForLayer(layer); 598 RunAnimationForLayer(layer);
599 EXPECT_TRUE(keyboard_container()->IsVisible()); 599 EXPECT_TRUE(keyboard_container()->IsVisible());
600 EXPECT_TRUE(keyboard_window()->IsVisible()); 600 EXPECT_TRUE(keyboard_window()->IsVisible());
601 EXPECT_EQ(1.0, layer->opacity()); 601 EXPECT_EQ(1.0, layer->opacity());
602 EXPECT_EQ(gfx::Transform(), layer->transform()); 602 EXPECT_EQ(gfx::Transform(), layer->transform());
603 } 603 }
604 604
605 } // namespace keyboard 605 } // namespace keyboard
OLDNEW
« no previous file with comments | « ui/keyboard/keyboard_controller_proxy.cc ('k') | ui/keyboard/keyboard_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698