1
0
Fork 0

tests/kms/device: Add mode setting test

Checks that the relevant device state is correct after mode setting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
This commit is contained in:
Jonas Ådahl 2021-06-24 15:32:43 +02:00 committed by Marge Bot
parent feadaacfdd
commit 0fab55dbc0
4 changed files with 63 additions and 0 deletions

View file

@ -63,12 +63,15 @@ G_DECLARE_FINAL_TYPE (MetaKmsCrtc, meta_kms_crtc,
META_EXPORT_TEST
MetaKmsDevice * meta_kms_crtc_get_device (MetaKmsCrtc *crtc);
META_EXPORT_TEST
const MetaKmsCrtcState * meta_kms_crtc_get_current_state (MetaKmsCrtc *crtc);
META_EXPORT_TEST
uint32_t meta_kms_crtc_get_id (MetaKmsCrtc *crtc);
int meta_kms_crtc_get_idx (MetaKmsCrtc *crtc);
META_EXPORT_TEST
gboolean meta_kms_crtc_is_active (MetaKmsCrtc *crtc);
void meta_kms_crtc_gamma_free (MetaKmsCrtcGamma *gamma);

View file

@ -72,6 +72,7 @@ MetaKmsPlane * meta_kms_device_get_cursor_plane_for (MetaKmsDevice *device,
GList * meta_kms_device_get_fallback_modes (MetaKmsDevice *device);
META_EXPORT_TEST
MetaKmsFeedback * meta_kms_device_process_update_sync (MetaKmsDevice *device,
MetaKmsUpdate *update,
MetaKmsUpdateFlag flags);

View file

@ -300,6 +300,8 @@ if have_native_tests
native_kms_device_tests = executable('mutter-native-kms-device',
sources: [
'meta-kms-test-utils.c',
'meta-kms-test-utils.h',
'native-kms-device.c',
],
include_directories: tests_includes,

View file

@ -25,8 +25,10 @@
#include "backends/native/meta-kms-crtc.h"
#include "backends/native/meta-kms-device.h"
#include "backends/native/meta-kms-plane.h"
#include "backends/native/meta-kms-update.h"
#include "backends/native/meta-kms.h"
#include "meta-test/meta-context-test.h"
#include "tests/meta-kms-test-utils.h"
static MetaContext *test_context;
@ -86,11 +88,66 @@ meta_test_kms_device_sanity (void)
META_KMS_PLANE_TYPE_CURSOR);
}
static void
meta_test_kms_device_mode_set (void)
{
MetaKmsDevice *device;
MetaKmsUpdate *update;
MetaKmsCrtc *crtc;
MetaKmsConnector *connector;
MetaKmsMode *mode;
MetaKmsPlane *primary_plane;
g_autoptr (MetaDrmBuffer) primary_buffer = NULL;
const MetaKmsCrtcState *crtc_state;
const MetaKmsConnectorState *connector_state;
MetaRectangle mode_rect;
device = meta_get_test_kms_device (test_context);
crtc = meta_get_test_kms_crtc (device);
connector = meta_get_test_kms_connector (device);
mode = meta_kms_connector_get_preferred_mode (connector);
update = meta_kms_update_new (device);
meta_kms_update_mode_set (update, crtc,
g_list_append (NULL, connector),
mode);
primary_buffer = meta_create_test_mode_dumb_buffer (device, mode);
primary_plane = meta_kms_device_get_primary_plane_for (device, crtc);
meta_kms_update_assign_plane (update,
crtc,
primary_plane,
primary_buffer,
meta_get_mode_fixed_rect_16 (mode),
meta_get_mode_rect (mode),
META_KMS_ASSIGN_PLANE_FLAG_NONE);
meta_kms_device_process_update_sync (device, update,
META_KMS_UPDATE_FLAG_NONE);
meta_kms_update_free (update);
crtc_state = meta_kms_crtc_get_current_state (crtc);
g_assert_nonnull (crtc_state);
g_assert_true (crtc_state->is_active);
g_assert_true (crtc_state->is_drm_mode_valid);
mode_rect = meta_get_mode_rect (mode);
g_assert (meta_rectangle_equal (&crtc_state->rect, &mode_rect));
connector_state = meta_kms_connector_get_current_state (connector);
g_assert_nonnull (connector_state);
g_assert_cmpuint (connector_state->current_crtc_id,
==,
meta_kms_crtc_get_id (crtc));
}
static void
init_tests (void)
{
g_test_add_func ("/backends/native/kms/device/sanity",
meta_test_kms_device_sanity);
g_test_add_func ("/backends/native/kms/device/mode-set",
meta_test_kms_device_mode_set);
}
int