Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
ahb_swapchain_vk_unittests.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "gtest/gtest.h"
6
11
13
16
18 public:
19 bool IsValid() const override { return true; }
20
21 ASurfaceControl* GetHandle() const override { return nullptr; }
22
23 bool RemoveFromParent() const override { return true; }
24};
25
26TEST(AndroidAHBSwapchainTest,
27 AHBSwapchainNoFenceWaitAfterAcquireNextImageFailure) {
28 bool wait_for_fences_called = false;
29 auto const context =
33 [](VkDevice, VkSwapchainKHR, uint64_t, VkSemaphore, VkFence,
34 uint32_t*) -> VkResult { return VK_ERROR_SURFACE_LOST_KHR; })
35 .SetWaitForFencesCallback([&](VkDevice, uint32_t, const VkFence*,
36 VkBool32, uint64_t) -> VkResult {
37 wait_for_fences_called = true;
38 return VK_SUCCESS;
39 })
40 .Build();
41
42 auto ahb_swapchain = std::shared_ptr<AHBSwapchainVK>(new AHBSwapchainVK(
43 context, std::make_shared<FakeSurfaceControl>(), {}, {100, 100}, false));
44
45 // Acquire a drawable but do not present it.
46 auto image = ahb_swapchain->AcquireNextDrawable();
47 EXPECT_TRUE(image);
48
49 // Call AcquireNextDrawable again. vkWaitForFences should not be called
50 // because no command was submitted and no fences are pending.
51 ahb_swapchain->AcquireNextDrawable();
52 EXPECT_FALSE(wait_for_fences_called);
53}
54
55TEST(AndroidAHBSwapchainTest, AHBSwapchainDtorCallsWaitIdle) {
58 .Build();
59
60 auto ahb_swapchain = std::shared_ptr<AHBSwapchainVK>(new AHBSwapchainVK(
61 context, std::make_shared<FakeSurfaceControl>(), {}, {100, 100}, false));
62
63 ahb_swapchain.reset();
64
65 auto called_functions = GetMockVulkanFunctions(context->GetDevice());
66 EXPECT_NE(std::find(called_functions->begin(), called_functions->end(),
67 "vkDeviceWaitIdle"),
68 called_functions->end());
69}
70
71} // namespace impeller::android::testing
The implementation of a swapchain that uses hardware buffers presented to a given surface control on ...
A wrapper for ASurfaceControl. https://developer.android.com/ndk/reference/group/native-activity#asur...
bool RemoveFromParent() const override
Remove the surface control from the hierarchy of nodes presented by the system compositor.
MockVulkanContextBuilder & SetDeviceExtensions(const std::vector< std::string > &device_extensions)
Definition mock_vulkan.h:92
std::shared_ptr< ContextVK > Build()
Create a Vulkan context with Vulkan functions mocked. The caller is given a chance to tinker on the s...
MockVulkanContextBuilder SetAcquireNextImageCallback(std::function< std::remove_pointer_t< PFN_vkAcquireNextImageKHR > > acquire_next_image_callback)
FlutterVulkanImage * image
TEST(AndroidAHBSwapchainTest, AHBSwapchainNoFenceWaitAfterAcquireNextImageFailure)
const std::vector< std::string > kAndroidDeviceExtensions
std::shared_ptr< std::vector< std::string > > GetMockVulkanFunctions(VkDevice device)
std::shared_ptr< ContextGLES > context