7 #include "flutter/testing/testing.h"
8 #include "fml/synchronization/waitable_event.h"
9 #include "impeller/renderer/backend/vulkan/test/mock_vulkan.h"
15 TEST(CommandEncoderVKTest, DeleteEncoderAfterThreadDies) {
18 std::shared_ptr<std::vector<std::string>> called_functions;
20 auto context = MockVulkanContextBuilder().Build();
21 called_functions = GetMockVulkanFunctions(context->GetDevice());
22 std::thread thread([&] { context->CreateCommandBuffer(); });
27 std::find(called_functions->begin(), called_functions->end(),
28 "vkDestroyCommandPool");
30 std::find(called_functions->begin(), called_functions->end(),
31 "vkFreeCommandBuffers");
32 EXPECT_TRUE(destroy_pool != called_functions->end());
33 EXPECT_TRUE(free_buffers != called_functions->end());
34 EXPECT_TRUE(free_buffers < destroy_pool);
37 TEST(CommandEncoderVKTest, CleanupAfterSubmit) {
41 std::shared_ptr<std::vector<std::string>> called_functions;
43 fml::AutoResetWaitableEvent wait_for_submit;
44 fml::AutoResetWaitableEvent wait_for_thread_join;
45 auto context = MockVulkanContextBuilder().Build();
46 std::thread thread([&] {
47 auto buffer = context->CreateCommandBuffer();
48 context->GetCommandQueue()->Submit(
51 wait_for_thread_join.Wait();
52 wait_for_submit.Signal();
56 wait_for_thread_join.Signal();
57 wait_for_submit.Wait();
58 called_functions = GetMockVulkanFunctions(context->GetDevice());
63 std::find(called_functions->begin(), called_functions->end(),
64 "vkDestroyCommandPool");
66 std::find(called_functions->begin(), called_functions->end(),
67 "vkFreeCommandBuffers");
68 EXPECT_TRUE(destroy_pool != called_functions->end());
69 EXPECT_TRUE(free_buffers != called_functions->end());
70 EXPECT_TRUE(free_buffers < destroy_pool);
TEST(AllocationSizeTest, CanCreateTypedAllocations)