| OLD | NEW |
| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/aura/client/focus_client.h" | 10 #include "ui/aura/client/focus_client.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 aura::Window* root_; | 52 aura::Window* root_; |
| 53 DISALLOW_COPY_AND_ASSIGN(TestFocusController); | 53 DISALLOW_COPY_AND_ASSIGN(TestFocusController); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 class TestKeyboardControllerProxy : public KeyboardControllerProxy { | 56 class TestKeyboardControllerProxy : public KeyboardControllerProxy { |
| 57 public: | 57 public: |
| 58 TestKeyboardControllerProxy() | 58 TestKeyboardControllerProxy() |
| 59 : window_(new aura::Window(&delegate_)), | 59 : window_(new aura::Window(&delegate_)), |
| 60 input_method_(ui::CreateInputMethod(NULL, | 60 input_method_(ui::CreateInputMethod(NULL, |
| 61 gfx::kNullAcceleratedWidget)) { | 61 gfx::kNullAcceleratedWidget)) { |
| 62 window_->Init(ui::LAYER_NOT_DRAWN); | 62 window_->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
| 63 window_->set_owned_by_parent(false); | 63 window_->set_owned_by_parent(false); |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual ~TestKeyboardControllerProxy() { | 66 virtual ~TestKeyboardControllerProxy() { |
| 67 // Destroy the window before the delegate. | 67 // Destroy the window before the delegate. |
| 68 window_.reset(); | 68 window_.reset(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 // Overridden from KeyboardControllerProxy: | 71 // Overridden from KeyboardControllerProxy: |
| 72 virtual aura::Window* GetKeyboardWindow() OVERRIDE { return window_.get(); } | 72 virtual aura::Window* GetKeyboardWindow() OVERRIDE { return window_.get(); } |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 // The KeyboardController's LayoutManager shouldn't let this happen | 248 // The KeyboardController's LayoutManager shouldn't let this happen |
| 249 proxy()->GetKeyboardWindow()->SetBounds(new_bounds); | 249 proxy()->GetKeyboardWindow()->SetBounds(new_bounds); |
| 250 ASSERT_EQ(before_bounds, proxy()->GetKeyboardWindow()->bounds()); | 250 ASSERT_EQ(before_bounds, proxy()->GetKeyboardWindow()->bounds()); |
| 251 } | 251 } |
| 252 | 252 |
| 253 // Tests that tapping/clicking inside the keyboard does not give it focus. | 253 // Tests that tapping/clicking inside the keyboard does not give it focus. |
| 254 TEST_F(KeyboardControllerTest, ClickDoesNotFocusKeyboard) { | 254 TEST_F(KeyboardControllerTest, ClickDoesNotFocusKeyboard) { |
| 255 const gfx::Rect& root_bounds = root_window()->bounds(); | 255 const gfx::Rect& root_bounds = root_window()->bounds(); |
| 256 aura::test::EventCountDelegate delegate; | 256 aura::test::EventCountDelegate delegate; |
| 257 scoped_ptr<aura::Window> window(new aura::Window(&delegate)); | 257 scoped_ptr<aura::Window> window(new aura::Window(&delegate)); |
| 258 window->Init(ui::LAYER_NOT_DRAWN); | 258 window->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
| 259 window->SetBounds(root_bounds); | 259 window->SetBounds(root_bounds); |
| 260 root_window()->AddChild(window.get()); | 260 root_window()->AddChild(window.get()); |
| 261 window->Show(); | 261 window->Show(); |
| 262 window->Focus(); | 262 window->Focus(); |
| 263 | 263 |
| 264 aura::Window* keyboard_container(controller()->GetContainerWindow()); | 264 aura::Window* keyboard_container(controller()->GetContainerWindow()); |
| 265 keyboard_container->SetBounds(root_bounds); | 265 keyboard_container->SetBounds(root_bounds); |
| 266 | 266 |
| 267 root_window()->AddChild(keyboard_container); | 267 root_window()->AddChild(keyboard_container); |
| 268 keyboard_container->Show(); | 268 keyboard_container->Show(); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 433 |
| 434 EXPECT_TRUE(keyboard_container->IsVisible()); | 434 EXPECT_TRUE(keyboard_container->IsVisible()); |
| 435 | 435 |
| 436 input_method->SetFocusedTextInputClient(&no_input_client); | 436 input_method->SetFocusedTextInputClient(&no_input_client); |
| 437 // Keyboard should not hide itself after lost focus. | 437 // Keyboard should not hide itself after lost focus. |
| 438 EXPECT_TRUE(keyboard_container->IsVisible()); | 438 EXPECT_TRUE(keyboard_container->IsVisible()); |
| 439 EXPECT_FALSE(WillHideKeyboard()); | 439 EXPECT_FALSE(WillHideKeyboard()); |
| 440 } | 440 } |
| 441 | 441 |
| 442 } // namespace keyboard | 442 } // namespace keyboard |
| OLD | NEW |