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

Side by Side Diff: ash/wm/workspace/workspace_window_resizer_unittest.cc

Issue 10948020: Convert native mouse locations to the locations in screen coordinate in RootWindowHostLinux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
OLDNEW
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 "ash/wm/workspace/workspace_window_resizer.h" 5 #include "ash/wm/workspace/workspace_window_resizer.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/display/mouse_cursor_event_filter.h" 8 #include "ash/display/mouse_cursor_event_filter.h"
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 487 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
488 { 488 {
489 // Grab (0, 0) of the window. 489 // Grab (0, 0) of the window.
490 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 490 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
491 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); 491 window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
492 ASSERT_TRUE(resizer.get()); 492 ASSERT_TRUE(resizer.get());
493 // Drag the pointer to the right. Once it reaches the right edge of the 493 // Drag the pointer to the right. Once it reaches the right edge of the
494 // primary display, it warps to the secondary. Since the secondary root 494 // primary display, it warps to the secondary. Since the secondary root
495 // window's native origin held by aura::RootWindowHost is (0, 600), and a 495 // window's native origin held by aura::RootWindowHost is (0, 600), and a
496 // mouse drag event has a location in the primary root window's coordinates, 496 // mouse drag event has a location in the primary root window's coordinates,
497 // (0, 610) below means (0, 10) in the second root window's coordinates. 497 // (810, 0) right means (10, 0) in the second root window's coordinates.
498 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); 498 resizer->Drag(CalculateDragPoint(*resizer, 810, 0), 0);
499 resizer->CompleteDrag(0); 499 resizer->CompleteDrag(0);
500 // The whole window is on the secondary display now. The parent should be 500 // The whole window is on the secondary display now. The parent should be
501 // changed. 501 // changed.
502 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 502 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
503 EXPECT_EQ("0,10 50x60", window_->bounds().ToString()); 503 EXPECT_EQ("10,0 50x60", window_->bounds().ToString());
504 } 504 }
505 505
506 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 506 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
507 gfx::Screen::GetPrimaryDisplay()); 507 gfx::Screen::GetPrimaryDisplay());
508 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 508 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
509 { 509 {
510 // Grab (0, 0) of the window and move the pointer to (790, 10). 510 // Grab (0, 0) of the window and move the pointer to (790, 10).
511 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 511 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
512 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); 512 window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
513 ASSERT_TRUE(resizer.get()); 513 ASSERT_TRUE(resizer.get());
514 resizer->Drag(CalculateDragPoint(*resizer, 790, 10), 0); 514 resizer->Drag(CalculateDragPoint(*resizer, 790, 10), 0);
515 resizer->CompleteDrag(0); 515 resizer->CompleteDrag(0);
516 // Since the pointer is still on the primary root window, the parent should 516 // Since the pointer is still on the primary root window, the parent should
517 // not be changed. 517 // not be changed.
518 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 518 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
519 EXPECT_EQ("790,10 50x60", window_->bounds().ToString()); 519 EXPECT_EQ("790,10 50x60", window_->bounds().ToString());
520 } 520 }
521 521
522 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 522 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
523 gfx::Screen::GetPrimaryDisplay()); 523 gfx::Screen::GetPrimaryDisplay());
524 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 524 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
525 { 525 {
526 // Grab the top-right edge of the window and move the pointer to (0, 10) 526 // Grab the top-right edge of the window and move the pointer to (0, 10)
527 // in the secondary root window's coordinates. 527 // in the secondary root window's coordinates.
528 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 528 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
529 window_.get(), gfx::Point(49, 0), HTCAPTION, empty_windows())); 529 window_.get(), gfx::Point(49, 0), HTCAPTION, empty_windows()));
530 ASSERT_TRUE(resizer.get()); 530 ASSERT_TRUE(resizer.get());
531 resizer->Drag(CalculateDragPoint(*resizer, -49, 610), ui::EF_CONTROL_DOWN); 531 resizer->Drag(CalculateDragPoint(*resizer, -49 + 800, 0),
532 ui::EF_CONTROL_DOWN);
532 resizer->CompleteDrag(0); 533 resizer->CompleteDrag(0);
533 // Since the pointer is on the secondary, the parent should not be changed 534 // Since the pointer is on the secondary, the parent should not be changed
534 // even though only small fraction of the window is within the secondary 535 // even though only small fraction of the window is within the secondary
535 // root window's bounds. 536 // root window's bounds.
536 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 537 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
537 EXPECT_EQ("-49,10 50x60", window_->bounds().ToString()); 538 EXPECT_EQ("-49,0 50x60", window_->bounds().ToString());
538 } 539 }
539 } 540 }
540 541
541 // Verifies a window can be moved from the secondary display to primary. 542 // Verifies a window can be moved from the secondary display to primary.
542 TEST_F(WorkspaceWindowResizerTest, 543 TEST_F(WorkspaceWindowResizerTest,
543 MAYBE_WindowDragWithMultiDisplaysRightToLeft) { 544 MAYBE_WindowDragWithMultiDisplaysRightToLeft) {
544 UpdateDisplay("800x600,800x600"); 545 UpdateDisplay("800x600,800x600");
545 Shell::GetInstance()->shelf()->LayoutShelf(); 546 Shell::GetInstance()->shelf()->LayoutShelf();
546 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 547 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
547 ASSERT_EQ(2U, root_windows.size()); 548 ASSERT_EQ(2U, root_windows.size());
548 549
549 window_->SetBoundsInScreen( 550 window_->SetBoundsInScreen(
550 gfx::Rect(800, 00, 50, 60), 551 gfx::Rect(800, 00, 50, 60),
551 gfx::Screen::GetDisplayNearestWindow(root_windows[1])); 552 gfx::Screen::GetDisplayNearestWindow(root_windows[1]));
552 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 553 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
553 { 554 {
554 // Grab (0, 0) of the window. 555 // Grab (0, 0) of the window.
555 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 556 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
556 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); 557 window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
557 ASSERT_TRUE(resizer.get()); 558 ASSERT_TRUE(resizer.get());
558 // Move the mouse near the right edge, (798, 0), of the primary display. 559 // Move the mouse near the right edge, (798, 0), of the primary display.
559 resizer->Drag(CalculateDragPoint(*resizer, 798, -600), ui::EF_CONTROL_DOWN); 560 resizer->Drag(CalculateDragPoint(*resizer, -2, 0),
561 ui::EF_CONTROL_DOWN);
560 resizer->CompleteDrag(0); 562 resizer->CompleteDrag(0);
561 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 563 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
562 EXPECT_EQ("798,0 50x60", window_->bounds().ToString()); 564 EXPECT_EQ("798,0 50x60", window_->bounds().ToString());
563 } 565 }
564 } 566 }
565 567
566 // Verifies the style of the drag phantom window is correct. 568 // Verifies the style of the drag phantom window is correct.
567 TEST_F(WorkspaceWindowResizerTest, MAYBE_PhantomStyle) { 569 TEST_F(WorkspaceWindowResizerTest, MAYBE_PhantomStyle) {
568 UpdateDisplay("800x600,800x600"); 570 UpdateDisplay("800x600,800x600");
569 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 571 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
(...skipping 28 matching lines...) Expand all
598 controller->phantom_widget_->GetNativeWindow()->layer()->children(); 600 controller->phantom_widget_->GetNativeWindow()->layer()->children();
599 EXPECT_FALSE(layers.empty()); 601 EXPECT_FALSE(layers.empty());
600 EXPECT_EQ(resizer->layer_, layers.back()); 602 EXPECT_EQ(resizer->layer_, layers.back());
601 603
602 // |window_| should be opaque since the pointer is still on the primary 604 // |window_| should be opaque since the pointer is still on the primary
603 // root window. The phantom should be semi-transparent. 605 // root window. The phantom should be semi-transparent.
604 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 606 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
605 EXPECT_GT(1.0f, controller->GetOpacity()); 607 EXPECT_GT(1.0f, controller->GetOpacity());
606 608
607 // Enter the pointer to the secondary display. 609 // Enter the pointer to the secondary display.
608 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); 610 resizer->Drag(CalculateDragPoint(*resizer, 810, 0), 0);
609 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); 611 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get());
610 controller = resizer->drag_phantom_window_controller_.get(); 612 controller = resizer->drag_phantom_window_controller_.get();
611 ASSERT_TRUE(controller); 613 ASSERT_TRUE(controller);
612 EXPECT_EQ(PhantomWindowController::STYLE_DRAGGING, controller->style()); 614 EXPECT_EQ(PhantomWindowController::STYLE_DRAGGING, controller->style());
613 // |window_| should be transparent, and the phantom should be opaque. 615 // |window_| should be transparent, and the phantom should be opaque.
614 EXPECT_GT(1.0f, window_->layer()->opacity()); 616 EXPECT_GT(1.0f, window_->layer()->opacity());
615 EXPECT_FLOAT_EQ(1.0f, controller->GetOpacity()); 617 EXPECT_FLOAT_EQ(1.0f, controller->GetOpacity());
616 618
617 resizer->CompleteDrag(0); 619 resizer->CompleteDrag(0);
618 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 620 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); 1005 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0);
1004 EXPECT_EQ("152,130 20x30", window_->bounds().ToString()); 1006 EXPECT_EQ("152,130 20x30", window_->bounds().ToString());
1005 1007
1006 // Move |window| one pixel above the bottom of |window2|. 1008 // Move |window| one pixel above the bottom of |window2|.
1007 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); 1009 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0);
1008 EXPECT_EQ("152,180 20x30", window_->bounds().ToString()); 1010 EXPECT_EQ("152,180 20x30", window_->bounds().ToString());
1009 } 1011 }
1010 1012
1011 } // namespace internal 1013 } // namespace internal
1012 } // namespace ash 1014 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698