Skip to content

Commit

Permalink
[wayland] Refactor ozone/wayland output tests
Browse files Browse the repository at this point in the history
This CL makes several changes to how output unittests work.

1. A TestOutputMetrics struct has been introduced that encapsulates
   any output state needed by TestOutput and its associated test
   extension classes.

   This avoids the current scattering of state across test output
   classes, making it easier to ensure the metrics are consistent
   (i.e. logical size, physical size, scale are set correctly).

   This consistency helps make the tests more understandable and
   correct (the tested state is more representative of what happens
   in actual production code).

2. TestOutputMetrics are updated via various helpers and flushed
   collectively to clients (for the wl_output and all extensions)
   before the wl_output.done event.

   This is more consistent with what the spec describes and how exo
   actually handles output updates.

   Previously metrics could be sent one at a time and/or remain in
   a pending state depending on how the test had been written. This
   could result in clients getting stuck in invalid states (IsReady()
   implementations would return incorrect results as not all expected
   state had been sent).

3. This CL makes it such that TestOutputMetrics are always flushed
   to clients after their outputs are bound.

   This change is consistent with what the spec describes.

   Previously this behavior was suppressed by not setting any pending
   metrics (rect/scale). This was not super clear and resulted in
   verbose tests. The default behavior of flushing on bind is the
   behavior expected for effectively all existing test cases.

   The only test case that required suppressing output metrics was
   LazilyConfiguredScreenTest.DualOutput. This CL instead adds a flag
   that can be optionally set to suppress output metrics specifically
   for this test case.

This CL goes through and updates various test cases that were
impacted by the above changes. In most places an explicit Flush()
is no longer required when creating a TestOutput. This change also
addresses existing problems such as test cases that had forgotten
to Flush() updates or set an appropriate logical transform state.

Bug: 1412420
Change-Id: I6b9bacccc47511ce8fcdf06ec7e5246a0da8017d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4298177
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1117341}
  • Loading branch information
Thomas Lukaszewicz authored and Chromium LUCI CQ committed Mar 15, 2023
1 parent ce71c65 commit b74b4d5
Show file tree
Hide file tree
Showing 17 changed files with 431 additions and 457 deletions.
2 changes: 2 additions & 0 deletions ui/ozone/platform/wayland/BUILD.gn
Expand Up @@ -444,6 +444,8 @@ source_set("test_support") {
"test/test_keyboard.h",
"test/test_output.cc",
"test/test_output.h",
"test/test_output_metrics.cc",
"test/test_output_metrics.h",
"test/test_overlay_prioritized_surface.cc",
"test/test_overlay_prioritized_surface.h",
"test/test_overlay_prioritizer.cc",
Expand Down
Expand Up @@ -160,8 +160,9 @@ class WaylandDataDragControllerTest : public WaylandDragDropTest {

// Set output dimensions at some offset.
PostToServerAndWait([](wl::TestWaylandServerThread* server) {
server->output()->SetRect({20, 30, 1200, 900});
server->output()->Flush();
auto* output = server->output();
output->SetPhysicalAndLogicalBounds({20, 30, 1200, 900});
output->Flush();
});

drag_finished_callback_ = std::make_unique<MockDragFinishedCallback>();
Expand Down Expand Up @@ -460,7 +461,7 @@ TEST_P(WaylandDataDragControllerTest, ReceiveDragPixelSurface) {
if (output->xdg_output()) {
// Use logical size to control the scale when the pixel coordinates
// is enabled.
output->xdg_output()->SetLogicalSize({400, 300});
output->SetLogicalSize({400, 300});
} else {
output->SetScale(kTripleScale);
}
Expand Down

0 comments on commit b74b4d5

Please sign in to comment.