Flutter Engine
The Flutter Engine
impeller
renderer
backend
vulkan
test
mock_vulkan_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 "flutter/testing/testing.h"
// IWYU pragma: keep
6
#include "gtest/gtest.h"
7
#include "
impeller/renderer/backend/vulkan/test/mock_vulkan.h
"
8
#include "vulkan/vulkan_enums.hpp"
9
10
namespace
impeller
{
11
namespace
testing {
12
13
TEST
(MockVulkanContextTest, IsThreadSafe) {
14
// In a typical app, there is a single ContextVK per app, shared b/w threads.
15
//
16
// This test ensures that the (mock) ContextVK is thread-safe.
17
auto
const
context =
MockVulkanContextBuilder
().
Build
();
18
19
// Spawn two threads, and have them create a CommandPoolVK each.
20
std::thread thread1([&context]() {
21
auto
const
pool
= context->GetCommandPoolRecycler()->
Get
();
22
EXPECT_TRUE
(
pool
);
23
});
24
25
std::thread thread2([&context]() {
26
auto
const
pool
= context->GetCommandPoolRecycler()->
Get
();
27
EXPECT_TRUE
(
pool
);
28
});
29
30
thread1.join();
31
thread2.join();
32
33
context->Shutdown();
34
}
35
36
TEST
(MockVulkanContextTest, DefaultFenceAlwaysReportsSuccess) {
37
auto
const
context =
MockVulkanContextBuilder
().
Build
();
38
auto
const
device
= context->GetDevice();
39
40
auto
fence =
device
.createFenceUnique({}).
value
;
41
EXPECT_EQ(vk::Result::eSuccess,
device
.getFenceStatus(*fence));
42
}
43
44
TEST
(MockVulkanContextTest, MockedFenceReportsStatus) {
45
auto
const
context =
MockVulkanContextBuilder
().
Build
();
46
47
auto
const
device
= context->GetDevice();
48
auto
fence =
device
.createFenceUnique({}).
value
;
49
MockFence::SetStatus
(fence, vk::Result::eNotReady);
50
51
EXPECT_EQ(vk::Result::eNotReady,
device
.getFenceStatus(fence.get()));
52
53
MockFence::SetStatus
(fence, vk::Result::eSuccess);
54
EXPECT_EQ(vk::Result::eSuccess,
device
.getFenceStatus(*fence));
55
}
56
57
}
// namespace testing
58
}
// namespace impeller
pool
AutoreleasePool pool
Definition:
BazelBenchmarkTestRunner.cpp:313
impeller::testing::MockFence::SetStatus
void SetStatus(vk::Result result)
Definition:
mock_vulkan.h:33
impeller::testing::MockVulkanContextBuilder
Definition:
mock_vulkan.h:59
impeller::testing::MockVulkanContextBuilder::Build
std::shared_ptr< ContextVK > Build()
Create a Vulkan context with Vulkan functions mocked. The caller is given a chance to tinker on the s...
Definition:
mock_vulkan.cc:912
device
VkDevice device
Definition:
main.cc:53
value
uint8_t value
Definition:
fl_standard_message_codec.cc:36
mock_vulkan.h
GrCustomXfermode::Get
const GrXPFactory * Get(SkBlendMode mode)
Definition:
GrCustomXfermode.cpp:379
impeller::testing::TEST
TEST(AiksCanvasTest, EmptyCullRect)
Definition:
canvas_unittests.cc:18
impeller
Definition:
texture.h:18
EXPECT_TRUE
#define EXPECT_TRUE(handle)
Definition:
unit_test.h:678
Generated on Sun Jun 23 2024 21:55:04 for Flutter Engine by
1.9.4