mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-08 07:33:53 +01:00
test: add dpi min/max tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
committed by
Benjamin Tissoires
parent
aeaa69b9e1
commit
b140bc2827
@@ -64,7 +64,7 @@ static const struct ratbag_test_device ratbagd_test_device_descr = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
.resolutions = {
|
.resolutions = {
|
||||||
{ .xres = 100, .yres = 200, .hz = 1000 },
|
{ .xres = 100, .yres = 200, .hz = 1000, .dpi_min = 50, .dpi_max = 5000 },
|
||||||
{ .xres = 200, .yres = 300, .hz = 1000, .active = true, .dflt = true },
|
{ .xres = 200, .yres = 300, .hz = 1000, .active = true, .dflt = true },
|
||||||
{ .xres = 300, .yres = 400, .hz = 1000 },
|
{ .xres = 300, .yres = 400, .hz = 1000 },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -169,7 +169,9 @@ test_read_profile(struct ratbag_profile *profile)
|
|||||||
{
|
{
|
||||||
struct ratbag_test_device *d = ratbag_get_drv_data(profile->device);
|
struct ratbag_test_device *d = ratbag_get_drv_data(profile->device);
|
||||||
struct ratbag_test_profile *p;
|
struct ratbag_test_profile *p;
|
||||||
|
struct ratbag_test_profile *p0;
|
||||||
struct ratbag_test_resolution *r;
|
struct ratbag_test_resolution *r;
|
||||||
|
struct ratbag_test_resolution *r0;
|
||||||
struct ratbag_button *button;
|
struct ratbag_button *button;
|
||||||
struct ratbag_led *led;
|
struct ratbag_led *led;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -179,6 +181,9 @@ test_read_profile(struct ratbag_profile *profile)
|
|||||||
assert(profile->index < d->num_profiles);
|
assert(profile->index < d->num_profiles);
|
||||||
|
|
||||||
p = &d->profiles[profile->index];
|
p = &d->profiles[profile->index];
|
||||||
|
p0 = &d->profiles[0];
|
||||||
|
r0 = &p0->resolutions[0];
|
||||||
|
|
||||||
for (i = 0; i < d->num_resolutions; i++) {
|
for (i = 0; i < d->num_resolutions; i++) {
|
||||||
_cleanup_resolution_ struct ratbag_resolution *res;
|
_cleanup_resolution_ struct ratbag_resolution *res;
|
||||||
|
|
||||||
@@ -187,6 +192,8 @@ test_read_profile(struct ratbag_profile *profile)
|
|||||||
res = ratbag_profile_get_resolution(profile, i);
|
res = ratbag_profile_get_resolution(profile, i);
|
||||||
assert(res);
|
assert(res);
|
||||||
ratbag_resolution_set_resolution(res, r->xres, r->yres, r->hz);
|
ratbag_resolution_set_resolution(res, r->xres, r->yres, r->hz);
|
||||||
|
if (r0->dpi_min != 0 && r0->dpi_max != 0)
|
||||||
|
ratbag_resolution_set_range(res, r0->dpi_min, r0->dpi_max);
|
||||||
res->is_active = r->active;
|
res->is_active = r->active;
|
||||||
if (r->active)
|
if (r->active)
|
||||||
active_set = true;
|
active_set = true;
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ struct ratbag_test_resolution {
|
|||||||
bool active;
|
bool active;
|
||||||
bool dflt;
|
bool dflt;
|
||||||
uint32_t caps;
|
uint32_t caps;
|
||||||
|
|
||||||
|
int dpi_min, dpi_max;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ratbag_test_color {
|
struct ratbag_test_color {
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ START_TEST(device_resolutions)
|
|||||||
struct ratbag_resolution *res;
|
struct ratbag_resolution *res;
|
||||||
int nprofiles, nresolutions;
|
int nprofiles, nresolutions;
|
||||||
int i, j;
|
int i, j;
|
||||||
int xres, yres, rate;
|
int xres, yres, rate, dpi_min, dpi_max;
|
||||||
int device_freed_count = 0;
|
int device_freed_count = 0;
|
||||||
bool is_active;
|
bool is_active;
|
||||||
|
|
||||||
@@ -353,7 +353,7 @@ START_TEST(device_resolutions)
|
|||||||
.profiles = {
|
.profiles = {
|
||||||
{
|
{
|
||||||
.resolutions = {
|
.resolutions = {
|
||||||
{ .xres = 100, .yres = 200, .hz = 1000 },
|
{ .xres = 100, .yres = 200, .hz = 1000, .dpi_min = 50, .dpi_max = 5000},
|
||||||
{ .xres = 200, .yres = 300, .hz = 1000, .active = true },
|
{ .xres = 200, .yres = 300, .hz = 1000, .active = true },
|
||||||
{ .xres = 300, .yres = 400, .hz = 1000 },
|
{ .xres = 300, .yres = 400, .hz = 1000 },
|
||||||
},
|
},
|
||||||
@@ -394,12 +394,17 @@ START_TEST(device_resolutions)
|
|||||||
yres = ratbag_resolution_get_dpi_y(res);
|
yres = ratbag_resolution_get_dpi_y(res);
|
||||||
rate = ratbag_resolution_get_report_rate(res);
|
rate = ratbag_resolution_get_report_rate(res);
|
||||||
is_active = ratbag_resolution_is_active(res);
|
is_active = ratbag_resolution_is_active(res);
|
||||||
|
dpi_min = ratbag_resolution_get_dpi_minimum(res);
|
||||||
|
dpi_max = ratbag_resolution_get_dpi_maximum(res);
|
||||||
|
|
||||||
ck_assert_int_eq(xres, i * 1000 + (j + 1) * 100);
|
ck_assert_int_eq(xres, i * 1000 + (j + 1) * 100);
|
||||||
ck_assert_int_eq(yres, i * 1000 + (j + 1) * 100 + 100);
|
ck_assert_int_eq(yres, i * 1000 + (j + 1) * 100 + 100);
|
||||||
ck_assert_int_eq(xres, ratbag_resolution_get_dpi(res));
|
ck_assert_int_eq(xres, ratbag_resolution_get_dpi(res));
|
||||||
ck_assert_int_eq(is_active, (j == 1));
|
ck_assert_int_eq(is_active, (j == 1));
|
||||||
|
|
||||||
|
ck_assert_int_eq(dpi_min, 50);
|
||||||
|
ck_assert_int_eq(dpi_max, 5000);
|
||||||
|
|
||||||
ck_assert_int_eq(rate, (i + 1) * 1000);
|
ck_assert_int_eq(rate, (i + 1) * 1000);
|
||||||
|
|
||||||
ratbag_resolution_unref(res);
|
ratbag_resolution_unref(res);
|
||||||
|
|||||||
Reference in New Issue
Block a user