| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
| 6 | 6 |
| 7 #include "ash/session/session_state_delegate.h" | 7 #include "ash/session/session_state_delegate.h" |
| 8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 namespace ash { | 45 namespace ash { |
| 46 namespace { | 46 namespace { |
| 47 | 47 |
| 48 class TestDelegate : public views::WidgetDelegateView { | 48 class TestDelegate : public views::WidgetDelegateView { |
| 49 public: | 49 public: |
| 50 explicit TestDelegate(bool system_modal) : system_modal_(system_modal) {} | 50 explicit TestDelegate(bool system_modal) : system_modal_(system_modal) {} |
| 51 virtual ~TestDelegate() {} | 51 virtual ~TestDelegate() {} |
| 52 | 52 |
| 53 // Overridden from views::WidgetDelegate: | 53 // Overridden from views::WidgetDelegate: |
| 54 virtual views::View* GetContentsView() OVERRIDE { | 54 virtual views::View* GetContentsView() override { |
| 55 return this; | 55 return this; |
| 56 } | 56 } |
| 57 | 57 |
| 58 virtual ui::ModalType GetModalType() const OVERRIDE { | 58 virtual ui::ModalType GetModalType() const override { |
| 59 return system_modal_ ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE; | 59 return system_modal_ ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE; |
| 60 } | 60 } |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 bool system_modal_; | 63 bool system_modal_; |
| 64 | 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(TestDelegate); | 65 DISALLOW_COPY_AND_ASSIGN(TestDelegate); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class DeleteOnBlurDelegate : public aura::test::TestWindowDelegate, | 68 class DeleteOnBlurDelegate : public aura::test::TestWindowDelegate, |
| 69 public aura::client::FocusChangeObserver { | 69 public aura::client::FocusChangeObserver { |
| 70 public: | 70 public: |
| 71 DeleteOnBlurDelegate() : window_(NULL) {} | 71 DeleteOnBlurDelegate() : window_(NULL) {} |
| 72 virtual ~DeleteOnBlurDelegate() {} | 72 virtual ~DeleteOnBlurDelegate() {} |
| 73 | 73 |
| 74 void SetWindow(aura::Window* window) { | 74 void SetWindow(aura::Window* window) { |
| 75 window_ = window; | 75 window_ = window; |
| 76 aura::client::SetFocusChangeObserver(window_, this); | 76 aura::client::SetFocusChangeObserver(window_, this); |
| 77 } | 77 } |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 // aura::test::TestWindowDelegate overrides: | 80 // aura::test::TestWindowDelegate overrides: |
| 81 virtual bool CanFocus() OVERRIDE { | 81 virtual bool CanFocus() override { |
| 82 return true; | 82 return true; |
| 83 } | 83 } |
| 84 | 84 |
| 85 // aura::client::FocusChangeObserver implementation: | 85 // aura::client::FocusChangeObserver implementation: |
| 86 virtual void OnWindowFocused(aura::Window* gained_focus, | 86 virtual void OnWindowFocused(aura::Window* gained_focus, |
| 87 aura::Window* lost_focus) OVERRIDE { | 87 aura::Window* lost_focus) override { |
| 88 if (window_ == lost_focus) | 88 if (window_ == lost_focus) |
| 89 delete window_; | 89 delete window_; |
| 90 } | 90 } |
| 91 | 91 |
| 92 aura::Window* window_; | 92 aura::Window* window_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(DeleteOnBlurDelegate); | 94 DISALLOW_COPY_AND_ASSIGN(DeleteOnBlurDelegate); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace | 97 } // namespace |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 } | 531 } |
| 532 | 532 |
| 533 void SetWindow(Window* window) { | 533 void SetWindow(Window* window) { |
| 534 window_ = window; | 534 window_ = window; |
| 535 window->AddObserver(this); | 535 window->AddObserver(this); |
| 536 } | 536 } |
| 537 | 537 |
| 538 bool destroyed() const { return destroyed_; } | 538 bool destroyed() const { return destroyed_; } |
| 539 | 539 |
| 540 // WindowObserver overrides: | 540 // WindowObserver overrides: |
| 541 virtual void OnWindowDestroying(Window* window) OVERRIDE { | 541 virtual void OnWindowDestroying(Window* window) override { |
| 542 destroyed_ = true; | 542 destroyed_ = true; |
| 543 Shutdown(); | 543 Shutdown(); |
| 544 } | 544 } |
| 545 | 545 |
| 546 private: | 546 private: |
| 547 void Shutdown() { | 547 void Shutdown() { |
| 548 if (!window_) | 548 if (!window_) |
| 549 return; | 549 return; |
| 550 window_->RemoveObserver(this); | 550 window_->RemoveObserver(this); |
| 551 window_ = NULL; | 551 window_ = NULL; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 root->GetEventHandlerForPoint( | 610 root->GetEventHandlerForPoint( |
| 611 gfx::Point(size.width() - 1, size.height() - 1))); | 611 gfx::Point(size.width() - 1, size.height() - 1))); |
| 612 } | 612 } |
| 613 | 613 |
| 614 class VirtualKeyboardRootWindowControllerTest | 614 class VirtualKeyboardRootWindowControllerTest |
| 615 : public RootWindowControllerTest { | 615 : public RootWindowControllerTest { |
| 616 public: | 616 public: |
| 617 VirtualKeyboardRootWindowControllerTest() {}; | 617 VirtualKeyboardRootWindowControllerTest() {}; |
| 618 virtual ~VirtualKeyboardRootWindowControllerTest() {}; | 618 virtual ~VirtualKeyboardRootWindowControllerTest() {}; |
| 619 | 619 |
| 620 virtual void SetUp() OVERRIDE { | 620 virtual void SetUp() override { |
| 621 CommandLine::ForCurrentProcess()->AppendSwitch( | 621 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 622 keyboard::switches::kEnableVirtualKeyboard); | 622 keyboard::switches::kEnableVirtualKeyboard); |
| 623 test::AshTestBase::SetUp(); | 623 test::AshTestBase::SetUp(); |
| 624 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( | 624 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( |
| 625 keyboard::KeyboardController::GetInstance()); | 625 keyboard::KeyboardController::GetInstance()); |
| 626 } | 626 } |
| 627 | 627 |
| 628 private: | 628 private: |
| 629 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest); | 629 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest); |
| 630 }; | 630 }; |
| 631 | 631 |
| 632 class MockTextInputClient : public ui::DummyTextInputClient { | 632 class MockTextInputClient : public ui::DummyTextInputClient { |
| 633 public: | 633 public: |
| 634 MockTextInputClient() : | 634 MockTextInputClient() : |
| 635 ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT) {} | 635 ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT) {} |
| 636 | 636 |
| 637 virtual void EnsureCaretInRect(const gfx::Rect& rect) OVERRIDE { | 637 virtual void EnsureCaretInRect(const gfx::Rect& rect) override { |
| 638 visible_rect_ = rect; | 638 visible_rect_ = rect; |
| 639 } | 639 } |
| 640 | 640 |
| 641 const gfx::Rect& visible_rect() const { | 641 const gfx::Rect& visible_rect() const { |
| 642 return visible_rect_; | 642 return visible_rect_; |
| 643 } | 643 } |
| 644 | 644 |
| 645 private: | 645 private: |
| 646 gfx::Rect visible_rect_; | 646 gfx::Rect visible_rect_; |
| 647 | 647 |
| 648 DISALLOW_COPY_AND_ASSIGN(MockTextInputClient); | 648 DISALLOW_COPY_AND_ASSIGN(MockTextInputClient); |
| 649 }; | 649 }; |
| 650 | 650 |
| 651 class TargetHitTestEventHandler : public ui::test::TestEventHandler { | 651 class TargetHitTestEventHandler : public ui::test::TestEventHandler { |
| 652 public: | 652 public: |
| 653 TargetHitTestEventHandler() {} | 653 TargetHitTestEventHandler() {} |
| 654 | 654 |
| 655 // ui::test::TestEventHandler overrides. | 655 // ui::test::TestEventHandler overrides. |
| 656 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 656 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
| 657 if (event->type() == ui::ET_MOUSE_PRESSED) | 657 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 658 ui::test::TestEventHandler::OnMouseEvent(event); | 658 ui::test::TestEventHandler::OnMouseEvent(event); |
| 659 event->StopPropagation(); | 659 event->StopPropagation(); |
| 660 } | 660 } |
| 661 | 661 |
| 662 private: | 662 private: |
| 663 DISALLOW_COPY_AND_ASSIGN(TargetHitTestEventHandler); | 663 DISALLOW_COPY_AND_ASSIGN(TargetHitTestEventHandler); |
| 664 }; | 664 }; |
| 665 | 665 |
| 666 // Test for http://crbug.com/297858. Virtual keyboard container should only show | 666 // Test for http://crbug.com/297858. Virtual keyboard container should only show |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 ASSERT_TRUE(keyboard_container); | 961 ASSERT_TRUE(keyboard_container); |
| 962 keyboard_container->Show(); | 962 keyboard_container->Show(); |
| 963 EXPECT_EQ("0,0 800x600", keyboard_container->bounds().ToString()); | 963 EXPECT_EQ("0,0 800x600", keyboard_container->bounds().ToString()); |
| 964 | 964 |
| 965 UpdateDisplay("600x800"); | 965 UpdateDisplay("600x800"); |
| 966 EXPECT_EQ("0,0 600x800", keyboard_container->bounds().ToString()); | 966 EXPECT_EQ("0,0 600x800", keyboard_container->bounds().ToString()); |
| 967 } | 967 } |
| 968 | 968 |
| 969 } // namespace test | 969 } // namespace test |
| 970 } // namespace ash | 970 } // namespace ash |
| OLD | NEW |