-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathtest_kmsgrab.cpp
More file actions
93 lines (84 loc) · 3.23 KB
/
Copy pathtest_kmsgrab.cpp
File metadata and controls
93 lines (84 loc) · 3.23 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* @file tests/unit/platform/linux/test_kmsgrab.cpp
* @brief Tests for portable KMS monitor descriptor helpers.
*/
#include "../../../tests_common.h"
// standard includes
#include <algorithm>
#include <cstdint>
#include <string>
#include <vector>
// local includes
#include "src/platform/linux/kmsgrab.h"
namespace {
/**
* @brief Input and expected output for KMS viewport resolution tests.
*/
struct monitor_viewport_test_case_t {
std::string name; ///< Descriptive test-case name.
std::vector<platf::kms::card_descriptor_t> card_descriptors; ///< Cached card descriptors.
std::string card_path; ///< Live DRM card filename.
std::uint32_t crtc_id; ///< Live DRM CRTC identifier.
platf::touch_port_t live_crtc_viewport; ///< Fallback live CRTC geometry.
platf::touch_port_t expected_viewport; ///< Expected resolved geometry.
platf::kms::monitor_viewport_source_e expected_source; ///< Expected geometry source.
};
/**
* @brief Parameterized fixture for KMS viewport resolution.
*/
class KmsMonitorViewportTest: public testing::TestWithParam<monitor_viewport_test_case_t> {};
TEST_P(KmsMonitorViewportTest, ResolvesCachedOrLiveCrtcGeometry) {
const auto &test_case = GetParam();
const auto result = platf::kms::resolve_monitor_viewport(
test_case.card_descriptors,
test_case.card_path,
test_case.crtc_id,
test_case.live_crtc_viewport
);
EXPECT_EQ(result.source, test_case.expected_source);
EXPECT_EQ(result.viewport.offset_x, test_case.expected_viewport.offset_x);
EXPECT_EQ(result.viewport.offset_y, test_case.expected_viewport.offset_y);
EXPECT_EQ(result.viewport.width, test_case.expected_viewport.width);
EXPECT_EQ(result.viewport.height, test_case.expected_viewport.height);
EXPECT_EQ(result.viewport.logical_width, test_case.expected_viewport.logical_width);
EXPECT_EQ(result.viewport.logical_height, test_case.expected_viewport.logical_height);
}
INSTANTIATE_TEST_SUITE_P(
KmsMonitorViewportCases,
KmsMonitorViewportTest,
testing::Values(
monitor_viewport_test_case_t {
"cached monitor",
{{"card2", {{42, {10, 1, 0, {100, 200, 2560, 1600, 1280, 800}}}}}},
"card2",
42,
{0, 0, 1920, 1080, 1920, 1080},
{100, 200, 2560, 1600, 1280, 800},
platf::kms::monitor_viewport_source_e::cached,
},
monitor_viewport_test_case_t {
"missing secondary card",
{{"card1", {{17, {11, 1, 0, {0, 0, 1920, 1080, 1920, 1080}}}}}},
"card2",
42,
{0, 0, 2560, 1600, 2560, 1600},
{0, 0, 2560, 1600, 2560, 1600},
platf::kms::monitor_viewport_source_e::live_crtc_missing_card,
},
monitor_viewport_test_case_t {
"missing monitor on cached card",
{{"card2", {{17, {10, 1, 0, {0, 0, 1920, 1080, 1920, 1080}}}}}},
"card2",
42,
{300, 0, 2560, 1600, 2560, 1600},
{300, 0, 2560, 1600, 2560, 1600},
platf::kms::monitor_viewport_source_e::live_crtc_missing_monitor,
}
),
[](const testing::TestParamInfo<monitor_viewport_test_case_t> &info) {
std::string name = info.param.name;
std::ranges::replace(name, ' ', '_');
return name;
}
);
} // namespace