Chromium Code Reviews| 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 private: | |
| 49 scoped_ptr<aura::Window> window_; | |
|
sadrul
2013/04/04 22:08:25
DISALLOW_COPY...
bryeung
2013/04/05 12:29:38
Good catch. Thanks.
| |
| 50 }; | |
| 51 | |
| 52 } // namespace | |
| 53 | |
| 54 TEST_F(KeyboardControllerTest, KeyboardSize) { | |
| 55 KeyboardControllerProxy* proxy = new TestKeyboardControllerProxy(); | |
| 56 KeyboardController controller(proxy); | |
| 57 | |
| 58 scoped_ptr<aura::Window> container(controller.GetContainerWindow()); | |
| 59 gfx::Rect bounds(0, 0, 100, 100); | |
| 60 container->SetBounds(bounds); | |
| 61 | |
| 62 const gfx::Rect& before_bounds = proxy->GetKeyboardWindow()->bounds(); | |
| 63 gfx::Rect new_bounds( | |
| 64 before_bounds.x(), before_bounds.y(), | |
| 65 before_bounds.width() / 2, before_bounds.height() / 2); | |
| 66 | |
| 67 // The KeyboardController's LayoutManager shouldn't let this happen | |
| 68 proxy->GetKeyboardWindow()->SetBounds(new_bounds); | |
| 69 ASSERT_EQ(before_bounds, proxy->GetKeyboardWindow()->bounds()); | |
| 70 } | |
| 71 | |
| 72 } // namespace keyboard | |
| OLD | NEW |