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

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

Issue 8538017: Fix WindowTest.Transform, and also make it run on Windows. Some of it (the bits that rely on wind... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | « no previous file | ui/aura_shell/desktop_event_filter_unittest.cc » ('j') | 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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 EXPECT_FALSE(w2->IsActive()); 683 EXPECT_FALSE(w2->IsActive());
684 EXPECT_EQ(w1.get(), parent->children()[1]); 684 EXPECT_EQ(w1.get(), parent->children()[1]);
685 685
686 // Deactivate w1 and make sure w2 becomes active and frontmost. 686 // Deactivate w1 and make sure w2 becomes active and frontmost.
687 w1->Deactivate(); 687 w1->Deactivate();
688 EXPECT_FALSE(w1->IsActive()); 688 EXPECT_FALSE(w1->IsActive());
689 EXPECT_TRUE(w2->IsActive()); 689 EXPECT_TRUE(w2->IsActive());
690 EXPECT_EQ(w2.get(), parent->children()[1]); 690 EXPECT_EQ(w2.get(), parent->children()[1]);
691 } 691 }
692 692
693 #if !defined(OS_WIN)
694 // Tests transformation on the desktop. 693 // Tests transformation on the desktop.
695 TEST_F(WindowTest, Transform) { 694 TEST_F(WindowTest, Transform) {
696 Desktop* desktop = Desktop::GetInstance(); 695 Desktop* desktop = Desktop::GetInstance();
697 desktop->ShowDesktop();
698 gfx::Size size = desktop->GetHostSize(); 696 gfx::Size size = desktop->GetHostSize();
699 EXPECT_EQ(gfx::Rect(size), 697 EXPECT_EQ(gfx::Rect(size),
700 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point())); 698 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point()));
701 699
702 // Rotate it clock-wise 90 degrees. 700 // Rotate it clock-wise 90 degrees.
703 ui::Transform transform; 701 ui::Transform transform;
704 transform.SetRotate(90.0f); 702 transform.SetRotate(90.0f);
705 transform.ConcatTranslate(size.width(), 0); 703 transform.ConcatTranslate(size.width(), 0);
706 desktop->SetTransform(transform); 704 desktop->SetTransform(transform);
707 705
708 // The size should be the transformed size. 706 // The size should be the transformed size.
709 gfx::Size transformed_size(size.height(), size.width()); 707 gfx::Size transformed_size(size.height(), size.width());
710 EXPECT_EQ(transformed_size.ToString(), desktop->GetHostSize().ToString()); 708 EXPECT_EQ(transformed_size.ToString(), desktop->GetHostSize().ToString());
711 EXPECT_EQ(gfx::Rect(transformed_size).ToString(), 709 EXPECT_EQ(gfx::Rect(transformed_size).ToString(),
712 desktop->bounds().ToString()); 710 desktop->bounds().ToString());
713 EXPECT_EQ(gfx::Rect(transformed_size).ToString(), 711 EXPECT_EQ(gfx::Rect(transformed_size).ToString(),
714 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point()).ToString()); 712 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point()).ToString());
715
716 ActivateWindowDelegate d1;
717 scoped_ptr<Window> w1(
718 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(0, 10, 50, 50), NULL));
719 w1->Show();
720
721 gfx::Point miss_point(5, 5);
722 transform.TransformPoint(miss_point);
723 MouseEvent mouseev1(ui::ET_MOUSE_PRESSED,
724 miss_point,
725 ui::EF_LEFT_BUTTON_DOWN);
726 desktop->DispatchMouseEvent(&mouseev1);
727 EXPECT_FALSE(w1->GetFocusManager()->GetFocusedWindow());
728 MouseEvent mouseup(ui::ET_MOUSE_RELEASED,
729 miss_point,
730 ui::EF_LEFT_BUTTON_DOWN);
731 desktop->DispatchMouseEvent(&mouseup);
732
733 gfx::Point hit_point(5, 15);
734 transform.TransformPoint(hit_point);
735 MouseEvent mouseev2(ui::ET_MOUSE_PRESSED,
736 hit_point,
737 ui::EF_LEFT_BUTTON_DOWN);
738 desktop->DispatchMouseEvent(&mouseev2);
739 EXPECT_EQ(w1.get(), desktop->active_window());
740 EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow());
741 } 713 }
742 #endif
743 714
744 // Various assertions for transient children. 715 // Various assertions for transient children.
745 TEST_F(WindowTest, TransientChildren) { 716 TEST_F(WindowTest, TransientChildren) {
746 scoped_ptr<Window> parent(CreateTestWindowWithId(0, NULL)); 717 scoped_ptr<Window> parent(CreateTestWindowWithId(0, NULL));
747 scoped_ptr<Window> w1(CreateTestWindowWithId(1, parent.get())); 718 scoped_ptr<Window> w1(CreateTestWindowWithId(1, parent.get()));
748 scoped_ptr<Window> w3(CreateTestWindowWithId(3, parent.get())); 719 scoped_ptr<Window> w3(CreateTestWindowWithId(3, parent.get()));
749 Window* w2 = CreateTestWindowWithId(2, parent.get()); 720 Window* w2 = CreateTestWindowWithId(2, parent.get());
750 w1->AddTransientChild(w2); // w2 is now owned by w1. 721 w1->AddTransientChild(w2); // w2 is now owned by w1.
751 // Move w1 to the front (end), this should force w2 to be last (on top of w1). 722 // Move w1 to the front (end), this should force w2 to be last (on top of w1).
752 parent->MoveChildToFront(w1.get()); 723 parent->MoveChildToFront(w1.get());
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 1051
1081 w3->Activate(); 1052 w3->Activate();
1082 EXPECT_EQ(w2.get(), active()); 1053 EXPECT_EQ(w2.get(), active());
1083 1054
1084 w1->Activate(); 1055 w1->Activate();
1085 EXPECT_EQ(w1.get(), active()); 1056 EXPECT_EQ(w1.get(), active());
1086 } 1057 }
1087 1058
1088 } // namespace test 1059 } // namespace test
1089 } // namespace aura 1060 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/aura_shell/desktop_event_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698