[display] Factor out test tool utilities.
Bug: 49056
Bug: 41413
Change-Id: I917899b1281c22e733c38405ace7eba82847951e
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/377993
Reviewed-by: Payam Moradshahi <payamm@google.com>
Reviewed-by: Randall Bosetti <rlb@google.com>
Testability-Review: Randall Bosetti <rlb@google.com>
Commit-Queue: Randall Bosetti <rlb@google.com>
diff --git a/src/graphics/display/bin/display-test/BUILD.gn b/src/graphics/display/bin/display-test/BUILD.gn
index 66fe78f..e0f62e8 100644
--- a/src/graphics/display/bin/display-test/BUILD.gn
+++ b/src/graphics/display/bin/display-test/BUILD.gn
@@ -2,13 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-##########################################
-# Though under //zircon, this build file #
-# is meant to be used in the Fuchsia GN #
-# build. #
-# See fxb/36139. #
-##########################################
-
assert(!defined(zx) || zx != "/",
"This file can only be used in the Fuchsia GN build.")
@@ -18,13 +11,9 @@
if (is_fuchsia) {
configs += [ "//build/unification/config:zircon-migrated" ]
}
- sources = [
- "display.cc",
- "image.cc",
- "main.cc",
- "virtual-layer.cc",
- ]
+ sources = [ "main.cc" ]
deps = [
+ "//src/graphics/display/testing",
"//zircon/public/lib/fbl",
"//zircon/public/lib/fdio",
"//zircon/public/lib/fdio-caller",
diff --git a/src/graphics/display/bin/display-test/main.cc b/src/graphics/display/bin/display-test/main.cc
index 4022b25..46c280a 100644
--- a/src/graphics/display/bin/display-test/main.cc
+++ b/src/graphics/display/bin/display-test/main.cc
@@ -32,16 +32,22 @@
#include <fbl/vector.h>
#include "ddk/driver.h"
-#include "display.h"
#include "fuchsia/hardware/display/llcpp/fidl.h"
#include "lib/fdio/directory.h"
#include "lib/fzl/vmo-mapper.h"
-#include "virtual-layer.h"
+#include "src/graphics/display/testing/display.h"
+#include "src/graphics/display/testing/virtual-layer.h"
namespace fhd = ::llcpp::fuchsia::hardware::display;
namespace sysmem = ::llcpp::fuchsia::sysmem;
namespace sysinfo = ::llcpp::fuchsia::sysinfo;
+using testing::display::ColorLayer;
+using testing::display::CursorLayer;
+using testing::display::Display;
+using testing::display::PrimaryLayer;
+using testing::display::VirtualLayer;
+
static zx_handle_t device_handle;
static std::unique_ptr<fhd::Controller::SyncClient> dc;
static bool has_ownership;
diff --git a/src/graphics/display/testing/BUILD.gn b/src/graphics/display/testing/BUILD.gn
new file mode 100644
index 0000000..3c1cd70
--- /dev/null
+++ b/src/graphics/display/testing/BUILD.gn
@@ -0,0 +1,20 @@
+static_library("testing") {
+ sources = [
+ "display.cc",
+ "image.cc",
+ "virtual-layer.cc",
+ ]
+ deps = [
+ "//zircon/public/lib/fbl",
+ "//zircon/public/lib/fdio",
+ "//zircon/public/lib/fdio-caller",
+ "//zircon/public/lib/fidl",
+ "//zircon/public/lib/fzl",
+ "//zircon/public/lib/image-format-llcpp",
+ "//zircon/public/lib/zx",
+ "//zircon/system/banjo/ddk.protocol.display.controller",
+ "//zircon/system/fidl/fuchsia-hardware-display:llcpp",
+ "//zircon/system/fidl/fuchsia-sysinfo:llcpp",
+ "//zircon/system/fidl/fuchsia-sysmem:llcpp",
+ ]
+}
diff --git a/src/graphics/display/bin/display-test/display.cc b/src/graphics/display/testing/display.cc
similarity index 96%
rename from src/graphics/display/bin/display-test/display.cc
rename to src/graphics/display/testing/display.cc
index b1d9deb..6320f9a 100644
--- a/src/graphics/display/bin/display-test/display.cc
+++ b/src/graphics/display/testing/display.cc
@@ -10,6 +10,9 @@
namespace fhd = ::llcpp::fuchsia::hardware::display;
+namespace testing {
+namespace display {
+
Display::Display(const fhd::Info& info) {
id_ = info.id;
@@ -82,3 +85,6 @@
ZX_ASSERT(dc->SetDisplayColorConversion(id_, preoffsets, grayscale, postoffsets).ok());
}
}
+
+} // namespace display
+} // namespace testing
diff --git a/src/graphics/display/bin/display-test/display.h b/src/graphics/display/testing/display.h
similarity index 87%
rename from src/graphics/display/bin/display-test/display.h
rename to src/graphics/display/testing/display.h
index 0de72eb..cc9ad8f 100644
--- a/src/graphics/display/bin/display-test/display.h
+++ b/src/graphics/display/testing/display.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_SYSTEM_UAPP_DISPLAY_TEST_DISPLAY_H_
-#define ZIRCON_SYSTEM_UAPP_DISPLAY_TEST_DISPLAY_H_
+#ifndef SRC_GRAPHICS_DISPLAY_TESTING_DISPLAY_H_
+#define SRC_GRAPHICS_DISPLAY_TESTING_DISPLAY_H_
#include <fuchsia/hardware/display/llcpp/fidl.h>
#include <lib/fidl/txn_header.h>
@@ -12,6 +12,9 @@
#include <fbl/string.h>
#include <fbl/vector.h>
+namespace testing {
+namespace display {
+
class Display {
public:
Display(const ::llcpp::fuchsia::hardware::display::Info& info);
@@ -58,4 +61,7 @@
bool using_fallback_sizes_;
};
-#endif // ZIRCON_SYSTEM_UAPP_DISPLAY_TEST_DISPLAY_H_
+} // namespace display
+} // namespace testing
+
+#endif // SRC_GRAPHICS_DISPLAY_TESTING_DISPLAY_H_
diff --git a/src/graphics/display/bin/display-test/image.cc b/src/graphics/display/testing/image.cc
similarity index 98%
rename from src/graphics/display/bin/display-test/image.cc
rename to src/graphics/display/testing/image.cc
index fe7b638..a2f9357 100644
--- a/src/graphics/display/bin/display-test/image.cc
+++ b/src/graphics/display/testing/image.cc
@@ -33,6 +33,9 @@
namespace sysmem = ::llcpp::fuchsia::sysmem;
namespace fhd = ::llcpp::fuchsia::hardware::display;
+namespace testing {
+namespace display {
+
Image::Image(uint32_t width, uint32_t height, int32_t stride, zx_pixel_format_t format,
uint32_t collection_id, void* buf, uint32_t fg_color, uint32_t bg_color,
bool use_intel_y_tiling)
@@ -345,3 +348,6 @@
dc->ReleaseBufferCollection(collection_id_);
return true;
}
+
+} // namespace display
+} // namespace testing
diff --git a/src/graphics/display/bin/display-test/image.h b/src/graphics/display/testing/image.h
similarity index 88%
rename from src/graphics/display/bin/display-test/image.h
rename to src/graphics/display/testing/image.h
index 5313a54..319d541 100644
--- a/src/graphics/display/bin/display-test/image.h
+++ b/src/graphics/display/testing/image.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_SYSTEM_UAPP_DISPLAY_TEST_IMAGE_H_
-#define ZIRCON_SYSTEM_UAPP_DISPLAY_TEST_IMAGE_H_
+#ifndef SRC_GRAPHICS_DISPLAY_TESTING_IMAGE_H_
+#define SRC_GRAPHICS_DISPLAY_TESTING_IMAGE_H_
#include <fuchsia/hardware/display/llcpp/fidl.h>
#include <lib/zx/channel.h>
@@ -22,6 +22,9 @@
#define WAIT_EVENT 0
#define SIGNAL_EVENT 1
+namespace testing {
+namespace display {
+
typedef struct image_import {
uint64_t id;
zx::event events[2];
@@ -64,4 +67,7 @@
bool use_intel_y_tiling_;
};
-#endif // ZIRCON_SYSTEM_UAPP_DISPLAY_TEST_IMAGE_H_
+} // namespace display
+} // namespace testing
+
+#endif // SRC_GRAPHICS_DISPLAY_TESTING_IMAGE_H_
diff --git a/src/graphics/display/bin/display-test/utils.h b/src/graphics/display/testing/utils.h
similarity index 76%
rename from src/graphics/display/bin/display-test/utils.h
rename to src/graphics/display/testing/utils.h
index 50abe59..d30303e 100644
--- a/src/graphics/display/bin/display-test/utils.h
+++ b/src/graphics/display/testing/utils.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SRC_GRAPHICS_DISPLAY_TESTING_UTILS_H_
+#define SRC_GRAPHICS_DISPLAY_TESTING_UTILS_H_
#include <inttypes.h>
@@ -11,3 +12,5 @@
fraction = (cur_frame / period) % 2 ? 1.0f - fraction : fraction;
return (uint32_t)((float)max * fraction);
}
+
+#endif // SRC_GRAPHICS_DISPLAY_TESTING_UTILS_H_
diff --git a/src/graphics/display/bin/display-test/virtual-layer.cc b/src/graphics/display/testing/virtual-layer.cc
similarity index 98%
rename from src/graphics/display/bin/display-test/virtual-layer.cc
rename to src/graphics/display/testing/virtual-layer.cc
index 3d040f7..fdb376c 100644
--- a/src/graphics/display/bin/display-test/virtual-layer.cc
+++ b/src/graphics/display/testing/virtual-layer.cc
@@ -15,6 +15,9 @@
namespace fhd = ::llcpp::fuchsia::hardware::display;
+namespace testing {
+namespace display {
+
static constexpr uint32_t kSrcFrameBouncePeriod = 90;
static constexpr uint32_t kDestFrameBouncePeriod = 60;
static constexpr uint32_t kRotationPeriod = 24;
@@ -414,3 +417,6 @@
return true;
}
+
+} // namespace display
+} // namespace testing
diff --git a/src/graphics/display/bin/display-test/virtual-layer.h b/src/graphics/display/testing/virtual-layer.h
similarity index 96%
rename from src/graphics/display/bin/display-test/virtual-layer.h
rename to src/graphics/display/testing/virtual-layer.h
index 4dcc4ad..e952ce9 100644
--- a/src/graphics/display/bin/display-test/virtual-layer.h
+++ b/src/graphics/display/testing/virtual-layer.h
@@ -2,18 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_SYSTEM_UAPP_DISPLAY_TEST_VIRTUAL_LAYER_H_
-#define ZIRCON_SYSTEM_UAPP_DISPLAY_TEST_VIRTUAL_LAYER_H_
+#ifndef SRC_GRAPHICS_DISPLAY_TESTING_VIRTUAL_LAYER_H_
+#define SRC_GRAPHICS_DISPLAY_TESTING_VIRTUAL_LAYER_H_
+#include <fuchsia/hardware/display/llcpp/fidl.h>
#include <lib/zx/channel.h>
#include <zircon/types.h>
-//#include <ddk/protocol/display/controller.h>
-#include <fuchsia/hardware/display/llcpp/fidl.h>
-
#include "display.h"
#include "image.h"
+namespace testing {
+namespace display {
+
typedef struct custom_layer {
uint64_t id;
bool active;
@@ -231,4 +232,7 @@
virtual bool is_done() const override { return true; }
};
-#endif // ZIRCON_SYSTEM_UAPP_DISPLAY_TEST_VIRTUAL_LAYER_H_
+} // namespace display
+} // namespace testing
+
+#endif // SRC_GRAPHICS_DISPLAY_TESTING_VIRTUAL_LAYER_H_