window_mirror_view_unittest.cc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/wm/window_mirror_view.h"
  5. #include "ash/test/ash_test_base.h"
  6. #include "ui/aura/client/aura_constants.h"
  7. #include "ui/aura/window_occlusion_tracker.h"
  8. #include "ui/compositor/layer.h"
  9. #include "ui/gfx/geometry/size.h"
  10. #include "ui/gfx/geometry/transform.h"
  11. #include "ui/views/widget/widget.h"
  12. #include "ui/views/widget/widget_delegate.h"
  13. namespace ash {
  14. namespace {
  15. using WindowMirrorViewTest = AshTestBase;
  16. TEST_F(WindowMirrorViewTest, LocalWindowOcclusionMadeVisible) {
  17. auto widget = CreateTestWidget();
  18. widget->Hide();
  19. aura::Window* widget_window = widget->GetNativeWindow();
  20. widget_window->TrackOcclusionState();
  21. EXPECT_EQ(aura::Window::OcclusionState::HIDDEN,
  22. widget_window->GetOcclusionState());
  23. auto mirror_widget = CreateTestWidget();
  24. auto mirror_view = std::make_unique<WindowMirrorView>(
  25. widget_window, /*trilinear_filtering_on_init=*/false);
  26. mirror_widget->widget_delegate()->GetContentsView()->AddChildView(
  27. mirror_view.get());
  28. // Even though the widget is hidden, the occlusion state is considered
  29. // visible. This is to ensure renderers still produce content.
  30. EXPECT_EQ(aura::Window::OcclusionState::VISIBLE,
  31. widget_window->GetOcclusionState());
  32. }
  33. // Tests that a mirror view that mirrors a window with an existing transform
  34. // does not copy that transform onto its mirror layer (and then putting the
  35. // mirror layer offscreen). Regression test for https://crbug.com/1113429.
  36. TEST_F(WindowMirrorViewTest, MirrorLayerHasNoTransformWhenNonClientViewShown) {
  37. // Create a window that has a transform already. When the layer is mirrored,
  38. // the transform will be copied with it.
  39. auto widget = CreateTestWidget();
  40. aura::Window* widget_window = widget->GetNativeWindow();
  41. const gfx::Transform transform(1.f, 0.f, 0.f, 1.f, 100.f, 100.f);
  42. widget_window->SetTransform(transform);
  43. auto mirror_widget = CreateTestWidget();
  44. auto mirror_view = std::make_unique<WindowMirrorView>(
  45. widget_window, /*trilinear_filtering_on_init=*/false,
  46. /*show_non_client_view=*/true);
  47. mirror_view->RecreateMirrorLayers();
  48. EXPECT_TRUE(
  49. mirror_view->GetMirrorLayerForTesting()->transform().IsIdentity());
  50. }
  51. } // namespace
  52. } // namespace ash