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

Side by Side Diff: components/exo/shell_surface_unittest.cc

Issue 2548653005: exo: Add initial support for service side decorations. (Closed)
Patch Set: fix typo Created 4 years 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
« no previous file with comments | « components/exo/shell_surface.cc ('k') | components/exo/touch_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/aura/wm_window_aura.h" 5 #include "ash/aura/wm_window_aura.h"
6 #include "ash/common/accessibility_delegate.h" 6 #include "ash/common/accessibility_delegate.h"
7 #include "ash/common/wm/window_state.h" 7 #include "ash/common/wm/window_state.h"
8 #include "ash/common/wm/wm_event.h" 8 #include "ash/common/wm/wm_event.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 404
405 EXPECT_FALSE(is_resizing); 405 EXPECT_FALSE(is_resizing);
406 shell_surface->Resize(HTBOTTOMRIGHT); 406 shell_surface->Resize(HTBOTTOMRIGHT);
407 shell_surface->AcknowledgeConfigure(0); 407 shell_surface->AcknowledgeConfigure(0);
408 EXPECT_TRUE(is_resizing); 408 EXPECT_TRUE(is_resizing);
409 } 409 }
410 410
411 TEST_F(ShellSurfaceTest, ModalWindow) { 411 TEST_F(ShellSurfaceTest, ModalWindow) {
412 std::unique_ptr<Surface> surface(new Surface); 412 std::unique_ptr<Surface> surface(new Surface);
413 std::unique_ptr<ShellSurface> shell_surface( 413 std::unique_ptr<ShellSurface> shell_surface(
414 new ShellSurface(surface.get(), nullptr, gfx::Rect(), true, 414 new ShellSurface(surface.get(), nullptr, gfx::Rect(), true, false,
415 ash::kShellWindowId_SystemModalContainer)); 415 ash::kShellWindowId_SystemModalContainer));
416 gfx::Size desktop_size(640, 480); 416 gfx::Size desktop_size(640, 480);
417 std::unique_ptr<Buffer> desktop_buffer( 417 std::unique_ptr<Buffer> desktop_buffer(
418 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(desktop_size))); 418 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(desktop_size)));
419 surface->Attach(desktop_buffer.get()); 419 surface->Attach(desktop_buffer.get());
420 surface->SetInputRegion(SkRegion()); 420 surface->SetInputRegion(SkRegion());
421 surface->Commit(); 421 surface->Commit();
422 422
423 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 423 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
424 424
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 EXPECT_EQ(gfx::Rect(parent_bounds.origin() + 492 EXPECT_EQ(gfx::Rect(parent_bounds.origin() +
493 popup_bounds.OffsetFromOrigin() + 493 popup_bounds.OffsetFromOrigin() +
494 geometry.OffsetFromOrigin(), 494 geometry.OffsetFromOrigin(),
495 geometry.size()), 495 geometry.size()),
496 popup->GetWidget()->GetWindowBoundsInScreen()); 496 popup->GetWidget()->GetWindowBoundsInScreen());
497 } 497 }
498 498
499 TEST_F(ShellSurfaceTest, Shadow) { 499 TEST_F(ShellSurfaceTest, Shadow) {
500 std::unique_ptr<Surface> surface(new Surface); 500 std::unique_ptr<Surface> surface(new Surface);
501 std::unique_ptr<ShellSurface> shell_surface( 501 std::unique_ptr<ShellSurface> shell_surface(
502 new ShellSurface(surface.get(), nullptr, gfx::Rect(), true, 502 new ShellSurface(surface.get(), nullptr, gfx::Rect(), true, false,
503 ash::kShellWindowId_DefaultContainer)); 503 ash::kShellWindowId_DefaultContainer));
504 surface->Commit(); 504 surface->Commit();
505 505
506 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); 506 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow();
507 507
508 // 1) Initial state, no shadow. 508 // 1) Initial state, no shadow.
509 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); 509 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window);
510 ASSERT_TRUE(shadow); 510 ASSERT_TRUE(shadow);
511 EXPECT_FALSE(shadow->layer()->visible()); 511 EXPECT_FALSE(shadow->layer()->visible());
512 512
513 std::unique_ptr<Display> display(new Display); 513 std::unique_ptr<Display> display(new Display);
514 514
515 // 2) Just creating a sub surface won't create a shadow. 515 // 2) Just creating a sub surface won't create a shadow.
516 std::unique_ptr<Surface> child = display->CreateSurface(); 516 std::unique_ptr<Surface> child = display->CreateSurface();
517 gfx::Size buffer_size(128, 128); 517 gfx::Size buffer_size(128, 128);
518 std::unique_ptr<Buffer> child_buffer( 518 std::unique_ptr<Buffer> child_buffer(
519 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 519 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
520 child->Attach(child_buffer.get()); 520 child->Attach(child_buffer.get());
521 std::unique_ptr<SubSurface> sub_surface( 521 std::unique_ptr<SubSurface> sub_surface(
522 display->CreateSubSurface(child.get(), surface.get())); 522 display->CreateSubSurface(child.get(), surface.get()));
523 surface->Commit(); 523 surface->Commit();
524 524
525 EXPECT_FALSE(shadow->layer()->visible()); 525 EXPECT_FALSE(shadow->layer()->visible());
526 526
527 // 3) Create a shadow. 527 // 3) Create a shadow.
528 shell_surface->SetRectangularShadow(gfx::Rect(10, 10, 100, 100)); 528 shell_surface->SetRectangularShadow(true);
529 shell_surface->SetRectangularShadowContentBounds(gfx::Rect(10, 10, 100, 100));
529 surface->Commit(); 530 surface->Commit();
530 EXPECT_TRUE(shadow->layer()->visible()); 531 EXPECT_TRUE(shadow->layer()->visible());
531 532
532 gfx::Rect before = shadow->layer()->bounds(); 533 gfx::Rect before = shadow->layer()->bounds();
533 534
534 // 4) Shadow bounds is independent of the sub surface. 535 // 4) Shadow bounds is independent of the sub surface.
535 gfx::Size new_buffer_size(256, 256); 536 gfx::Size new_buffer_size(256, 256);
536 std::unique_ptr<Buffer> new_child_buffer( 537 std::unique_ptr<Buffer> new_child_buffer(
537 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(new_buffer_size))); 538 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(new_buffer_size)));
538 child->Attach(new_child_buffer.get()); 539 child->Attach(new_child_buffer.get());
539 child->Commit(); 540 child->Commit();
540 surface->Commit(); 541 surface->Commit();
541 542
542 EXPECT_EQ(before, shadow->layer()->bounds()); 543 EXPECT_EQ(before, shadow->layer()->bounds());
543 544
544 // 4) Updating the widget's window bounds should not change the shadow bounds. 545 // 4) Updating the widget's window bounds should not change the shadow bounds.
545 window->SetBounds(gfx::Rect(10, 10, 100, 100)); 546 window->SetBounds(gfx::Rect(10, 10, 100, 100));
546 EXPECT_EQ(before, shadow->layer()->bounds()); 547 EXPECT_EQ(before, shadow->layer()->bounds());
547 548
548 // 5) Set empty content bounds should disable shadow. 549 // 5) This should disable shadow.
549 shell_surface->SetRectangularShadow(gfx::Rect()); 550 shell_surface->SetRectangularShadow(false);
550 surface->Commit(); 551 surface->Commit();
551 552
552 EXPECT_EQ(wm::SHADOW_TYPE_NONE, wm::GetShadowType(window)); 553 EXPECT_EQ(wm::SHADOW_TYPE_NONE, wm::GetShadowType(window));
553 EXPECT_FALSE(shadow->layer()->visible()); 554 EXPECT_FALSE(shadow->layer()->visible());
554 555
555 // 6) Setting non empty content bounds should enable shadow. 556 // 6) This should enable shadow.
556 shell_surface->SetRectangularShadow(gfx::Rect(10, 10, 100, 100)); 557 shell_surface->SetRectangularShadow(true);
557 surface->Commit(); 558 surface->Commit();
558 559
559 EXPECT_EQ(wm::SHADOW_TYPE_RECTANGULAR, wm::GetShadowType(window)); 560 EXPECT_EQ(wm::SHADOW_TYPE_RECTANGULAR, wm::GetShadowType(window));
560 EXPECT_TRUE(shadow->layer()->visible()); 561 EXPECT_TRUE(shadow->layer()->visible());
561 } 562 }
562 563
563 TEST_F(ShellSurfaceTest, ShadowWithStateChange) { 564 TEST_F(ShellSurfaceTest, ShadowWithStateChange) {
564 std::unique_ptr<Surface> surface(new Surface); 565 std::unique_ptr<Surface> surface(new Surface);
565 // Set the bounds to disable auto managed mode. 566 // Set the bounds to disable auto managed mode.
566 std::unique_ptr<ShellSurface> shell_surface( 567 std::unique_ptr<ShellSurface> shell_surface(
567 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, 568 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, false,
568 ash::kShellWindowId_DefaultContainer)); 569 ash::kShellWindowId_DefaultContainer));
569 570
570 // Postion the widget at 10,10 so that we get non zero offset. 571 // Postion the widget at 10,10 so that we get non zero offset.
571 const gfx::Size content_size(100, 100); 572 const gfx::Size content_size(100, 100);
572 const gfx::Rect original_bounds(gfx::Point(10, 10), content_size); 573 const gfx::Rect original_bounds(gfx::Point(10, 10), content_size);
573 shell_surface->SetGeometry(original_bounds); 574 shell_surface->SetGeometry(original_bounds);
574 surface->Commit(); 575 surface->Commit();
575 576
576 // Placing a shadow at screen origin will make the shadow's origin (-10, -10). 577 // Placing a shadow at screen origin will make the shadow's origin (-10, -10).
577 const gfx::Rect shadow_bounds(content_size); 578 const gfx::Rect shadow_bounds(content_size);
578 579
579 // Expected shadow position/bounds in parent coordinates. 580 // Expected shadow position/bounds in parent coordinates.
580 const gfx::Point expected_shadow_origin(-10, -10); 581 const gfx::Point expected_shadow_origin(-10, -10);
581 const gfx::Rect expected_shadow_bounds(expected_shadow_origin, content_size); 582 const gfx::Rect expected_shadow_bounds(expected_shadow_origin, content_size);
582 583
583 views::Widget* widget = shell_surface->GetWidget(); 584 views::Widget* widget = shell_surface->GetWidget();
584 aura::Window* window = widget->GetNativeWindow(); 585 aura::Window* window = widget->GetNativeWindow();
585 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); 586 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window);
586 587
587 shell_surface->SetRectangularShadow(shadow_bounds); 588 shell_surface->SetRectangularShadow(true);
589 shell_surface->SetRectangularShadowContentBounds(shadow_bounds);
588 surface->Commit(); 590 surface->Commit();
589 EXPECT_EQ(wm::SHADOW_TYPE_RECTANGULAR, wm::GetShadowType(window)); 591 EXPECT_EQ(wm::SHADOW_TYPE_RECTANGULAR, wm::GetShadowType(window));
590 592
591 // Shadow overlay bounds. 593 // Shadow overlay bounds.
592 EXPECT_TRUE(shadow->layer()->visible()); 594 EXPECT_TRUE(shadow->layer()->visible());
593 // Origin must be in sync. 595 // Origin must be in sync.
594 EXPECT_EQ(expected_shadow_origin, 596 EXPECT_EQ(expected_shadow_origin,
595 shadow->layer()->parent()->bounds().origin()); 597 shadow->layer()->parent()->bounds().origin());
596 598
597 const gfx::Rect work_area = 599 const gfx::Rect work_area =
598 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); 600 display::Screen::GetScreen()->GetPrimaryDisplay().work_area();
599 // Maximizing window hides the shadow. 601 // Maximizing window hides the shadow.
600 widget->Maximize(); 602 widget->Maximize();
601 ASSERT_TRUE(widget->IsMaximized()); 603 ASSERT_TRUE(widget->IsMaximized());
602 EXPECT_FALSE(shadow->layer()->visible()); 604 EXPECT_FALSE(shadow->layer()->visible());
603 605
604 shell_surface->SetRectangularShadow(work_area); 606 shell_surface->SetRectangularShadowContentBounds(work_area);
605 surface->Commit(); 607 surface->Commit();
606 EXPECT_FALSE(shadow->layer()->visible()); 608 EXPECT_FALSE(shadow->layer()->visible());
607 609
608 // Restoring bounds will re-enable shadow. It's content size is set to work 610 // Restoring bounds will re-enable shadow. It's content size is set to work
609 // area,/ thus not visible until new bounds is committed. 611 // area,/ thus not visible until new bounds is committed.
610 widget->Restore(); 612 widget->Restore();
611 EXPECT_TRUE(shadow->layer()->visible()); 613 EXPECT_TRUE(shadow->layer()->visible());
612 const gfx::Rect shadow_in_maximized(expected_shadow_origin, work_area.size()); 614 const gfx::Rect shadow_in_maximized(expected_shadow_origin, work_area.size());
613 EXPECT_EQ(shadow_in_maximized, shadow->layer()->parent()->bounds()); 615 EXPECT_EQ(shadow_in_maximized, shadow->layer()->parent()->bounds());
614 616
615 // The bounds is updated. 617 // The bounds is updated.
616 shell_surface->SetRectangularShadow(shadow_bounds); 618 shell_surface->SetRectangularShadowContentBounds(shadow_bounds);
617 surface->Commit(); 619 surface->Commit();
618 EXPECT_EQ(expected_shadow_bounds, shadow->layer()->parent()->bounds()); 620 EXPECT_EQ(expected_shadow_bounds, shadow->layer()->parent()->bounds());
619 } 621 }
620 622
621 TEST_F(ShellSurfaceTest, ShadowWithTransform) { 623 TEST_F(ShellSurfaceTest, ShadowWithTransform) {
622 std::unique_ptr<Surface> surface(new Surface); 624 std::unique_ptr<Surface> surface(new Surface);
623 // Set the bounds to disable auto managed mode. 625 // Set the bounds to disable auto managed mode.
624 std::unique_ptr<ShellSurface> shell_surface( 626 std::unique_ptr<ShellSurface> shell_surface(
625 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 400), true, 627 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 400), true, false,
626 ash::kShellWindowId_DefaultContainer)); 628 ash::kShellWindowId_DefaultContainer));
627 629
628 // Postion the widget at 10,10 so that we get non zero offset. 630 // Postion the widget at 10,10 so that we get non zero offset.
629 const gfx::Size content_size(100, 100); 631 const gfx::Size content_size(100, 100);
630 const gfx::Rect original_bounds(gfx::Point(10, 10), content_size); 632 const gfx::Rect original_bounds(gfx::Point(10, 10), content_size);
631 shell_surface->SetGeometry(original_bounds); 633 shell_surface->SetGeometry(original_bounds);
632 surface->Commit(); 634 surface->Commit();
633 635
634 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); 636 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow();
635 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); 637 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window);
636 638
637 // Placing a shadow at screen origin will make the shadow's origin (-10, -10). 639 // Placing a shadow at screen origin will make the shadow's origin (-10, -10).
638 const gfx::Rect shadow_bounds(content_size); 640 const gfx::Rect shadow_bounds(content_size);
639 641
640 // Shadow bounds relative to its parent should not be affected by a transform. 642 // Shadow bounds relative to its parent should not be affected by a transform.
641 gfx::Transform transform; 643 gfx::Transform transform;
642 transform.Translate(50, 50); 644 transform.Translate(50, 50);
643 window->SetTransform(transform); 645 window->SetTransform(transform);
644 shell_surface->SetRectangularShadow(shadow_bounds); 646 shell_surface->SetRectangularShadow(true);
647 shell_surface->SetRectangularShadowContentBounds(shadow_bounds);
645 surface->Commit(); 648 surface->Commit();
646 EXPECT_TRUE(shadow->layer()->visible()); 649 EXPECT_TRUE(shadow->layer()->visible());
647 EXPECT_EQ(gfx::Rect(-10, -10, 100, 100), shadow->layer()->parent()->bounds()); 650 EXPECT_EQ(gfx::Rect(-10, -10, 100, 100), shadow->layer()->parent()->bounds());
648 } 651 }
649 652
650 TEST_F(ShellSurfaceTest, ShadowStartMaximized) { 653 TEST_F(ShellSurfaceTest, ShadowStartMaximized) {
651 std::unique_ptr<Surface> surface(new Surface); 654 std::unique_ptr<Surface> surface(new Surface);
652 std::unique_ptr<ShellSurface> shell_surface( 655 std::unique_ptr<ShellSurface> shell_surface(
653 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, 656 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, false,
654 ash::kShellWindowId_DefaultContainer)); 657 ash::kShellWindowId_DefaultContainer));
655 shell_surface->Maximize(); 658 shell_surface->Maximize();
656 views::Widget* widget = shell_surface->GetWidget(); 659 views::Widget* widget = shell_surface->GetWidget();
657 aura::Window* window = widget->GetNativeWindow(); 660 aura::Window* window = widget->GetNativeWindow();
658 661
659 // There is no shadow when started in maximized state. 662 // There is no shadow when started in maximized state.
660 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); 663 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window));
661 664
662 // Sending a shadow bounds in maximized state won't create a shaodw. 665 // Sending a shadow bounds in maximized state won't create a shaodw.
663 shell_surface->SetRectangularShadow(gfx::Rect(10, 10, 100, 100)); 666 shell_surface->SetRectangularShadow(true);
667 shell_surface->SetRectangularShadowContentBounds(gfx::Rect(10, 10, 100, 100));
664 surface->Commit(); 668 surface->Commit();
665 669
666 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); 670 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window));
667 // Underlay should be created even without shadow. 671 // Underlay should be created even without shadow.
668 ASSERT_TRUE(shell_surface->shadow_underlay()); 672 ASSERT_TRUE(shell_surface->shadow_underlay());
669 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); 673 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
670 674
671 // Restore the window and make sure the shadow is created, visible and 675 // Restore the window and make sure the shadow is created, visible and
672 // has the latest bounds. 676 // has the latest bounds.
673 widget->Restore(); 677 widget->Restore();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 EXPECT_EQ(CurrentContext()->bounds().width(), 715 EXPECT_EQ(CurrentContext()->bounds().width(),
712 shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); 716 shell_surface->GetWidget()->GetWindowBoundsInScreen().width());
713 } 717 }
714 718
715 TEST_F(ShellSurfaceTest, ImmersiveFullscreenBackground) { 719 TEST_F(ShellSurfaceTest, ImmersiveFullscreenBackground) {
716 gfx::Size buffer_size(256, 256); 720 gfx::Size buffer_size(256, 256);
717 std::unique_ptr<Buffer> buffer( 721 std::unique_ptr<Buffer> buffer(
718 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 722 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
719 std::unique_ptr<Surface> surface(new Surface); 723 std::unique_ptr<Surface> surface(new Surface);
720 std::unique_ptr<ShellSurface> shell_surface( 724 std::unique_ptr<ShellSurface> shell_surface(
721 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, 725 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, false,
722 ash::kShellWindowId_DefaultContainer)); 726 ash::kShellWindowId_DefaultContainer));
723 727
724 surface->Attach(buffer.get()); 728 surface->Attach(buffer.get());
725 729
726 gfx::Rect shadow_bounds(10, 10, 100, 100); 730 gfx::Rect shadow_bounds(10, 10, 100, 100);
727 shell_surface->SetRectangularShadow(shadow_bounds); 731 shell_surface->SetRectangularShadow(true);
732 shell_surface->SetRectangularShadowContentBounds(shadow_bounds);
728 surface->Commit(); 733 surface->Commit();
729 ASSERT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); 734 ASSERT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds());
730 735
731 ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN); 736 ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN);
732 ash::WmWindow* window = 737 ash::WmWindow* window =
733 ash::WmWindowAura::Get(shell_surface->GetWidget()->GetNativeWindow()); 738 ash::WmWindowAura::Get(shell_surface->GetWidget()->GetNativeWindow());
734 739
735 // Enter immersive fullscreen mode. Shadow underlay is fullscreen. 740 // Enter immersive fullscreen mode. Shadow underlay is fullscreen.
736 window->GetWindowState()->OnWMEvent(&event); 741 window->GetWindowState()->OnWMEvent(&event);
737 742
738 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), 743 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(),
739 shell_surface->shadow_underlay()->bounds()); 744 shell_surface->shadow_underlay()->bounds());
740 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); 745 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
741 EXPECT_EQ(1.f, shell_surface->shadow_underlay()->layer()->opacity()); 746 EXPECT_EQ(1.f, shell_surface->shadow_underlay()->layer()->opacity());
742 EXPECT_NE(shell_surface->GetWidget()->GetWindowBoundsInScreen(), 747 EXPECT_NE(shell_surface->GetWidget()->GetWindowBoundsInScreen(),
743 shell_surface->shadow_underlay()->bounds()); 748 shell_surface->shadow_underlay()->bounds());
744 749
745 // Leave fullscreen mode. Shadow underlay is restored. 750 // Leave fullscreen mode. Shadow underlay is restored.
746 window->GetWindowState()->OnWMEvent(&event); 751 window->GetWindowState()->OnWMEvent(&event);
747 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); 752 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
748 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); 753 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds());
749 } 754 }
750 755
751 TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) { 756 TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) {
752 gfx::Size buffer_size(256, 256); 757 gfx::Size buffer_size(256, 256);
753 Buffer buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); 758 Buffer buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size));
754 Surface surface; 759 Surface surface;
755 ShellSurface shell_surface(&surface, nullptr, gfx::Rect(640, 480), true, 760 ShellSurface shell_surface(&surface, nullptr, gfx::Rect(640, 480), true,
756 ash::kShellWindowId_DefaultContainer); 761 false, ash::kShellWindowId_DefaultContainer);
757 762
758 surface.Attach(&buffer); 763 surface.Attach(&buffer);
759 764
760 gfx::Rect shadow_bounds(10, 10, 100, 100); 765 gfx::Rect shadow_bounds(10, 10, 100, 100);
761 shell_surface.SetRectangularShadow(shadow_bounds); 766 shell_surface.SetRectangularShadow(true);
767 shell_surface.SetRectangularShadowContentBounds(shadow_bounds);
762 surface.Commit(); 768 surface.Commit();
763 ASSERT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); 769 ASSERT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds());
764 770
765 aura::Window* shell_window = shell_surface.GetWidget()->GetNativeWindow(); 771 aura::Window* shell_window = shell_surface.GetWidget()->GetNativeWindow();
766 aura::WindowTargeter* targeter = static_cast<aura::WindowTargeter*>( 772 aura::WindowTargeter* targeter = static_cast<aura::WindowTargeter*>(
767 static_cast<ui::EventTarget*>(shell_window)->GetEventTargeter()); 773 static_cast<ui::EventTarget*>(shell_window)->GetEventTargeter());
768 774
769 gfx::Point pt(300, 300); 775 gfx::Point pt(300, 300);
770 ui::MouseEvent ev_out(ui::ET_MOUSE_PRESSED, pt, pt, ui::EventTimeForNow(), 776 ui::MouseEvent ev_out(ui::ET_MOUSE_PRESSED, pt, pt, ui::EventTimeForNow(),
771 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); 777 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
(...skipping 20 matching lines...) Expand all
792 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( 798 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent(
793 shell_window, &ev_out)); 799 shell_window, &ev_out));
794 EXPECT_NE(shell_surface.shadow_underlay(), 800 EXPECT_NE(shell_surface.shadow_underlay(),
795 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( 801 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent(
796 shell_window, &ev_in)); 802 shell_window, &ev_in));
797 803
798 // Create a new surface 804 // Create a new surface
799 Buffer buffer2(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); 805 Buffer buffer2(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size));
800 Surface surface2; 806 Surface surface2;
801 ShellSurface shell_surface2(&surface2, nullptr, gfx::Rect(640, 480), true, 807 ShellSurface shell_surface2(&surface2, nullptr, gfx::Rect(640, 480), true,
802 ash::kShellWindowId_DefaultContainer); 808 false, ash::kShellWindowId_DefaultContainer);
803 surface2.Attach(&buffer2); 809 surface2.Attach(&buffer2);
804 shell_surface2.SetRectangularShadow(shadow_bounds); 810 shell_surface2.SetRectangularShadow(true);
811 shell_surface2.SetRectangularShadowContentBounds(shadow_bounds);
805 surface2.Commit(); 812 surface2.Commit();
806 813
807 // spoken-feedback was already on, so underlay should fill screen 814 // spoken-feedback was already on, so underlay should fill screen
808 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), 815 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(),
809 shell_surface2.shadow_underlay()->bounds()); 816 shell_surface2.shadow_underlay()->bounds());
810 817
811 // De-activated shell-surface should NOT have fullscreen underlay 818 // De-activated shell-surface should NOT have fullscreen underlay
812 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); 819 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds());
813 820
814 // Disable spoken feedback. Shadow underlay is restored. 821 // Disable spoken feedback. Shadow underlay is restored.
815 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( 822 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback(
816 ash::A11Y_NOTIFICATION_NONE); 823 ash::A11Y_NOTIFICATION_NONE);
817 shell_surface.OnAccessibilityModeChanged(); 824 shell_surface.OnAccessibilityModeChanged();
818 shell_surface2.OnAccessibilityModeChanged(); 825 shell_surface2.OnAccessibilityModeChanged();
819 826
820 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); 827 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible());
821 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); 828 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds());
822 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); 829 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds());
823 } 830 }
824 831
825 } // namespace 832 } // namespace
826 } // namespace exo 833 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/shell_surface.cc ('k') | components/exo/touch_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698