-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathtest_graphics.cpp
More file actions
61 lines (47 loc) · 1.51 KB
/
Copy pathtest_graphics.cpp
File metadata and controls
61 lines (47 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* @file tests/unit/platform/linux/test_graphics.cpp
* @brief Test src/platform/linux/graphics.h image descriptor behavior.
*/
#include "../../../tests_common.h"
#if defined(__linux__)
#include <algorithm>
#include <exception>
#include <src/platform/linux/graphics.h>
namespace {
/**
* @brief Test-only failure raised by a capture-buffer release callback.
*/
class capture_buffer_release_error: public std::exception {};
} // namespace
TEST(EglImageDescriptorTest, ReleasesCaptureBufferOnlyOnce) {
egl::img_descriptor_t descriptor;
std::ranges::fill(descriptor.sd.fds, -1);
int release_count = 0;
descriptor.capture_buffer_consumed_cb = [&release_count]() {
++release_count;
};
descriptor.mark_capture_buffer_consumed();
descriptor.mark_capture_buffer_consumed();
descriptor.reset();
EXPECT_EQ(release_count, 1);
}
TEST(EglImageDescriptorTest, ResetReleasesCaptureBuffer) {
egl::img_descriptor_t descriptor;
std::ranges::fill(descriptor.sd.fds, -1);
bool released = false;
descriptor.capture_buffer_consumed_cb = [&released]() {
released = true;
};
descriptor.reset();
EXPECT_TRUE(released);
}
TEST(EglImageDescriptorTest, ContainsCaptureBufferReleaseExceptions) {
egl::img_descriptor_t descriptor;
std::ranges::fill(descriptor.sd.fds, -1);
descriptor.capture_buffer_consumed_cb = []() {
throw capture_buffer_release_error {};
};
EXPECT_NO_THROW(descriptor.mark_capture_buffer_consumed());
EXPECT_FALSE(descriptor.capture_buffer_consumed_cb);
}
#endif