| 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 "ash/magnifier/magnification_controller.h" | 5 #include "ash/magnifier/magnification_controller.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 const int kTextInputWindowHeight = 50; | 32 const int kTextInputWindowHeight = 50; |
| 33 | 33 |
| 34 class TextInputView : public views::WidgetDelegateView { | 34 class TextInputView : public views::WidgetDelegateView { |
| 35 public: | 35 public: |
| 36 TextInputView() : text_field_(new views::Textfield) { | 36 TextInputView() : text_field_(new views::Textfield) { |
| 37 text_field_->SetTextInputType(ui::TEXT_INPUT_TYPE_TEXT); | 37 text_field_->SetTextInputType(ui::TEXT_INPUT_TYPE_TEXT); |
| 38 AddChildView(text_field_); | 38 AddChildView(text_field_); |
| 39 SetLayoutManager(new views::FillLayout); | 39 SetLayoutManager(new views::FillLayout); |
| 40 } | 40 } |
| 41 | 41 |
| 42 virtual ~TextInputView() {} | 42 ~TextInputView() override {} |
| 43 | 43 |
| 44 virtual gfx::Size GetPreferredSize() const override { | 44 gfx::Size GetPreferredSize() const override { |
| 45 return gfx::Size(kTextInputWindowWidth, kTextInputWindowHeight); | 45 return gfx::Size(kTextInputWindowWidth, kTextInputWindowHeight); |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Overridden from views::WidgetDelegate: | 48 // Overridden from views::WidgetDelegate: |
| 49 virtual views::View* GetContentsView() override { return this; } | 49 views::View* GetContentsView() override { return this; } |
| 50 | 50 |
| 51 void FocusOnTextInput() { GetFocusManager()->SetFocusedView(text_field_); } | 51 void FocusOnTextInput() { GetFocusManager()->SetFocusedView(text_field_); } |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 views::Textfield* text_field_; // owned by views hierarchy | 54 views::Textfield* text_field_; // owned by views hierarchy |
| 55 | 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(TextInputView); | 56 DISALLOW_COPY_AND_ASSIGN(TextInputView); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 61 class MagnificationControllerTest: public test::AshTestBase { | 61 class MagnificationControllerTest: public test::AshTestBase { |
| 62 public: | 62 public: |
| 63 MagnificationControllerTest() : text_input_view_(NULL) {} | 63 MagnificationControllerTest() : text_input_view_(NULL) {} |
| 64 virtual ~MagnificationControllerTest() {} | 64 ~MagnificationControllerTest() override {} |
| 65 | 65 |
| 66 virtual void SetUp() override { | 66 void SetUp() override { |
| 67 AshTestBase::SetUp(); | 67 AshTestBase::SetUp(); |
| 68 UpdateDisplay(base::StringPrintf("%dx%d", kRootWidth, kRootHeight)); | 68 UpdateDisplay(base::StringPrintf("%dx%d", kRootWidth, kRootHeight)); |
| 69 | 69 |
| 70 aura::Window* root = GetRootWindow(); | 70 aura::Window* root = GetRootWindow(); |
| 71 gfx::Rect root_bounds(root->bounds()); | 71 gfx::Rect root_bounds(root->bounds()); |
| 72 | 72 |
| 73 #if defined(OS_WIN) | 73 #if defined(OS_WIN) |
| 74 // RootWindow and Display can't resize on Windows Ash. | 74 // RootWindow and Display can't resize on Windows Ash. |
| 75 // http://crbug.com/165962 | 75 // http://crbug.com/165962 |
| 76 EXPECT_EQ(kRootHeight, root_bounds.height()); | 76 EXPECT_EQ(kRootHeight, root_bounds.height()); |
| 77 EXPECT_EQ(kRootWidth, root_bounds.width()); | 77 EXPECT_EQ(kRootWidth, root_bounds.width()); |
| 78 #endif | 78 #endif |
| 79 } | 79 } |
| 80 | 80 |
| 81 virtual void TearDown() override { | 81 void TearDown() override { AshTestBase::TearDown(); } |
| 82 AshTestBase::TearDown(); | |
| 83 } | |
| 84 | 82 |
| 85 protected: | 83 protected: |
| 86 aura::Window* GetRootWindow() const { | 84 aura::Window* GetRootWindow() const { |
| 87 return Shell::GetPrimaryRootWindow(); | 85 return Shell::GetPrimaryRootWindow(); |
| 88 } | 86 } |
| 89 | 87 |
| 90 std::string GetHostMouseLocation() { | 88 std::string GetHostMouseLocation() { |
| 91 const gfx::Point& location = | 89 const gfx::Point& location = |
| 92 aura::test::QueryLatestMousePositionRequestInHost( | 90 aura::test::QueryLatestMousePositionRequestInHost( |
| 93 GetRootWindow()->GetHost()); | 91 GetRootWindow()->GetHost()); |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 gfx::Rect caret_bounds = GetCaretBounds(); | 576 gfx::Rect caret_bounds = GetCaretBounds(); |
| 579 EXPECT_FALSE(view_port.Intersects(caret_bounds)); | 577 EXPECT_FALSE(view_port.Intersects(caret_bounds)); |
| 580 | 578 |
| 581 gfx::Rect new_view_port = GetViewport(); | 579 gfx::Rect new_view_port = GetViewport(); |
| 582 EXPECT_TRUE(new_view_port.Contains(caret_bounds)); | 580 EXPECT_TRUE(new_view_port.Contains(caret_bounds)); |
| 583 EXPECT_EQ(caret_bounds.x(), new_view_port.CenterPoint().x()); | 581 EXPECT_EQ(caret_bounds.x(), new_view_port.CenterPoint().x()); |
| 584 EXPECT_EQ(view_port.y(), new_view_port.y()); | 582 EXPECT_EQ(view_port.y(), new_view_port.y()); |
| 585 } | 583 } |
| 586 | 584 |
| 587 } // namespace ash | 585 } // namespace ash |
| OLD | NEW |