Flutter Engine
 
Loading...
Searching...
No Matches
impeller::android::testing Namespace Reference

Functions

std::shared_ptr< ContextCreateContext ()
 
 TEST (AndroidVulkanTest, CanImportRGBA)
 
 TEST (AndroidVulkanTest, CanImportWithYUB)
 
 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

◆ CreateContext()

std::shared_ptr< Context > impeller::android::testing::CreateContext ( )

Definition at line 19 of file ahb_texture_source_vk_unittests.cc.

19 {
20 auto vulkan_dylib = fml::NativeLibrary::Create("libvulkan.so");
21 auto instance_proc_addr =
22 vulkan_dylib->ResolveFunction<PFN_vkGetInstanceProcAddr>(
23 "vkGetInstanceProcAddr");
24
25 if (!instance_proc_addr.has_value()) {
26 VALIDATION_LOG << "Could not setup Vulkan proc table.";
27 return nullptr;
28 }
29
31 settings.proc_address_callback = instance_proc_addr.value();
32 settings.shader_libraries_data = {};
33 settings.enable_validation = false;
34 settings.enable_gpu_tracing = false;
35 settings.enable_surface_control = false;
36
37 return ContextVK::Create(std::move(settings));
38}
static fml::RefPtr< NativeLibrary > Create(const char *path)
std::vector< std::shared_ptr< fml::Mapping > > shader_libraries_data
Definition context_vk.h:81
PFN_vkGetInstanceProcAddr proc_address_callback
Definition context_vk.h:80
#define VALIDATION_LOG
Definition validation.h:91

References fml::NativeLibrary::Create(), impeller::ContextVK::Create(), impeller::ContextVK::Settings::enable_gpu_tracing, impeller::ContextVK::Settings::enable_surface_control, impeller::ContextVK::Settings::enable_validation, impeller::ContextVK::Settings::proc_address_callback, impeller::ContextVK::Settings::shader_libraries_data, and VALIDATION_LOG.

Referenced by TEST(), and TEST().

◆ TEST() [1/13]

impeller::android::testing::TEST ( AndroidVulkanTest  ,
CanImportRGBA   
)

Definition at line 40 of file ahb_texture_source_vk_unittests.cc.

40 {
41 if (!HardwareBuffer::IsAvailableOnPlatform()) {
42 GTEST_SKIP() << "Hardware buffers are not supported on this platform.";
43 }
44
46 desc.size = ISize{1, 1};
47 desc.format = HardwareBufferFormat::kR8G8B8A8UNormInt;
48 desc.usage = HardwareBufferUsageFlags::kSampledImage;
49
50 auto ahb = std::make_unique<HardwareBuffer>(desc);
51 ASSERT_TRUE(ahb);
52 auto context_vk = CreateContext();
53 ASSERT_TRUE(context_vk);
54
55 AHBTextureSourceVK source(context_vk, std::move(ahb),
56 /*is_swapchain_image=*/false);
57
58 EXPECT_TRUE(source.IsValid());
59 EXPECT_EQ(source.GetYUVConversion(), nullptr);
60
61 context_vk->Shutdown();
62}
A texture source that wraps an instance of AHardwareBuffer.
A descriptor use to specify hardware buffer allocations.

References CreateContext(), impeller::android::HardwareBufferDescriptor::format, impeller::AHBTextureSourceVK::GetYUVConversion(), impeller::android::HardwareBuffer::IsAvailableOnPlatform(), impeller::AHBTextureSourceVK::IsValid(), impeller::android::kR8G8B8A8UNormInt, impeller::android::kSampledImage, impeller::android::HardwareBufferDescriptor::size, and impeller::android::HardwareBufferDescriptor::usage.

◆ TEST() [2/13]

impeller::android::testing::TEST ( AndroidVulkanTest  ,
CanImportWithYUB   
)

Definition at line 64 of file ahb_texture_source_vk_unittests.cc.

64 {
65 if (!HardwareBuffer::IsAvailableOnPlatform()) {
66 GTEST_SKIP() << "Hardware buffers are not supported on this platform.";
67 }
68
69 AHardwareBuffer_Desc desc;
70 desc.width = 16;
71 desc.height = 16;
72 desc.format = AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420;
73 desc.stride = 0;
74 desc.layers = 1;
75 desc.rfu0 = 0;
76 desc.rfu1 = 0;
77 desc.usage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
78 AHARDWAREBUFFER_USAGE_CPU_WRITE_MASK |
79 AHARDWAREBUFFER_USAGE_CPU_READ_MASK;
80
81 EXPECT_EQ(AHardwareBuffer_isSupported(&desc), 1);
82
83 AHardwareBuffer* buffer = nullptr;
84 ASSERT_EQ(AHardwareBuffer_allocate(&desc, &buffer), 0);
85
86 auto context_vk = CreateContext();
87 ASSERT_TRUE(context_vk);
88
89 AHBTextureSourceVK source(context_vk, buffer, desc);
90
91 EXPECT_TRUE(source.IsValid());
92 EXPECT_NE(source.GetYUVConversion(), nullptr);
93
94 context_vk->Shutdown();
95}

References CreateContext(), impeller::AHBTextureSourceVK::GetYUVConversion(), impeller::android::HardwareBuffer::IsAvailableOnPlatform(), and impeller::AHBTextureSourceVK::IsValid().

◆ TEST() [3/13]

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());
92 ASSERT_TRUE(transaction.Apply([&event](auto) { event.Signal(); }));
93 event.Wait();
94}
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...

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

◆ TEST() [4/13]

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(), and impeller::android::HardwareBufferDescriptor::MakeForSwapchainImage().

◆ TEST() [5/13]

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}
The table of Android procs that are resolved dynamically.
Definition proc_table.h:97
bool IsValid() const
If a valid proc table could be setup. This may fail in case of setup on non-Android platforms.
Definition proc_table.cc:65

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

◆ TEST() [6/13]

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::IsAvailableOnPlatform(), and impeller::android::HardwareBufferDescriptor::MakeForSwapchainImage().

◆ TEST() [7/13]

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}
const ProcTable & GetProcTable()
Definition proc_table.cc:12

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

◆ TEST() [8/13]

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() [9/13]

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());
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() [10/13]

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() [11/13]

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() [12/13]

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}
#define DISABLE_ANDROID_PROC(name)

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

◆ TEST() [13/13]

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().