| Flutter Impeller |

Functions
impeller::android::testing Namespace Reference

## Functions
| TEST (ToolkitAndroidTest, CanCreateProcTable)
| TEST (ToolkitAndroidTest, GuardsAgainstZeroSizedDescriptors)
| TEST (ToolkitAndroidTest, CanCreateHardwareBuffer)
| TEST (ToolkitAndroidTest, CanGetHardwareBufferIDs)
| TEST (ToolkitAndroidTest, HardwareBufferNullIDIfAPIUnavailable)
| TEST (ToolkitAndroidTest, CanDescribeHardwareBufferHandles)
| TEST (ToolkitAndroidTest, CanApplySurfaceTransaction)
| TEST (ToolkitAndroidTest, SurfacControlsAreAvailable)
| TEST (ToolkitAndroidTest, ChoreographerIsAvailable)
| TEST (ToolkitAndroidTest, CanPostAndNotWaitForFrameCallbacks)
| TEST (ToolkitAndroidTest, CanPostAndWaitForFrameCallbacks)
| TEST (ToolkitAndroidTest, ShouldDisableAHB)

## Function Documentation

## ◆ TEST() [1/12]

impeller::android::testing::TEST | ( | ToolkitAndroidTest | ,
|  | CanApplySurfaceTransaction |
| ) |  |

Definition at line 85 of file toolkit_android_unittests.cc.

85 {
86 if (!SurfaceTransaction::IsAvailableOnPlatform()) {
87 GTEST_SKIP() << "Surface controls are not supported on this platform.";
88 }
89 ASSERT_TRUE(SurfaceTransaction::IsAvailableOnPlatform());
90 SurfaceTransaction transaction;
91 ASSERT_TRUE(transaction.IsValid());
92 fml::AutoResetWaitableEvent event;
93 ASSERT_TRUE(transaction.Apply([&event](auto) { event.Signal(); }));
94 event.Wait();
95 }

References impeller::android::SurfaceTransaction::Apply(), impeller::android::SurfaceTransaction::IsAvailableOnPlatform(), and impeller::android::SurfaceTransaction::IsValid().

## ◆ TEST() [2/12]

impeller::android::testing::TEST | ( | ToolkitAndroidTest | ,
|  | CanCreateHardwareBuffer |
| ) |  |

Definition at line 39 of file toolkit_android_unittests.cc.

39 {
40 if (!HardwareBuffer::IsAvailableOnPlatform()) {
41 GTEST_SKIP() << "Hardware buffers are not supported on this platform.";
42 }
43 ASSERT_TRUE(HardwareBuffer::IsAvailableOnPlatform());
44 auto desc = HardwareBufferDescriptor::MakeForSwapchainImage({100, 100});
45 ASSERT_TRUE(desc.IsAllocatable());
46 HardwareBuffer buffer(desc);
47 ASSERT_TRUE(buffer.IsValid());
48 }

References impeller::android::HardwareBuffer::IsAvailableOnPlatform(), impeller::android::HardwareBuffer::IsValid(), and impeller::android::HardwareBufferDescriptor::MakeForSwapchainImage().

## ◆ TEST() [3/12]

impeller::android::testing::TEST | ( | ToolkitAndroidTest | ,
|  | CanCreateProcTable |
| ) |  |

Definition at line 28 of file toolkit_android_unittests.cc.

28 {
29 ProcTable proc_table;
30 ASSERT_TRUE(proc_table.IsValid());
31 }

References impeller::android::ProcTable::IsValid().

## ◆ TEST() [4/12]

impeller::android::testing::TEST | ( | ToolkitAndroidTest | ,
|  | CanDescribeHardwareBufferHandles |
| ) |  |

Definition at line 70 of file toolkit_android_unittests.cc.

70 {
71 if (!HardwareBuffer::IsAvailableOnPlatform()) {
72 GTEST_SKIP() << "Hardware buffers are not supported on this platform.";
73 }
74 ASSERT_TRUE(HardwareBuffer::IsAvailableOnPlatform());
75 auto desc = HardwareBufferDescriptor::MakeForSwapchainImage({100, 100});
76 ASSERT_TRUE(desc.IsAllocatable());
77 HardwareBuffer buffer(desc);
78 ASSERT_TRUE(buffer.IsValid());
79 auto a_desc = HardwareBuffer::Describe(buffer.GetHandle());
80 ASSERT_TRUE(a_desc.has_value());
81 ASSERT_EQ(a_desc->width, 100u); // NOLINT
82 ASSERT_EQ(a_desc->height, 100u); // NOLINT
83 }

References impeller::android::HardwareBuffer::Describe(), impeller::android::HardwareBuffer::GetHandle(), impeller::android::HardwareBuffer::IsAvailableOnPlatform(), impeller::android::HardwareBuffer::IsValid(), and impeller::android::HardwareBufferDescriptor::MakeForSwapchainImage().

## ◆ TEST() [5/12]

impeller::android::testing::TEST | ( | ToolkitAndroidTest | ,
|  | CanGetHardwareBufferIDs |
| ) |  |

Definition at line 50 of file toolkit_android_unittests.cc.

50 {
51 if (!HardwareBuffer::IsAvailableOnPlatform()) {
52 GTEST_SKIP() << "Hardware buffers are not supported on this platform.";
53 }
54 ASSERT_TRUE(HardwareBuffer::IsAvailableOnPlatform());
55 if (!GetProcTable().AHardwareBuffer_getId.IsAvailable()) {
56 GTEST_SKIP() << "Hardware buffer IDs are not available on this platform.";
57 }
58 auto desc = HardwareBufferDescriptor::MakeForSwapchainImage({100, 100});
59 ASSERT_TRUE(desc.IsAllocatable());
60 HardwareBuffer buffer(desc);
61 ASSERT_TRUE(buffer.IsValid());
62 ASSERT_TRUE(buffer.GetSystemUniqueID().has_value());
63 }

