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

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

Issue 2694213003: mash: wires up shadows for mash (Closed)
Patch Set: defaults test Created 3 years, 10 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
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/common/accessibility_delegate.h" 5 #include "ash/common/accessibility_delegate.h"
6 #include "ash/common/wm/window_state.h" 6 #include "ash/common/wm/window_state.h"
7 #include "ash/common/wm/wm_event.h" 7 #include "ash/common/wm/wm_event.h"
8 #include "ash/common/wm_shell.h" 8 #include "ash/common/wm_shell.h"
9 #include "ash/common/wm_window.h" 9 #include "ash/common/wm_window.h"
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
(...skipping 28 matching lines...) Expand all
39 39
40 uint32_t ConfigureFullscreen(uint32_t serial, 40 uint32_t ConfigureFullscreen(uint32_t serial,
41 const gfx::Size& size, 41 const gfx::Size& size,
42 ash::wm::WindowStateType state_type, 42 ash::wm::WindowStateType state_type,
43 bool resizing, 43 bool resizing,
44 bool activated) { 44 bool activated) {
45 EXPECT_EQ(ash::wm::WINDOW_STATE_TYPE_FULLSCREEN, state_type); 45 EXPECT_EQ(ash::wm::WINDOW_STATE_TYPE_FULLSCREEN, state_type);
46 return serial; 46 return serial;
47 } 47 }
48 48
49 wm::ShadowElevation GetShadowElevation(aura::Window* window) {
50 return window->GetProperty(wm::kShadowElevationKey);
51 }
52
49 TEST_F(ShellSurfaceTest, AcknowledgeConfigure) { 53 TEST_F(ShellSurfaceTest, AcknowledgeConfigure) {
50 gfx::Size buffer_size(32, 32); 54 gfx::Size buffer_size(32, 32);
51 std::unique_ptr<Buffer> buffer( 55 std::unique_ptr<Buffer> buffer(
52 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 56 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
53 std::unique_ptr<Surface> surface(new Surface); 57 std::unique_ptr<Surface> surface(new Surface);
54 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 58 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
55 59
56 surface->Attach(buffer.get()); 60 surface->Attach(buffer.get());
57 surface->Commit(); 61 surface->Commit();
58 62
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 EXPECT_EQ(before, shadow->layer()->bounds()); 557 EXPECT_EQ(before, shadow->layer()->bounds());
554 558
555 // 4) Updating the widget's window bounds should not change the shadow bounds. 559 // 4) Updating the widget's window bounds should not change the shadow bounds.
556 window->SetBounds(gfx::Rect(10, 10, 100, 100)); 560 window->SetBounds(gfx::Rect(10, 10, 100, 100));
557 EXPECT_EQ(before, shadow->layer()->bounds()); 561 EXPECT_EQ(before, shadow->layer()->bounds());
558 562
559 // 5) This should disable shadow. 563 // 5) This should disable shadow.
560 shell_surface->SetRectangularSurfaceShadow(gfx::Rect()); 564 shell_surface->SetRectangularSurfaceShadow(gfx::Rect());
561 surface->Commit(); 565 surface->Commit();
562 566
563 EXPECT_EQ(wm::ShadowElevation::NONE, wm::GetShadowElevation(window)); 567 EXPECT_EQ(wm::ShadowElevation::NONE, GetShadowElevation(window));
564 EXPECT_FALSE(shadow->layer()->visible()); 568 EXPECT_FALSE(shadow->layer()->visible());
565 569
566 // 6) This should enable non surface shadow again. 570 // 6) This should enable non surface shadow again.
567 shell_surface->SetRectangularSurfaceShadow(gfx::Rect(10, 10, 100, 100)); 571 shell_surface->SetRectangularSurfaceShadow(gfx::Rect(10, 10, 100, 100));
568 surface->Commit(); 572 surface->Commit();
569 573
570 EXPECT_EQ(wm::ShadowElevation::MEDIUM, wm::GetShadowElevation(window)); 574 EXPECT_EQ(wm::ShadowElevation::MEDIUM, GetShadowElevation(window));
571 EXPECT_TRUE(shadow->layer()->visible()); 575 EXPECT_TRUE(shadow->layer()->visible());
572 576
573 // For surface shadow, the underlay is placed at the bottom of shell surfaces. 577 // For surface shadow, the underlay is placed at the bottom of shell surfaces.
574 EXPECT_EQ(surface->window(), shell_surface->shadow_underlay()->parent()); 578 EXPECT_EQ(surface->window(), shell_surface->shadow_underlay()->parent());
575 EXPECT_EQ(window, shell_surface->shadow_overlay()->parent()); 579 EXPECT_EQ(window, shell_surface->shadow_overlay()->parent());
576 580
577 EXPECT_EQ(*surface->window()->children().begin(), 581 EXPECT_EQ(*surface->window()->children().begin(),
578 shell_surface->shadow_underlay()); 582 shell_surface->shadow_underlay());
579 } 583 }
580 584
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 // bounds. 634 // bounds.
631 const gfx::Rect new_bounds(50, 50, 100, 100); 635 const gfx::Rect new_bounds(50, 50, 100, 100);
632 window->SetBounds(new_bounds); 636 window->SetBounds(new_bounds);
633 EXPECT_NE(before, shadow->layer()->bounds()); 637 EXPECT_NE(before, shadow->layer()->bounds());
634 EXPECT_NE(new_bounds, shadow->layer()->bounds()); 638 EXPECT_NE(new_bounds, shadow->layer()->bounds());
635 639
636 // 5) This should disable shadow. 640 // 5) This should disable shadow.
637 shell_surface->SetRectangularShadowEnabled(false); 641 shell_surface->SetRectangularShadowEnabled(false);
638 surface->Commit(); 642 surface->Commit();
639 643
640 EXPECT_EQ(wm::ShadowElevation::NONE, wm::GetShadowElevation(window)); 644 EXPECT_EQ(wm::ShadowElevation::NONE, GetShadowElevation(window));
641 EXPECT_FALSE(shadow->layer()->visible()); 645 EXPECT_FALSE(shadow->layer()->visible());
642 646
643 // 6) This should enable non surface shadow. 647 // 6) This should enable non surface shadow.
644 shell_surface->SetRectangularShadowEnabled(true); 648 shell_surface->SetRectangularShadowEnabled(true);
645 surface->Commit(); 649 surface->Commit();
646 650
647 EXPECT_EQ(wm::ShadowElevation::MEDIUM, wm::GetShadowElevation(window)); 651 EXPECT_EQ(wm::ShadowElevation::MEDIUM, GetShadowElevation(window));
648 EXPECT_TRUE(shadow->layer()->visible()); 652 EXPECT_TRUE(shadow->layer()->visible());
649 653
650 // For no surface shadow, both of underlay and overlay should be stacked 654 // For no surface shadow, both of underlay and overlay should be stacked
651 // below the surface window. 655 // below the surface window.
652 EXPECT_EQ(window, shell_surface->shadow_underlay()->parent()); 656 EXPECT_EQ(window, shell_surface->shadow_underlay()->parent());
653 EXPECT_EQ(window, shell_surface->shadow_overlay()->parent()); 657 EXPECT_EQ(window, shell_surface->shadow_overlay()->parent());
654 658
655 // Shadow overlay should be stacked just above the shadow underlay. 659 // Shadow overlay should be stacked just above the shadow underlay.
656 auto underlay_it = 660 auto underlay_it =
657 std::find(window->children().begin(), window->children().end(), 661 std::find(window->children().begin(), window->children().end(),
(...skipping 26 matching lines...) Expand all
684 // Expected shadow position/bounds in parent coordinates. 688 // Expected shadow position/bounds in parent coordinates.
685 const gfx::Point expected_shadow_origin(-10, -10); 689 const gfx::Point expected_shadow_origin(-10, -10);
686 const gfx::Rect expected_shadow_bounds(expected_shadow_origin, content_size); 690 const gfx::Rect expected_shadow_bounds(expected_shadow_origin, content_size);
687 691
688 views::Widget* widget = shell_surface->GetWidget(); 692 views::Widget* widget = shell_surface->GetWidget();
689 aura::Window* window = widget->GetNativeWindow(); 693 aura::Window* window = widget->GetNativeWindow();
690 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); 694 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window);
691 695
692 shell_surface->SetRectangularSurfaceShadow(shadow_bounds); 696 shell_surface->SetRectangularSurfaceShadow(shadow_bounds);
693 surface->Commit(); 697 surface->Commit();
694 EXPECT_EQ(wm::ShadowElevation::MEDIUM, wm::GetShadowElevation(window)); 698 EXPECT_EQ(wm::ShadowElevation::MEDIUM, GetShadowElevation(window));
695 699
696 // Shadow overlay bounds. 700 // Shadow overlay bounds.
697 EXPECT_TRUE(shadow->layer()->visible()); 701 EXPECT_TRUE(shadow->layer()->visible());
698 // Origin must be in sync. 702 // Origin must be in sync.
699 EXPECT_EQ(expected_shadow_origin, 703 EXPECT_EQ(expected_shadow_origin,
700 shadow->layer()->parent()->bounds().origin()); 704 shadow->layer()->parent()->bounds().origin());
701 705
702 const gfx::Rect work_area = 706 const gfx::Rect work_area =
703 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); 707 display::Screen::GetScreen()->GetPrimaryDisplay().work_area();
704 // Maximizing window hides the shadow. 708 // Maximizing window hides the shadow.
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 shell_surface.OnAccessibilityModeChanged(); 941 shell_surface.OnAccessibilityModeChanged();
938 shell_surface2.OnAccessibilityModeChanged(); 942 shell_surface2.OnAccessibilityModeChanged();
939 943
940 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); 944 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible());
941 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); 945 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds());
942 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); 946 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds());
943 } 947 }
944 948
945 } // namespace 949 } // namespace
946 } // namespace exo 950 } // namespace exo
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc ('k') | services/ui/public/interfaces/window_manager.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698