OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 EXPECT_TRUE(root->IsOrContainsFullscreenWindow()); | 940 EXPECT_TRUE(root->IsOrContainsFullscreenWindow()); |
941 | 941 |
942 w11->Hide(); | 942 w11->Hide(); |
943 EXPECT_FALSE(root->IsOrContainsFullscreenWindow()); | 943 EXPECT_FALSE(root->IsOrContainsFullscreenWindow()); |
944 } | 944 } |
945 | 945 |
946 #if !defined(OS_WIN) | 946 #if !defined(OS_WIN) |
947 // Tests transformation on the desktop. | 947 // Tests transformation on the desktop. |
948 TEST_F(WindowTest, Transform) { | 948 TEST_F(WindowTest, Transform) { |
949 Desktop* desktop = Desktop::GetInstance(); | 949 Desktop* desktop = Desktop::GetInstance(); |
950 gfx::Size size(200, 300); | |
951 desktop->SetHostSize(size); | |
952 desktop->ShowDesktop(); | 950 desktop->ShowDesktop(); |
953 | 951 gfx::Size size = desktop->GetHostSize(); |
954 EXPECT_EQ(gfx::Rect(size), gfx::Rect(desktop->GetHostSize())); | |
955 EXPECT_EQ(gfx::Rect(size), | 952 EXPECT_EQ(gfx::Rect(size), |
956 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point())); | 953 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point())); |
957 | 954 |
958 // Rotate it clock-wise 90 degrees. | 955 // Rotate it clock-wise 90 degrees. |
959 ui::Transform transform; | 956 ui::Transform transform; |
960 transform.SetRotate(90.0f); | 957 transform.SetRotate(90.0f); |
961 transform.ConcatTranslate(size.width(), 0); | 958 transform.ConcatTranslate(size.width(), 0); |
962 desktop->SetTransform(transform); | 959 desktop->SetTransform(transform); |
963 | 960 |
964 // The size should be the transformed size. | 961 // The size should be the transformed size. |
965 EXPECT_EQ(gfx::Rect(0, 0, 300, 200), gfx::Rect(desktop->GetHostSize())); | 962 gfx::Size transformed_size(size.height(), size.width()); |
966 EXPECT_EQ(gfx::Rect(0, 0, 300, 200), desktop->bounds()); | 963 EXPECT_EQ(transformed_size.ToString(), desktop->GetHostSize().ToString()); |
967 EXPECT_EQ(gfx::Rect(0, 0, 300, 200), | 964 EXPECT_EQ(gfx::Rect(gfx::Point(), transformed_size).ToString(), |
968 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point())); | 965 desktop->bounds().ToString()); |
| 966 EXPECT_EQ(gfx::Rect(gfx::Point(), transformed_size).ToString(), |
| 967 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point()).ToString()); |
969 | 968 |
970 ActivateWindowDelegate d1; | 969 ActivateWindowDelegate d1; |
971 scoped_ptr<Window> w1( | 970 scoped_ptr<Window> w1( |
972 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(0, 10, 50, 50), NULL)); | 971 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(0, 10, 50, 50), NULL)); |
973 w1->Show(); | 972 w1->Show(); |
974 | 973 |
| 974 gfx::Point miss_point(5, 5); |
| 975 transform.TransformPoint(miss_point); |
975 MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, | 976 MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, |
976 gfx::Point(195, 5), ui::EF_LEFT_BUTTON_DOWN); | 977 miss_point, |
| 978 ui::EF_LEFT_BUTTON_DOWN); |
977 desktop->DispatchMouseEvent(&mouseev1); | 979 desktop->DispatchMouseEvent(&mouseev1); |
978 EXPECT_FALSE(w1->GetFocusManager()->GetFocusedWindow()); | 980 EXPECT_FALSE(w1->GetFocusManager()->GetFocusedWindow()); |
979 MouseEvent mouseup(ui::ET_MOUSE_RELEASED, | 981 MouseEvent mouseup(ui::ET_MOUSE_RELEASED, |
980 gfx::Point(195, 5), ui::EF_LEFT_BUTTON_DOWN); | 982 miss_point, |
| 983 ui::EF_LEFT_BUTTON_DOWN); |
981 desktop->DispatchMouseEvent(&mouseup); | 984 desktop->DispatchMouseEvent(&mouseup); |
982 | 985 |
| 986 gfx::Point hit_point(5, 15); |
| 987 transform.TransformPoint(hit_point); |
983 MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, | 988 MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, |
984 gfx::Point(185, 5), ui::EF_LEFT_BUTTON_DOWN); | 989 hit_point, |
| 990 ui::EF_LEFT_BUTTON_DOWN); |
985 desktop->DispatchMouseEvent(&mouseev2); | 991 desktop->DispatchMouseEvent(&mouseev2); |
986 EXPECT_EQ(w1.get(), desktop->active_window()); | 992 EXPECT_EQ(w1.get(), desktop->active_window()); |
987 EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow()); | 993 EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow()); |
988 } | 994 } |
989 #endif | 995 #endif |
990 | 996 |
991 class ToplevelWindowTest : public WindowTest { | 997 class ToplevelWindowTest : public WindowTest { |
992 public: | 998 public: |
993 ToplevelWindowTest() {} | 999 ToplevelWindowTest() {} |
994 virtual ~ToplevelWindowTest() {} | 1000 virtual ~ToplevelWindowTest() {} |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 | 1200 |
1195 w3->Activate(); | 1201 w3->Activate(); |
1196 EXPECT_EQ(w2.get(), active()); | 1202 EXPECT_EQ(w2.get(), active()); |
1197 | 1203 |
1198 w1->Activate(); | 1204 w1->Activate(); |
1199 EXPECT_EQ(w1.get(), active()); | 1205 EXPECT_EQ(w1.get(), active()); |
1200 } | 1206 } |
1201 | 1207 |
1202 } // namespace test | 1208 } // namespace test |
1203 } // namespace aura | 1209 } // namespace aura |
OLD | NEW |