fullscreen_window_finder_unittest.cc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Copyright 2018 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/fullscreen_window_finder.h"
  5. #include <memory>
  6. #include "ash/test/ash_test_base.h"
  7. #include "ash/wm/window_util.h"
  8. #include "ui/aura/client/aura_constants.h"
  9. #include "ui/aura/window.h"
  10. #include "ui/base/ui_base_types.h"
  11. #include "ui/gfx/geometry/rect.h"
  12. namespace ash {
  13. class FullscreenWindowFinderTest : public AshTestBase {
  14. public:
  15. FullscreenWindowFinderTest() = default;
  16. FullscreenWindowFinderTest(const FullscreenWindowFinderTest&) = delete;
  17. FullscreenWindowFinderTest& operator=(const FullscreenWindowFinderTest&) =
  18. delete;
  19. ~FullscreenWindowFinderTest() override = default;
  20. void SetUp() override {
  21. AshTestBase::SetUp();
  22. gfx::Rect bounds(100, 100, 200, 200);
  23. test_window_.reset(CreateTestWindowInShellWithBounds(bounds));
  24. }
  25. void TearDown() override {
  26. test_window_.reset();
  27. AshTestBase::TearDown();
  28. }
  29. bool FullscreenWindowExists() const {
  30. return nullptr != GetWindowForFullscreenModeForContext(test_window_.get());
  31. }
  32. protected:
  33. std::unique_ptr<aura::Window> test_window_;
  34. };
  35. // Test that a non-fullscreen window isn't found by GetWindowForFullscreenMode.
  36. TEST_F(FullscreenWindowFinderTest, NonFullscreen) {
  37. EXPECT_FALSE(FullscreenWindowExists());
  38. }
  39. // Test that a regular fullscreen window is found by GetWindowForFullscreenMode.
  40. TEST_F(FullscreenWindowFinderTest, RegularFullscreen) {
  41. test_window_->SetProperty(aura::client::kShowStateKey,
  42. ui::SHOW_STATE_FULLSCREEN);
  43. EXPECT_TRUE(FullscreenWindowExists());
  44. }
  45. // Test that a pinned fullscreen window is found by GetWindowForFullscreenMode.
  46. TEST_F(FullscreenWindowFinderTest, PinnedFullscreen) {
  47. window_util::PinWindow(test_window_.get(), /*trusted=*/false);
  48. EXPECT_TRUE(FullscreenWindowExists());
  49. }
  50. // Test that a trusted pinned fullscreen window is found by
  51. // GetWindowForFullscreenMode.
  52. TEST_F(FullscreenWindowFinderTest, TrustedPinnedFullscreen) {
  53. window_util::PinWindow(test_window_.get(), /*trusted=*/true);
  54. EXPECT_TRUE(FullscreenWindowExists());
  55. }
  56. } // namespace ash