Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(603)

Side by Side Diff: ui/aura/window_unittest.cc

Issue 8374005: aura: Try to make Linux host resize code more reliable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor cleanup Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/desktop_host_linux.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::Rect transformed_bounds(0, 0, size.height(), size.width());
966 EXPECT_EQ(gfx::Rect(0, 0, 300, 200), desktop->bounds()); 963 EXPECT_EQ(transformed_bounds.size(), desktop->GetHostSize());
967 EXPECT_EQ(gfx::Rect(0, 0, 300, 200), 964 EXPECT_EQ(transformed_bounds, desktop->bounds());
965 EXPECT_EQ(transformed_bounds,
968 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point())); 966 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point()));
oshima 2011/10/21 19:55:45 Just a suggestion. I've been using string to compa
969 967
970 ActivateWindowDelegate d1; 968 ActivateWindowDelegate d1;
971 scoped_ptr<Window> w1( 969 scoped_ptr<Window> w1(
972 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(0, 10, 50, 50), NULL)); 970 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(0, 10, 50, 50), NULL));
973 w1->Show(); 971 w1->Show();
974 972
975 MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, 973 MouseEvent mouseev1(ui::ET_MOUSE_PRESSED,
976 gfx::Point(195, 5), ui::EF_LEFT_BUTTON_DOWN); 974 gfx::Point(transformed_bounds.width() - 5, 5),
975 ui::EF_LEFT_BUTTON_DOWN);
977 desktop->DispatchMouseEvent(&mouseev1); 976 desktop->DispatchMouseEvent(&mouseev1);
978 EXPECT_FALSE(w1->GetFocusManager()->GetFocusedWindow()); 977 EXPECT_FALSE(w1->GetFocusManager()->GetFocusedWindow());
979 MouseEvent mouseup(ui::ET_MOUSE_RELEASED, 978 MouseEvent mouseup(ui::ET_MOUSE_RELEASED,
980 gfx::Point(195, 5), ui::EF_LEFT_BUTTON_DOWN); 979 gfx::Point(transformed_bounds.width() - 5, 5),
980 ui::EF_LEFT_BUTTON_DOWN);
981 desktop->DispatchMouseEvent(&mouseup); 981 desktop->DispatchMouseEvent(&mouseup);
982 982
983 MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, 983 MouseEvent mouseev2(ui::ET_MOUSE_PRESSED,
984 gfx::Point(185, 5), ui::EF_LEFT_BUTTON_DOWN); 984 gfx::Point(transformed_bounds.width() - 15, 5),
985 ui::EF_LEFT_BUTTON_DOWN);
985 desktop->DispatchMouseEvent(&mouseev2); 986 desktop->DispatchMouseEvent(&mouseev2);
986 EXPECT_EQ(w1.get(), desktop->active_window()); 987 EXPECT_EQ(w1.get(), desktop->active_window());
987 EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow()); 988 EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow());
988 } 989 }
989 #endif 990 #endif
990 991
991 class ToplevelWindowTest : public WindowTest { 992 class ToplevelWindowTest : public WindowTest {
992 public: 993 public:
993 ToplevelWindowTest() {} 994 ToplevelWindowTest() {}
994 virtual ~ToplevelWindowTest() {} 995 virtual ~ToplevelWindowTest() {}
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 1195
1195 w3->Activate(); 1196 w3->Activate();
1196 EXPECT_EQ(w2.get(), active()); 1197 EXPECT_EQ(w2.get(), active());
1197 1198
1198 w1->Activate(); 1199 w1->Activate();
1199 EXPECT_EQ(w1.get(), active()); 1200 EXPECT_EQ(w1.get(), active());
1200 } 1201 }
1201 1202
1202 } // namespace test 1203 } // namespace test
1203 } // namespace aura 1204 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/desktop_host_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698