Flutter Impeller
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)
 

Function Documentation

◆ TEST() [1/11]

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

Definition at line 84 of file toolkit_android_unittests.cc.

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

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

◆ TEST() [2/11]

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

Definition at line 38 of file toolkit_android_unittests.cc.

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

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

◆ TEST() [3/11]

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

Definition at line 27 of file toolkit_android_unittests.cc.

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

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

◆ TEST() [4/11]

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

Definition at line 69 of file toolkit_android_unittests.cc.

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

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

◆ TEST() [5/11]

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

Definition at line 49 of file toolkit_android_unittests.cc.

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

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

◆ TEST() [6/11]

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

Definition at line 110 of file toolkit_android_unittests.cc.

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

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

◆ TEST() [7/11]

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

Definition at line 119 of file toolkit_android_unittests.cc.

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

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

◆ TEST() [8/11]

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

Definition at line 103 of file toolkit_android_unittests.cc.

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

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

◆ TEST() [9/11]

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

Definition at line 32 of file toolkit_android_unittests.cc.

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

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

◆ TEST() [10/11]

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

Definition at line 64 of file toolkit_android_unittests.cc.

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

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

◆ TEST() [11/11]

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

Definition at line 96 of file toolkit_android_unittests.cc.

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

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

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