References impeller::android::GetProcTable(), impeller::android::HardwareBuffer::GetSystemUniqueID(), impeller::android::HardwareBuffer::IsAvailableOnPlatform(), impeller::android::HardwareBuffer::IsValid(), and impeller::android::HardwareBufferDescriptor::MakeForSwapchainImage().

## ◆ TEST() [6/12]

impeller::android::testing::TEST | ( | ToolkitAndroidTest | ,
|  | CanPostAndNotWaitForFrameCallbacks |
| ) |  |

Definition at line 111 of file toolkit_android_unittests.cc.

111 {
112 if (!Choreographer::IsAvailableOnPlatform()) {
113 GTEST_SKIP() << "Choreographer is not supported on this platform.";
114 }
115 const auto& choreographer = Choreographer::GetInstance();
116 ASSERT_TRUE(choreographer.IsValid());
117 ASSERT_TRUE(choreographer.PostFrameCallback([](auto) {}));
118 }

References impeller::android::Choreographer::GetInstance(), and impeller::android::Choreographer::IsAvailableOnPlatform().

## ◆ TEST() [7/12]

impeller::android::testing::TEST | ( | ToolkitAndroidTest | ,
|  | CanPostAndWaitForFrameCallbacks |
| ) |  |

Definition at line 120 of file toolkit_android_unittests.cc.

120 {
121 if (!Choreographer::IsAvailableOnPlatform()) {
122 GTEST_SKIP() << "Choreographer is not supported on this platform.";
123 }
124 if ((true)) {
125 GTEST_SKIP()
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.";
129 }
130 const auto& choreographer = Choreographer::GetInstance();
131 ASSERT_TRUE(choreographer.IsValid());
132 fml::AutoResetWaitableEvent event;
133 ASSERT_TRUE(choreographer.PostFrameCallback(
134 [&event](auto point) { event.Signal(); }));
135 event.Wait();
136 }

References impeller::android::Choreographer::GetInstance(), and impeller::android::Choreographer::IsAvailableOnPlatform().

## ◆ TEST() [8/12]

impeller::android::testing::TEST | ( | ToolkitAndroidTest | ,
|  | ChoreographerIsAvailable |
| ) |  |

Definition at line 104 of file toolkit_android_unittests.cc.

104 {
105 if (!Choreographer::IsAvailableOnPlatform()) {
106 GTEST_SKIP() << "Choreographer is not supported on this platform.";
107 }
108 ASSERT_TRUE(Choreographer::IsAvailableOnPlatform());
109 }

References impeller::android::Choreographer::IsAvailableOnPlatform().

## ◆ TEST() [9/12]

impeller::android::testing::TEST | ( | ToolkitAndroidTest | ,
|  | GuardsAgainstZeroSizedDescriptors |
| ) |  |

Definition at line 33 of file toolkit_android_unittests.cc.

33 {
34 auto desc = HardwareBufferDescriptor::MakeForSwapchainImage({0, 0});
35 ASSERT_GT(desc.size.width, 0u);
36 ASSERT_GT(desc.size.height, 0u);
37 }

References impeller::android::HardwareBufferDescriptor::MakeForSwapchainImage().

## ◆ TEST() [10/12]

impeller::android::testing::TEST | ( | ToolkitAndroidTest | ,
|  | HardwareBufferNullIDIfAPIUnavailable |
| ) |  |

Definition at line 65 of file toolkit_android_unittests.cc.

65 {
66 DISABLE_ANDROID_PROC(AHardwareBuffer_getId);
67 ASSERT_FALSE(HardwareBuffer::GetSystemUniqueID(nullptr).has_value());
68 }

References DISABLE_ANDROID_PROC, and impeller::android::HardwareBuffer::GetSystemUniqueID().

## ◆ TEST() [11/12]

impeller::android::testing::TEST | ( | ToolkitAndroidTest | ,
|  | ShouldDisableAHB |
| ) |  |

Definition at line 138 of file toolkit_android_unittests.cc.

138 {
139 EXPECT_FALSE(
140 ShadowRealm::ShouldDisableAHBInternal("android-huawei", "30", 30));
141 EXPECT_FALSE(
142 ShadowRealm::ShouldDisableAHBInternal("something made up", "29", 29));
143
144 EXPECT_TRUE(
145 ShadowRealm::ShouldDisableAHBInternal("android-huawei", "29", 29));
146 EXPECT_TRUE(
147 ShadowRealm::ShouldDisableAHBInternal("something made up", "27", 29));
148 EXPECT_TRUE(
149 ShadowRealm::ShouldDisableAHBInternal("android-huawei", "garbage", 29));
150 }

References impeller::android::ShadowRealm::ShouldDisableAHBInternal().

## ◆ TEST() [12/12]

impeller::android::testing::TEST | ( | ToolkitAndroidTest | ,
|  | SurfacControlsAreAvailable |
| ) |  |

Definition at line 97 of file toolkit_android_unittests.cc.

97 {
98 if (!SurfaceControl::IsAvailableOnPlatform()) {
99 GTEST_SKIP() << "Surface controls are not supported on this platform.";
100 }
101 ASSERT_TRUE(SurfaceControl::IsAvailableOnPlatform());
102 }

References impeller::android::SurfaceControl::IsAvailableOnPlatform().

DISABLE_ANDROID_PROC
#define DISABLE_ANDROID_PROC(name)
Definition: toolkit_android_unittests.cc:16
impeller::android::GetProcTable
const ProcTable & GetProcTable()
Definition: proc_table.cc:12