OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/message_loop.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/aura/test/aura_test_helper.h" |
| 9 #include "ui/aura/window.h" |
| 10 #include "ui/compositor/layer_type.h" |
| 11 #include "ui/gfx/rect.h" |
| 12 #include "ui/keyboard/keyboard_controller.h" |
| 13 #include "ui/keyboard/keyboard_controller_proxy.h" |
| 14 |
| 15 namespace keyboard { |
| 16 namespace { |
| 17 |
| 18 class KeyboardControllerTest : public testing::Test { |
| 19 public: |
| 20 KeyboardControllerTest() {} |
| 21 virtual ~KeyboardControllerTest() {} |
| 22 |
| 23 virtual void SetUp() OVERRIDE { |
| 24 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); |
| 25 aura_test_helper_->SetUp(); |
| 26 } |
| 27 |
| 28 virtual void TearDown() OVERRIDE { |
| 29 aura_test_helper_->TearDown(); |
| 30 } |
| 31 |
| 32 protected: |
| 33 base::MessageLoopForUI message_loop_; |
| 34 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; |
| 35 |
| 36 private: |
| 37 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerTest); |
| 38 }; |
| 39 |
| 40 class TestKeyboardControllerProxy : public KeyboardControllerProxy { |
| 41 public: |
| 42 TestKeyboardControllerProxy() : window_(new aura::Window(NULL)) { |
| 43 window_->Init(ui::LAYER_NOT_DRAWN); |
| 44 window_->set_owned_by_parent(false); |
| 45 } |
| 46 virtual ~TestKeyboardControllerProxy() {} |
| 47 virtual aura::Window* GetKeyboardWindow() OVERRIDE { return window_.get(); } |
| 48 |
| 49 private: |
| 50 scoped_ptr<aura::Window> window_; |
| 51 DISALLOW_COPY_AND_ASSIGN(TestKeyboardControllerProxy); |
| 52 }; |
| 53 |
| 54 } // namespace |
| 55 |
| 56 TEST_F(KeyboardControllerTest, KeyboardSize) { |
| 57 KeyboardControllerProxy* proxy = new TestKeyboardControllerProxy(); |
| 58 KeyboardController controller(proxy); |
| 59 |
| 60 scoped_ptr<aura::Window> container(controller.GetContainerWindow()); |
| 61 gfx::Rect bounds(0, 0, 100, 100); |
| 62 container->SetBounds(bounds); |
| 63 |
| 64 const gfx::Rect& before_bounds = proxy->GetKeyboardWindow()->bounds(); |
| 65 gfx::Rect new_bounds( |
| 66 before_bounds.x(), before_bounds.y(), |
| 67 before_bounds.width() / 2, before_bounds.height() / 2); |
| 68 |
| 69 // The KeyboardController's LayoutManager shouldn't let this happen |
| 70 proxy->GetKeyboardWindow()->SetBounds(new_bounds); |
| 71 ASSERT_EQ(before_bounds, proxy->GetKeyboardWindow()->bounds()); |
| 72 } |
| 73 |
| 74 } // namespace keyboard |
OLD | NEW |