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