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 "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 EXPECT_TRUE(window->HasCapture(ui::CW_LOCK_MOUSE)); | 754 EXPECT_TRUE(window->HasCapture(ui::CW_LOCK_MOUSE)); |
755 | 755 |
756 // Destroy the window. | 756 // Destroy the window. |
757 window.reset(); | 757 window.reset(); |
758 | 758 |
759 // Make sure the root window doesn't reference the window anymore. | 759 // Make sure the root window doesn't reference the window anymore. |
760 EXPECT_EQ(NULL, root_window()->mouse_pressed_handler()); | 760 EXPECT_EQ(NULL, root_window()->mouse_pressed_handler()); |
761 EXPECT_EQ(NULL, root_window()->capture_window()); | 761 EXPECT_EQ(NULL, root_window()->capture_window()); |
762 } | 762 } |
763 | 763 |
764 TEST_F(WindowTest, GetScreenBounds) { | 764 TEST_F(WindowTest, GetBoundsInRootWindow) { |
765 scoped_ptr<Window> viewport(CreateTestWindowWithBounds( | 765 scoped_ptr<Window> viewport(CreateTestWindowWithBounds( |
766 gfx::Rect(0, 0, 300, 300), NULL)); | 766 gfx::Rect(0, 0, 300, 300), NULL)); |
767 scoped_ptr<Window> child(CreateTestWindowWithBounds( | 767 scoped_ptr<Window> child(CreateTestWindowWithBounds( |
768 gfx::Rect(0, 0, 100, 100), viewport.get())); | 768 gfx::Rect(0, 0, 100, 100), viewport.get())); |
769 // Sanity check. | 769 // Sanity check. |
770 EXPECT_EQ("0,0 100x100", child->GetScreenBounds().ToString()); | 770 EXPECT_EQ("0,0 100x100", child->GetBoundsInRootWindow().ToString()); |
771 | 771 |
772 // The |child| window's screen bounds should move along with the |viewport|. | 772 // The |child| window's screen bounds should move along with the |viewport|. |
773 viewport->SetBounds(gfx::Rect(-100, -100, 300, 300)); | 773 viewport->SetBounds(gfx::Rect(-100, -100, 300, 300)); |
774 EXPECT_EQ("-100,-100 100x100", child->GetScreenBounds().ToString()); | 774 EXPECT_EQ("-100,-100 100x100", child->GetBoundsInRootWindow().ToString()); |
775 | 775 |
776 // The |child| window is moved to the 0,0 in screen coordinates. | 776 // The |child| window is moved to the 0,0 in screen coordinates. |
777 // |GetScreenBounds()| should return 0,0. | 777 // |GetBoundsInRootWindow()| should return 0,0. |
778 child->SetBounds(gfx::Rect(100, 100, 100, 100)); | 778 child->SetBounds(gfx::Rect(100, 100, 100, 100)); |
779 EXPECT_EQ("0,0 100x100", child->GetScreenBounds().ToString()); | 779 EXPECT_EQ("0,0 100x100", child->GetBoundsInRootWindow().ToString()); |
780 } | 780 } |
781 | 781 |
782 class MouseEnterExitWindowDelegate : public TestWindowDelegate { | 782 class MouseEnterExitWindowDelegate : public TestWindowDelegate { |
783 public: | 783 public: |
784 MouseEnterExitWindowDelegate() : entered_(false), exited_(false) {} | 784 MouseEnterExitWindowDelegate() : entered_(false), exited_(false) {} |
785 | 785 |
786 virtual bool OnMouseEvent(MouseEvent* event) OVERRIDE { | 786 virtual bool OnMouseEvent(MouseEvent* event) OVERRIDE { |
787 switch (event->type()) { | 787 switch (event->type()) { |
788 case ui::ET_MOUSE_ENTERED: | 788 case ui::ET_MOUSE_ENTERED: |
789 entered_ = true; | 789 entered_ = true; |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 w2->SetParent(w1.get()); | 1932 w2->SetParent(w1.get()); |
1933 | 1933 |
1934 w1.reset(); | 1934 w1.reset(); |
1935 | 1935 |
1936 // We should be able to deref w2 still, but its parent should now be NULL. | 1936 // We should be able to deref w2 still, but its parent should now be NULL. |
1937 EXPECT_EQ(NULL, w2->parent()); | 1937 EXPECT_EQ(NULL, w2->parent()); |
1938 } | 1938 } |
1939 | 1939 |
1940 } // namespace test | 1940 } // namespace test |
1941 } // namespace aura | 1941 } // namespace aura |
OLD | NEW |