15#define DISABLE_ANDROID_PROC(name) \
16 struct Disable##name { \
18 real_proc = GetMutableProcTable().name.proc; \
19 GetMutableProcTable().name.proc = nullptr; \
21 ~Disable##name() { GetMutableProcTable().name.proc = real_proc; } \
22 decltype(name)* real_proc; \
25TEST(ToolkitAndroidTest, CanCreateProcTable) {
27 ASSERT_TRUE(proc_table.
IsValid());
30TEST(ToolkitAndroidTest, GuardsAgainstZeroSizedDescriptors) {
32 ASSERT_GT(desc.size.width, 0u);
33 ASSERT_GT(desc.size.height, 0u);
36TEST(ToolkitAndroidTest, CanCreateHardwareBuffer) {
38 GTEST_SKIP() <<
"Hardware buffers are not supported on this platform.";
42 ASSERT_TRUE(desc.IsAllocatable());
44 ASSERT_TRUE(buffer.IsValid());
47TEST(ToolkitAndroidTest, CanGetHardwareBufferIDs) {
49 GTEST_SKIP() <<
"Hardware buffers are not supported on this platform.";
52 if (!
GetProcTable().AHardwareBuffer_getId.IsAvailable()) {
53 GTEST_SKIP() <<
"Hardware buffer IDs are not available on this platform.";
56 ASSERT_TRUE(desc.IsAllocatable());
58 ASSERT_TRUE(buffer.IsValid());
59 ASSERT_TRUE(buffer.GetSystemUniqueID().has_value());
62TEST(ToolkitAndroidTest, HardwareBufferNullIDIfAPIUnavailable) {
67TEST(ToolkitAndroidTest, CanDescribeHardwareBufferHandles) {
69 GTEST_SKIP() <<
"Hardware buffers are not supported on this platform.";
73 ASSERT_TRUE(desc.IsAllocatable());
75 ASSERT_TRUE(buffer.IsValid());
77 ASSERT_TRUE(a_desc.has_value());
78 ASSERT_EQ(a_desc->width, 100u);
79 ASSERT_EQ(a_desc->height, 100u);
82TEST(ToolkitAndroidTest, CanApplySurfaceTransaction) {
84 GTEST_SKIP() <<
"Surface controls are not supported on this platform.";
88 ASSERT_TRUE(transaction.
IsValid());
90 ASSERT_TRUE(transaction.
Apply([&event](
auto) { event.Signal(); }));
94TEST(ToolkitAndroidTest, SurfacControlsAreAvailable) {
96 GTEST_SKIP() <<
"Surface controls are not supported on this platform.";
101TEST(ToolkitAndroidTest, ChoreographerIsAvailable) {
103 GTEST_SKIP() <<
"Choreographer is not supported on this platform.";
108TEST(ToolkitAndroidTest, CanPostAndNotWaitForFrameCallbacks) {
110 GTEST_SKIP() <<
"Choreographer is not supported on this platform.";
113 ASSERT_TRUE(choreographer.IsValid());
114 ASSERT_TRUE(choreographer.PostFrameCallback([](
auto) {}));
117TEST(ToolkitAndroidTest, CanPostAndWaitForFrameCallbacks) {
119 GTEST_SKIP() <<
"Choreographer is not supported on this platform.";
123 <<
"Disabled till the test harness is in an Android activity. "
124 "Running it without one will hang because the choreographer "
125 "frame callback will never execute.";
128 ASSERT_TRUE(choreographer.IsValid());
130 ASSERT_TRUE(choreographer.PostFrameCallback(
131 [&event](
auto point) { event.Signal(); }));
static bool IsAvailableOnPlatform()
static Choreographer & GetInstance()
Create or get the thread local instance of a choreographer. A message loop will be setup on the calli...
A wrapper for AHardwareBuffer https://developer.android.com/ndk/reference/group/a-hardware-buffer.
static bool IsAvailableOnPlatform()
static std::optional< AHardwareBuffer_Desc > Describe(AHardwareBuffer *buffer)
std::optional< uint64_t > GetSystemUniqueID() const
Get the system wide unique ID of the hardware buffer if possible. This is only available on Android A...
static bool IsAvailableOnPlatform()
A wrapper for ASurfaceTransaction. https://developer.android.com/ndk/reference/group/native-activity#...
bool Apply(OnCompleteCallback callback=nullptr)
Applies the updated encoded in the transaction and invokes the callback when the updated are complete...
static bool IsAvailableOnPlatform()
TEST(AndroidAHBSwapchainTest, AHBSwapchainNoFenceWaitAfterAcquireNextImageFailure)
const ProcTable & GetProcTable()
static HardwareBufferDescriptor MakeForSwapchainImage(const ISize &size)
Create a descriptor of the given size that is suitable for use as a swapchain image.
The table of Android procs that are resolved dynamically.
bool IsValid() const
If a valid proc table could be setup. This may fail in case of setup on non-Android platforms.