input_method_surface_unittest.cc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2020 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 "components/exo/input_method_surface.h"
  5. #include "ash/shell.h"
  6. #include "components/exo/buffer.h"
  7. #include "components/exo/input_method_surface_manager.h"
  8. #include "components/exo/test/exo_test_base.h"
  9. #include "components/exo/test/exo_test_helper.h"
  10. #include "ui/display/display.h"
  11. namespace exo {
  12. class InputMethodSurfaceTest : public test::ExoTestBase,
  13. public InputMethodSurfaceManager {
  14. public:
  15. InputMethodSurfaceTest() = default;
  16. InputMethodSurfaceTest(const InputMethodSurfaceTest&) = delete;
  17. InputMethodSurfaceTest& operator=(const InputMethodSurfaceTest&) = delete;
  18. // Overridden from InputMethodSurfaceTest:
  19. InputMethodSurface* GetSurface() const override { return nullptr; }
  20. void AddSurface(InputMethodSurface* surface) override {}
  21. void RemoveSurface(InputMethodSurface* surface) override {}
  22. void OnTouchableBoundsChanged(InputMethodSurface* surface) override {}
  23. };
  24. TEST_F(InputMethodSurfaceTest, SetGeometryShouldIgnoreWorkArea) {
  25. UpdateDisplay("800x600");
  26. int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
  27. display::DisplayManager* display_manager =
  28. ash::Shell::Get()->display_manager();
  29. // With work area top insets.
  30. display_manager->UpdateWorkAreaOfDisplay(display_id,
  31. gfx::Insets::TLBR(200, 0, 0, 0));
  32. gfx::Size buffer_size(800, 600);
  33. std::unique_ptr<Buffer> buffer(
  34. new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
  35. std::unique_ptr<Surface> surface(new Surface);
  36. auto shell_surface =
  37. exo_test_helper()->CreateInputMethodSurface(surface.get(), this);
  38. surface->Attach(buffer.get());
  39. shell_surface->SetGeometry(gfx::Rect(buffer_size));
  40. surface->Commit();
  41. views::Widget* widget = shell_surface->GetWidget();
  42. EXPECT_EQ(gfx::Rect(buffer_size), widget->GetWindowBoundsInScreen());
  43. }
  44. } // namespace exo