5 #include "flutter/fml/synchronization/waitable_event.h"
6 #include "flutter/testing/testing.h"
16 #define DISABLE_ANDROID_PROC(name) \
17 struct Disable##name { \
19 real_proc = GetMutableProcTable().name.proc; \
20 GetMutableProcTable().name.proc = nullptr; \
23 GetMutableProcTable().name.proc = real_proc; \
25 decltype(name)* real_proc; \
28 TEST(ToolkitAndroidTest, CanCreateProcTable) {
30 ASSERT_TRUE(proc_table.
IsValid());
33 TEST(ToolkitAndroidTest, GuardsAgainstZeroSizedDescriptors) {
35 ASSERT_GT(desc.size.width, 0u);
36 ASSERT_GT(desc.size.height, 0u);
39 TEST(ToolkitAndroidTest, CanCreateHardwareBuffer) {
41 GTEST_SKIP() <<
"Hardware buffers are not supported on this platform.";
45 ASSERT_TRUE(desc.IsAllocatable());
50 TEST(ToolkitAndroidTest, CanGetHardwareBufferIDs) {
52 GTEST_SKIP() <<
"Hardware buffers are not supported on this platform.";
55 if (!
GetProcTable().AHardwareBuffer_getId.IsAvailable()) {
56 GTEST_SKIP() <<
"Hardware buffer IDs are not available on this platform.";
59 ASSERT_TRUE(desc.IsAllocatable());
65 TEST(ToolkitAndroidTest, HardwareBufferNullIDIfAPIUnavailable) {
70 TEST(ToolkitAndroidTest, CanDescribeHardwareBufferHandles) {
72 GTEST_SKIP() <<
"Hardware buffers are not supported on this platform.";
76 ASSERT_TRUE(desc.IsAllocatable());
80 ASSERT_TRUE(a_desc.has_value());
81 ASSERT_EQ(a_desc->width, 100u);
82 ASSERT_EQ(a_desc->height, 100u);
85 TEST(ToolkitAndroidTest, CanApplySurfaceTransaction) {
87 GTEST_SKIP() <<
"Surface controls are not supported on this platform.";
91 ASSERT_TRUE(transaction.
IsValid());
92 fml::AutoResetWaitableEvent event;
93 ASSERT_TRUE(transaction.
Apply([&event](
auto) { event.Signal(); }));
97 TEST(ToolkitAndroidTest, SurfacControlsAreAvailable) {
99 GTEST_SKIP() <<
"Surface controls are not supported on this platform.";
104 TEST(ToolkitAndroidTest, ChoreographerIsAvailable) {
106 GTEST_SKIP() <<
"Choreographer is not supported on this platform.";
111 TEST(ToolkitAndroidTest, CanPostAndNotWaitForFrameCallbacks) {
113 GTEST_SKIP() <<
"Choreographer is not supported on this platform.";
116 ASSERT_TRUE(choreographer.IsValid());
117 ASSERT_TRUE(choreographer.PostFrameCallback([](
auto) {}));
120 TEST(ToolkitAndroidTest, CanPostAndWaitForFrameCallbacks) {
122 GTEST_SKIP() <<
"Choreographer is not supported on this platform.";
126 <<
"Disabled till the test harness is in an Android activity. "
127 "Running it without one will hang because the choreographer "
128 "frame callback will never execute.";
131 ASSERT_TRUE(choreographer.IsValid());
132 fml::AutoResetWaitableEvent event;
133 ASSERT_TRUE(choreographer.PostFrameCallback(
134 [&event](
auto point) { event.Signal(); }));
138 TEST(ToolkitAndroidTest, ShouldDisableAHB) {