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]() { 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(); }));