| 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 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 EXPECT_TRUE(root->IsOrContainsFullscreenWindow()); | 962 EXPECT_TRUE(root->IsOrContainsFullscreenWindow()); |
| 963 | 963 |
| 964 w11->Hide(); | 964 w11->Hide(); |
| 965 EXPECT_FALSE(root->IsOrContainsFullscreenWindow()); | 965 EXPECT_FALSE(root->IsOrContainsFullscreenWindow()); |
| 966 } | 966 } |
| 967 | 967 |
| 968 #if !defined(OS_WIN) | 968 #if !defined(OS_WIN) |
| 969 // Tests transformation on the desktop. | 969 // Tests transformation on the desktop. |
| 970 TEST_F(WindowTest, Transform) { | 970 TEST_F(WindowTest, Transform) { |
| 971 Desktop* desktop = Desktop::GetInstance(); | 971 Desktop* desktop = Desktop::GetInstance(); |
| 972 gfx::Size size(200, 300); | |
| 973 desktop->SetHostSize(size); | |
| 974 desktop->ShowDesktop(); | 972 desktop->ShowDesktop(); |
| 975 | 973 gfx::Size size = desktop->GetHostSize(); |
| 976 EXPECT_EQ(gfx::Rect(size), gfx::Rect(desktop->GetHostSize())); | |
| 977 EXPECT_EQ(gfx::Rect(size), | 974 EXPECT_EQ(gfx::Rect(size), |
| 978 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point())); | 975 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point())); |
| 979 | 976 |
| 980 // Rotate it clock-wise 90 degrees. | 977 // Rotate it clock-wise 90 degrees. |
| 981 ui::Transform transform; | 978 ui::Transform transform; |
| 982 transform.SetRotate(90.0f); | 979 transform.SetRotate(90.0f); |
| 983 transform.ConcatTranslate(size.width(), 0); | 980 transform.ConcatTranslate(size.width(), 0); |
| 984 desktop->SetTransform(transform); | 981 desktop->SetTransform(transform); |
| 985 | 982 |
| 986 // The size should be the transformed size. | 983 // The size should be the transformed size. |
| 987 EXPECT_EQ(gfx::Rect(0, 0, 300, 200), gfx::Rect(desktop->GetHostSize())); | 984 gfx::Size transformed_size(size.height(), size.width()); |
| 988 EXPECT_EQ(gfx::Rect(0, 0, 300, 200), desktop->bounds()); | 985 EXPECT_EQ(transformed_size.ToString(), desktop->GetHostSize().ToString()); |
| 989 EXPECT_EQ(gfx::Rect(0, 0, 300, 200), | 986 EXPECT_EQ(gfx::Rect(transformed_size).ToString(), |
| 990 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point())); | 987 desktop->bounds().ToString()); |
| 988 EXPECT_EQ(gfx::Rect(transformed_size).ToString(), |
| 989 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point()).ToString()); |
| 991 | 990 |
| 992 ActivateWindowDelegate d1; | 991 ActivateWindowDelegate d1; |
| 993 scoped_ptr<Window> w1( | 992 scoped_ptr<Window> w1( |
| 994 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(0, 10, 50, 50), NULL)); | 993 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(0, 10, 50, 50), NULL)); |
| 995 w1->Show(); | 994 w1->Show(); |
| 996 | 995 |
| 996 gfx::Point miss_point(5, 5); |
| 997 transform.TransformPoint(miss_point); |
| 997 MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, | 998 MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, |
| 998 gfx::Point(195, 5), ui::EF_LEFT_BUTTON_DOWN); | 999 miss_point, |
| 1000 ui::EF_LEFT_BUTTON_DOWN); |
| 999 desktop->DispatchMouseEvent(&mouseev1); | 1001 desktop->DispatchMouseEvent(&mouseev1); |
| 1000 EXPECT_FALSE(w1->GetFocusManager()->GetFocusedWindow()); | 1002 EXPECT_FALSE(w1->GetFocusManager()->GetFocusedWindow()); |
| 1001 MouseEvent mouseup(ui::ET_MOUSE_RELEASED, | 1003 MouseEvent mouseup(ui::ET_MOUSE_RELEASED, |
| 1002 gfx::Point(195, 5), ui::EF_LEFT_BUTTON_DOWN); | 1004 miss_point, |
| 1005 ui::EF_LEFT_BUTTON_DOWN); |
| 1003 desktop->DispatchMouseEvent(&mouseup); | 1006 desktop->DispatchMouseEvent(&mouseup); |
| 1004 | 1007 |
| 1008 gfx::Point hit_point(5, 15); |
| 1009 transform.TransformPoint(hit_point); |
| 1005 MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, | 1010 MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, |
| 1006 gfx::Point(185, 5), ui::EF_LEFT_BUTTON_DOWN); | 1011 hit_point, |
| 1012 ui::EF_LEFT_BUTTON_DOWN); |
| 1007 desktop->DispatchMouseEvent(&mouseev2); | 1013 desktop->DispatchMouseEvent(&mouseev2); |
| 1008 EXPECT_EQ(w1.get(), desktop->active_window()); | 1014 EXPECT_EQ(w1.get(), desktop->active_window()); |
| 1009 EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow()); | 1015 EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow()); |
| 1010 } | 1016 } |
| 1011 #endif | 1017 #endif |
| 1012 | 1018 |
| 1013 class ToplevelWindowTest : public WindowTest { | 1019 class ToplevelWindowTest : public WindowTest { |
| 1014 public: | 1020 public: |
| 1015 ToplevelWindowTest() {} | 1021 ToplevelWindowTest() {} |
| 1016 virtual ~ToplevelWindowTest() {} | 1022 virtual ~ToplevelWindowTest() {} |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 | 1270 |
| 1265 w3->Activate(); | 1271 w3->Activate(); |
| 1266 EXPECT_EQ(w2.get(), active()); | 1272 EXPECT_EQ(w2.get(), active()); |
| 1267 | 1273 |
| 1268 w1->Activate(); | 1274 w1->Activate(); |
| 1269 EXPECT_EQ(w1.get(), active()); | 1275 EXPECT_EQ(w1.get(), active()); |
| 1270 } | 1276 } |
| 1271 | 1277 |
| 1272 } // namespace test | 1278 } // namespace test |
| 1273 } // namespace aura | 1279 } // namespace aura |
| OLD | NEW |