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; \
27TEST(ToolkitAndroidTest, CanCreateProcTable) {
29 ASSERT_TRUE(proc_table.
IsValid());
32TEST(ToolkitAndroidTest, GuardsAgainstZeroSizedDescriptors) {
34 ASSERT_GT(
desc.size.width, 0u);
35 ASSERT_GT(
desc.size.height, 0u);
38TEST(ToolkitAndroidTest, CanCreateHardwareBuffer) {
40 GTEST_SKIP() <<
"Hardware buffers are not supported on this platform.";
44 ASSERT_TRUE(
desc.IsAllocatable());
46 ASSERT_TRUE(
buffer.IsValid());
49TEST(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());
60 ASSERT_TRUE(
buffer.IsValid());
61 ASSERT_TRUE(
buffer.GetSystemUniqueID().has_value());
64TEST(ToolkitAndroidTest, HardwareBufferNullIDIfAPIUnavailable) {
69TEST(ToolkitAndroidTest, CanDescribeHardwareBufferHandles) {
71 GTEST_SKIP() <<
"Hardware buffers are not supported on this platform.";
75 ASSERT_TRUE(
desc.IsAllocatable());
77 ASSERT_TRUE(
buffer.IsValid());
79 ASSERT_TRUE(a_desc.has_value());
80 ASSERT_EQ(a_desc->width, 100u);
81 ASSERT_EQ(a_desc->height, 100u);
84TEST(ToolkitAndroidTest, CanApplySurfaceTransaction) {
86 GTEST_SKIP() <<
"Surface controls are not supported on this platform.";
90 ASSERT_TRUE(transaction.
IsValid());
92 ASSERT_TRUE(transaction.
Apply([&
event](
auto) { event.Signal(); }));
96TEST(ToolkitAndroidTest, SurfacControlsAreAvailable) {
98 GTEST_SKIP() <<
"Surface controls are not supported on this platform.";
103TEST(ToolkitAndroidTest, ChoreographerIsAvailable) {
105 GTEST_SKIP() <<
"Choreographer is not supported on this platform.";
110TEST(ToolkitAndroidTest, CanPostAndNotWaitForFrameCallbacks) {
112 GTEST_SKIP() <<
"Choreographer is not supported on this platform.";
115 ASSERT_TRUE(choreographer.IsValid());
116 ASSERT_TRUE(choreographer.PostFrameCallback([](
auto) {}));
119TEST(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());
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()
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()
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
TEST(ToolkitAndroidTest, CanCreateProcTable)
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.