5 #include "flutter/fml/synchronization/waitable_event.h"
6 #include "flutter/testing/testing.h"
15 #define DISABLE_ANDROID_PROC(name) \
16 struct Disable##name { \
18 real_proc = GetMutableProcTable().name.proc; \
19 GetMutableProcTable().name.proc = nullptr; \
22 GetMutableProcTable().name.proc = real_proc; \
24 decltype(name)* real_proc; \
27 TEST(ToolkitAndroidTest, CanCreateProcTable) {
29 ASSERT_TRUE(proc_table.
IsValid());
32 TEST(ToolkitAndroidTest, GuardsAgainstZeroSizedDescriptors) {
34 ASSERT_GT(desc.size.width, 0u);
35 ASSERT_GT(desc.size.height, 0u);
38 TEST(ToolkitAndroidTest, CanCreateHardwareBuffer) {
40 GTEST_SKIP() <<
"Hardware buffers are not supported on this platform.";
44 ASSERT_TRUE(desc.IsAllocatable());
49 TEST(ToolkitAndroidTest, CanGetHardwareBufferIDs) {
51 GTEST_SKIP() <<
"Hardware buffers are not supported on this platform.";
54 if (!
GetProcTable().AHardwareBuffer_getId.IsAvailable()) {
55 GTEST_SKIP() <<
"Hardware buffer IDs are not available on this platform.";
58 ASSERT_TRUE(desc.IsAllocatable());
64 TEST(ToolkitAndroidTest, HardwareBufferNullIDIfAPIUnavailable) {
69 TEST(ToolkitAndroidTest, CanDescribeHardwareBufferHandles) {
71 GTEST_SKIP() <<
"Hardware buffers are not supported on this platform.";
75 ASSERT_TRUE(desc.IsAllocatable());
79 ASSERT_TRUE(a_desc.has_value());
80 ASSERT_EQ(a_desc->width, 100u);
81 ASSERT_EQ(a_desc->height, 100u);
84 TEST(ToolkitAndroidTest, CanApplySurfaceTransaction) {
86 GTEST_SKIP() <<
"Surface controls are not supported on this platform.";
90 ASSERT_TRUE(transaction.
IsValid());
91 fml::AutoResetWaitableEvent event;
92 ASSERT_TRUE(transaction.
Apply([&event](
auto) { event.Signal(); }));
96 TEST(ToolkitAndroidTest, SurfacControlsAreAvailable) {
98 GTEST_SKIP() <<
"Surface controls are not supported on this platform.";
103 TEST(ToolkitAndroidTest, ChoreographerIsAvailable) {
105 GTEST_SKIP() <<
"Choreographer is not supported on this platform.";
110 TEST(ToolkitAndroidTest, CanPostAndNotWaitForFrameCallbacks) {
112 GTEST_SKIP() <<
"Choreographer is not supported on this platform.";
115 ASSERT_TRUE(choreographer.IsValid());
116 ASSERT_TRUE(choreographer.PostFrameCallback([](
auto) {}));
119 TEST(ToolkitAndroidTest, CanPostAndWaitForFrameCallbacks) {
121 GTEST_SKIP() <<
"Choreographer is not supported on this platform.";
125 <<
"Disabled till the test harness is in an Android activity. "
126 "Running it without one will hang because the choreographer "
127 "frame callback will never execute.";
130 ASSERT_TRUE(choreographer.IsValid());
131 fml::AutoResetWaitableEvent event;
132 ASSERT_TRUE(choreographer.PostFrameCallback(
133 [&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()
AHardwareBuffer * GetHandle() const
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(AndroidVulkanTest, CanImportRGBA)
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.