2016-12-05 05:40:44 -05:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "tests/monitor-unit-tests.h"
|
|
|
|
|
|
|
|
#include "backends/meta-backend-private.h"
|
2016-12-12 21:37:11 -05:00
|
|
|
#include "backends/meta-logical-monitor.h"
|
2016-12-12 21:58:41 -05:00
|
|
|
#include "backends/meta-monitor.h"
|
2016-12-05 08:28:22 -05:00
|
|
|
#include "tests/meta-monitor-manager-test.h"
|
|
|
|
|
|
|
|
#define ALL_TRANSFORMS ((1 << (META_MONITOR_TRANSFORM_FLIPPED_270 + 1)) - 1)
|
|
|
|
|
2016-12-07 00:54:32 -05:00
|
|
|
#define MAX_N_MODES 10
|
|
|
|
#define MAX_N_OUTPUTS 10
|
|
|
|
#define MAX_N_CRTCS 10
|
2016-12-12 21:58:41 -05:00
|
|
|
#define MAX_N_MONITORS 10
|
2016-12-07 00:54:32 -05:00
|
|
|
#define MAX_N_LOGICAL_MONITORS 10
|
|
|
|
|
2016-12-12 22:45:43 -05:00
|
|
|
/*
|
|
|
|
* The following structures are used to define test cases.
|
|
|
|
*
|
|
|
|
* Each test case consists of a test case setup and a test case expectaction.
|
|
|
|
* and a expected result, consisting
|
|
|
|
* of an array of monitors, logical monitors and a screen size.
|
|
|
|
*
|
|
|
|
* TEST CASE SETUP:
|
|
|
|
*
|
|
|
|
* A test case setup consists of an array of modes, an array of outputs and an
|
|
|
|
* array of CRTCs.
|
|
|
|
*
|
|
|
|
* A mode has a width and height in pixels, and a refresh rate in updates per
|
|
|
|
* second.
|
|
|
|
*
|
|
|
|
* An output has an array of available modes, and a preferred mode. Modes are
|
|
|
|
* defined as indices into the modes array of the test case setup.
|
|
|
|
*
|
|
|
|
* It also has CRTc and an array of possible CRTCs. Crtcs are defined as indices
|
|
|
|
* into the CRTC array. The CRTC value -1 means no CRTC.
|
|
|
|
*
|
|
|
|
* It also has various meta data, such as physical dimension, tile info and
|
|
|
|
* scale.
|
|
|
|
*
|
|
|
|
* A CRTC only has a current mode. A mode is defined as an index into the modes
|
|
|
|
* array.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* TEST CASE EXPECTS:
|
|
|
|
*
|
|
|
|
* A test case expects consists of an array of monitors, an array of logical
|
|
|
|
* monitors, a output and crtc count, and a screen width.
|
|
|
|
*
|
|
|
|
* A monitor represents a physical monitor (such as an external monitor, or a
|
|
|
|
* laptop panel etc). A monitor consists of an array of outputs, defined by
|
|
|
|
* indices into the setup output array, and the physical dimensions.
|
|
|
|
*
|
|
|
|
* A logical monitor represents a region of the total screen area. It contains
|
|
|
|
* the expected layout and a scale.
|
|
|
|
*/
|
|
|
|
|
2016-12-07 00:54:32 -05:00
|
|
|
typedef struct _MonitorTestCaseMode
|
|
|
|
{
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
float refresh_rate;
|
|
|
|
} MonitorTestCaseMode;
|
|
|
|
|
|
|
|
typedef struct _MonitorTestCaseOutput
|
|
|
|
{
|
|
|
|
int crtc;
|
|
|
|
int modes[MAX_N_MODES];
|
|
|
|
int n_modes;
|
|
|
|
int preferred_mode;
|
|
|
|
int possible_crtcs[MAX_N_CRTCS];
|
|
|
|
int n_possible_crtcs;
|
|
|
|
int width_mm;
|
|
|
|
int height_mm;
|
2016-12-07 04:42:06 -05:00
|
|
|
MetaTileInfo tile_info;
|
2016-12-07 04:42:30 -05:00
|
|
|
int scale;
|
2016-12-07 00:54:32 -05:00
|
|
|
} MonitorTestCaseOutput;
|
|
|
|
|
|
|
|
typedef struct _MonitorTestCaseCrtc
|
|
|
|
{
|
|
|
|
int current_mode;
|
|
|
|
} MonitorTestCaseCrtc;
|
|
|
|
|
|
|
|
typedef struct _MonitorTestCaseSetup
|
|
|
|
{
|
|
|
|
MonitorTestCaseMode modes[MAX_N_MODES];
|
|
|
|
int n_modes;
|
|
|
|
|
|
|
|
MonitorTestCaseOutput outputs[MAX_N_OUTPUTS];
|
|
|
|
int n_outputs;
|
|
|
|
|
|
|
|
MonitorTestCaseCrtc crtcs[MAX_N_CRTCS];
|
|
|
|
int n_crtcs;
|
|
|
|
} MonitorTestCaseSetup;
|
|
|
|
|
2016-12-14 04:23:44 -05:00
|
|
|
typedef struct _MonitorTestCaseMonitorCrtcMode
|
|
|
|
{
|
|
|
|
int output;
|
|
|
|
int crtc_mode;
|
|
|
|
} MetaTestCaseMonitorCrtcMode;
|
|
|
|
|
|
|
|
typedef struct _MonitorTestCaseMonitorMode
|
|
|
|
{
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
MetaTestCaseMonitorCrtcMode crtc_modes[MAX_N_CRTCS];
|
|
|
|
} MetaMonitorTestCaseMonitorMode;
|
|
|
|
|
2016-12-12 21:58:41 -05:00
|
|
|
typedef struct _MonitorTestCaseMonitor
|
|
|
|
{
|
|
|
|
long outputs[MAX_N_OUTPUTS];
|
|
|
|
int n_outputs;
|
2016-12-14 04:23:44 -05:00
|
|
|
MetaMonitorTestCaseMonitorMode modes[MAX_N_MODES];
|
|
|
|
int n_modes;
|
2016-12-12 21:58:41 -05:00
|
|
|
int width_mm;
|
|
|
|
int height_mm;
|
|
|
|
} MonitorTestCaseMonitor;
|
|
|
|
|
2016-12-07 01:18:28 -05:00
|
|
|
typedef struct _MonitorTestCaseLogicalMonitor
|
|
|
|
{
|
|
|
|
MetaRectangle layout;
|
|
|
|
int scale;
|
|
|
|
} MonitorTestCaseLogicalMonitor;
|
|
|
|
|
|
|
|
typedef struct _MonitorTestCaseExpect
|
|
|
|
{
|
2016-12-12 21:58:41 -05:00
|
|
|
MonitorTestCaseMonitor monitors[MAX_N_MONITORS];
|
|
|
|
int n_monitors;
|
2016-12-07 01:18:28 -05:00
|
|
|
MonitorTestCaseLogicalMonitor logical_monitors[MAX_N_LOGICAL_MONITORS];
|
|
|
|
int n_logical_monitors;
|
|
|
|
int n_outputs;
|
|
|
|
int n_crtcs;
|
2016-12-13 07:11:48 -05:00
|
|
|
int n_tiled_monitors;
|
2016-12-07 01:18:28 -05:00
|
|
|
int screen_width;
|
|
|
|
int screen_height;
|
|
|
|
} MonitorTestCaseExpect;
|
|
|
|
|
2016-12-07 00:54:32 -05:00
|
|
|
typedef struct _MonitorTestCase
|
|
|
|
{
|
|
|
|
MonitorTestCaseSetup setup;
|
2016-12-07 01:18:28 -05:00
|
|
|
MonitorTestCaseExpect expect;
|
2016-12-07 00:54:32 -05:00
|
|
|
} MonitorTestCase;
|
|
|
|
|
|
|
|
static MonitorTestCase initial_test_case = {
|
|
|
|
.setup = {
|
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 1024,
|
|
|
|
.height = 768,
|
|
|
|
.refresh_rate = 60.0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_modes = 1,
|
|
|
|
.outputs = {
|
|
|
|
{
|
|
|
|
.crtc = 0,
|
|
|
|
.modes = { 0 },
|
|
|
|
.n_modes = 1,
|
|
|
|
.preferred_mode = 0,
|
|
|
|
.possible_crtcs = { 0 },
|
|
|
|
.n_possible_crtcs = 1,
|
|
|
|
.width_mm = 222,
|
|
|
|
.height_mm = 125
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.crtc = 1,
|
|
|
|
.modes = { 0 },
|
|
|
|
.n_modes = 1,
|
|
|
|
.preferred_mode = 0,
|
|
|
|
.possible_crtcs = { 1 },
|
|
|
|
.n_possible_crtcs = 1,
|
2016-12-12 21:58:41 -05:00
|
|
|
.width_mm = 220,
|
|
|
|
.height_mm = 124
|
2016-12-07 00:54:32 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_outputs = 2,
|
|
|
|
.crtcs = {
|
|
|
|
{
|
|
|
|
.current_mode = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.current_mode = 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_crtcs = 2
|
2016-12-07 01:18:28 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
.expect = {
|
2016-12-12 21:58:41 -05:00
|
|
|
.monitors = {
|
|
|
|
{
|
|
|
|
.outputs = { 0 },
|
|
|
|
.n_outputs = 1,
|
2016-12-14 04:23:44 -05:00
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 1024,
|
|
|
|
.height = 768,
|
|
|
|
.crtc_modes = {
|
|
|
|
{
|
|
|
|
.output = 0,
|
|
|
|
.crtc_mode = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_modes = 1,
|
2016-12-12 21:58:41 -05:00
|
|
|
.width_mm = 222,
|
|
|
|
.height_mm = 125
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.outputs = { 1 },
|
|
|
|
.n_outputs = 1,
|
2016-12-14 04:23:44 -05:00
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 1024,
|
|
|
|
.height = 768,
|
|
|
|
.crtc_modes = {
|
|
|
|
{
|
|
|
|
.output = 1,
|
|
|
|
.crtc_mode = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_modes = 1,
|
2016-12-12 21:58:41 -05:00
|
|
|
.width_mm = 220,
|
|
|
|
.height_mm = 124
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_monitors = 2,
|
2016-12-07 01:18:28 -05:00
|
|
|
.logical_monitors = {
|
|
|
|
{
|
|
|
|
.layout = { .x = 0, .y = 0, .width = 1024, .height = 768 },
|
|
|
|
.scale = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.layout = { .x = 1024, .y = 0, .width = 1024, .height = 768 },
|
|
|
|
.scale = 1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_logical_monitors = 2,
|
|
|
|
.n_outputs = 2,
|
|
|
|
.n_crtcs = 2,
|
|
|
|
.screen_width = 1024 * 2,
|
|
|
|
.screen_height = 768
|
2016-12-07 00:54:32 -05:00
|
|
|
}
|
|
|
|
};
|
2016-12-05 05:40:44 -05:00
|
|
|
|
2016-12-12 21:58:41 -05:00
|
|
|
static MetaOutput *
|
|
|
|
output_from_winsys_id (MetaMonitorManager *monitor_manager,
|
|
|
|
long winsys_id)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < monitor_manager->n_outputs; i++)
|
|
|
|
{
|
|
|
|
MetaOutput *output = &monitor_manager->outputs[i];
|
|
|
|
|
|
|
|
if (output->winsys_id == winsys_id)
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-12-14 04:23:44 -05:00
|
|
|
typedef struct _CheckMonitorModeData
|
|
|
|
{
|
|
|
|
MetaMonitorManager *monitor_manager;
|
|
|
|
MetaTestCaseMonitorCrtcMode *expect_crtc_mode_iter;
|
|
|
|
} CheckMonitorModeData;
|
|
|
|
|
|
|
|
static void
|
|
|
|
check_monitor_mode (MetaMonitor *monitor,
|
|
|
|
MetaMonitorMode *mode,
|
|
|
|
MetaMonitorCrtcMode *monitor_crtc_mode,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
CheckMonitorModeData *data = user_data;
|
|
|
|
MetaMonitorManager *monitor_manager = data->monitor_manager;
|
|
|
|
MetaOutput *output;
|
|
|
|
MetaCrtcMode *crtc_mode;
|
|
|
|
|
|
|
|
output = output_from_winsys_id (monitor_manager,
|
|
|
|
data->expect_crtc_mode_iter->output);
|
|
|
|
crtc_mode = &monitor_manager->modes[data->expect_crtc_mode_iter->crtc_mode];
|
|
|
|
|
|
|
|
g_assert (monitor_crtc_mode->output == output);
|
|
|
|
g_assert (monitor_crtc_mode->crtc_mode == crtc_mode);
|
|
|
|
|
|
|
|
data->expect_crtc_mode_iter++;
|
|
|
|
}
|
|
|
|
|
2016-12-05 05:40:44 -05:00
|
|
|
static void
|
2016-12-07 01:18:28 -05:00
|
|
|
check_monitor_configuration (MonitorTestCase *test_case)
|
2016-12-05 05:40:44 -05:00
|
|
|
{
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
2016-12-13 07:11:48 -05:00
|
|
|
MetaMonitorManagerTest *monitor_manager_test =
|
|
|
|
META_MONITOR_MANAGER_TEST (monitor_manager);
|
|
|
|
int tiled_monitor_count;
|
2016-12-12 21:58:41 -05:00
|
|
|
GList *monitors;
|
2016-12-07 01:18:28 -05:00
|
|
|
GList *logical_monitors;
|
|
|
|
int n_logical_monitors;
|
|
|
|
GList *l;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
g_assert (monitor_manager->screen_width == test_case->expect.screen_width);
|
|
|
|
g_assert (monitor_manager->screen_height == test_case->expect.screen_height);
|
|
|
|
g_assert ((int) monitor_manager->n_outputs == test_case->expect.n_outputs);
|
|
|
|
g_assert ((int) monitor_manager->n_crtcs == test_case->expect.n_crtcs);
|
2016-12-05 05:40:44 -05:00
|
|
|
|
2016-12-13 07:11:48 -05:00
|
|
|
tiled_monitor_count =
|
|
|
|
meta_monitor_manager_test_get_tiled_monitor_count (monitor_manager_test);
|
|
|
|
g_assert (tiled_monitor_count == test_case->expect.n_tiled_monitors);
|
|
|
|
|
2016-12-12 21:58:41 -05:00
|
|
|
monitors = meta_monitor_manager_get_monitors (monitor_manager);
|
|
|
|
g_assert ((int) g_list_length (monitors) == test_case->expect.n_monitors);
|
|
|
|
for (l = monitors, i = 0; l; l = l->next, i++)
|
|
|
|
{
|
|
|
|
MetaMonitor *monitor = l->data;
|
|
|
|
GList *outputs;
|
|
|
|
GList *l_output;
|
|
|
|
int j;
|
|
|
|
int width_mm, height_mm;
|
2016-12-14 04:23:44 -05:00
|
|
|
GList *modes;
|
|
|
|
GList *l_mode;
|
2016-12-12 21:58:41 -05:00
|
|
|
|
|
|
|
outputs = meta_monitor_get_outputs (monitor);
|
|
|
|
|
|
|
|
g_assert ((int) g_list_length (outputs) ==
|
|
|
|
test_case->expect.monitors[i].n_outputs);
|
|
|
|
|
|
|
|
for (l_output = outputs, j = 0; l_output; l_output = l_output->next, j++)
|
|
|
|
{
|
|
|
|
MetaOutput *output = l_output->data;
|
|
|
|
long winsys_id = test_case->expect.monitors[i].outputs[j];
|
|
|
|
|
|
|
|
g_assert (output == output_from_winsys_id (monitor_manager,
|
|
|
|
winsys_id));
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_monitor_get_physical_dimensions (monitor, &width_mm, &height_mm);
|
|
|
|
g_assert (width_mm == test_case->expect.monitors[i].width_mm);
|
|
|
|
g_assert (height_mm == test_case->expect.monitors[i].height_mm);
|
2016-12-14 04:23:44 -05:00
|
|
|
|
|
|
|
modes = meta_monitor_get_modes (monitor);
|
|
|
|
for (l_mode = modes, j = 0; l_mode; l_mode = l_mode->next, j++)
|
|
|
|
{
|
|
|
|
MetaMonitorMode *mode = l_mode->data;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
CheckMonitorModeData data;
|
|
|
|
|
|
|
|
meta_monitor_mode_get_resolution (mode, &width, &height);
|
|
|
|
|
|
|
|
g_assert (width == test_case->expect.monitors[i].modes[j].width);
|
|
|
|
g_assert (height == test_case->expect.monitors[i].modes[j].height);
|
|
|
|
|
|
|
|
data = (CheckMonitorModeData) {
|
|
|
|
.monitor_manager = monitor_manager,
|
|
|
|
.expect_crtc_mode_iter =
|
|
|
|
test_case->expect.monitors[i].modes[j].crtc_modes
|
|
|
|
};
|
|
|
|
meta_monitor_mode_foreach_crtc (monitor, mode,
|
|
|
|
check_monitor_mode,
|
|
|
|
&data);
|
|
|
|
}
|
2016-12-12 21:58:41 -05:00
|
|
|
}
|
|
|
|
|
2016-12-05 05:40:44 -05:00
|
|
|
n_logical_monitors =
|
|
|
|
meta_monitor_manager_get_num_logical_monitors (monitor_manager);
|
2016-12-07 01:18:28 -05:00
|
|
|
g_assert (n_logical_monitors == test_case->expect.n_logical_monitors);
|
2016-12-05 05:40:44 -05:00
|
|
|
|
|
|
|
logical_monitors =
|
|
|
|
meta_monitor_manager_get_logical_monitors (monitor_manager);
|
2016-12-07 01:18:28 -05:00
|
|
|
for (l = logical_monitors, i = 0; l; l = l->next, i++)
|
2016-12-05 05:40:44 -05:00
|
|
|
{
|
|
|
|
MetaLogicalMonitor *logical_monitor = l->data;
|
2016-12-07 01:18:28 -05:00
|
|
|
MonitorTestCaseLogicalMonitor *test_logical_monitor =
|
|
|
|
&test_case->expect.logical_monitors[i];
|
2016-12-13 08:44:16 -05:00
|
|
|
GList *monitors;
|
|
|
|
GList *l_monitor;
|
2016-12-07 01:18:28 -05:00
|
|
|
|
|
|
|
g_assert (logical_monitor->rect.x == test_logical_monitor->layout.x);
|
|
|
|
g_assert (logical_monitor->rect.y == test_logical_monitor->layout.y);
|
|
|
|
g_assert (logical_monitor->rect.width ==
|
|
|
|
test_logical_monitor->layout.width);
|
|
|
|
g_assert (logical_monitor->rect.height ==
|
|
|
|
test_logical_monitor->layout.height);
|
|
|
|
g_assert (logical_monitor->scale == test_logical_monitor->scale);
|
2016-12-12 21:59:53 -05:00
|
|
|
|
2016-12-13 08:44:16 -05:00
|
|
|
monitors = meta_logical_monitor_get_monitors (logical_monitor);
|
|
|
|
for (l_monitor = monitors; l_monitor; l_monitor = l_monitor->next)
|
2016-12-12 21:59:53 -05:00
|
|
|
{
|
2016-12-13 08:44:16 -05:00
|
|
|
MetaMonitor *monitor = l_monitor->data;
|
|
|
|
GList *outputs;
|
|
|
|
GList *l_output;
|
|
|
|
|
|
|
|
outputs = meta_monitor_get_outputs (monitor);
|
|
|
|
for (l_output = outputs; l_output; l_output = l_output->next)
|
|
|
|
{
|
|
|
|
MetaOutput *output = l_output->data;
|
2016-12-12 21:59:53 -05:00
|
|
|
|
2016-12-13 08:44:16 -05:00
|
|
|
g_assert (output->crtc->logical_monitor == logical_monitor);
|
|
|
|
}
|
2016-12-12 21:59:53 -05:00
|
|
|
}
|
2016-12-05 05:40:44 -05:00
|
|
|
}
|
2016-12-07 01:18:28 -05:00
|
|
|
g_assert (n_logical_monitors == i);
|
2016-12-05 05:40:44 -05:00
|
|
|
}
|
|
|
|
|
2016-12-07 00:54:32 -05:00
|
|
|
static MetaMonitorTestSetup *
|
|
|
|
create_monitor_test_setup (MonitorTestCase *test_case)
|
2016-12-05 08:28:22 -05:00
|
|
|
{
|
|
|
|
MetaMonitorTestSetup *test_setup;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
test_setup = g_new0 (MetaMonitorTestSetup, 1);
|
|
|
|
|
2016-12-07 00:54:32 -05:00
|
|
|
test_setup->n_modes = test_case->setup.n_modes;
|
2016-12-09 02:49:54 -05:00
|
|
|
test_setup->modes = g_new0 (MetaCrtcMode, test_setup->n_modes);
|
2016-12-07 00:54:32 -05:00
|
|
|
for (i = 0; i < test_setup->n_modes; i++)
|
|
|
|
{
|
2016-12-09 02:49:54 -05:00
|
|
|
test_setup->modes[i] = (MetaCrtcMode) {
|
2016-12-07 00:54:32 -05:00
|
|
|
.mode_id = i,
|
|
|
|
.width = test_case->setup.modes[i].width,
|
|
|
|
.height = test_case->setup.modes[i].height,
|
|
|
|
.refresh_rate = test_case->setup.modes[i].refresh_rate
|
|
|
|
};
|
|
|
|
}
|
2016-12-05 08:28:22 -05:00
|
|
|
|
2016-12-07 00:54:32 -05:00
|
|
|
test_setup->n_crtcs = test_case->setup.n_crtcs;
|
2016-12-07 23:15:28 -05:00
|
|
|
test_setup->crtcs = g_new0 (MetaCrtc, test_setup->n_crtcs);
|
2016-12-07 00:54:32 -05:00
|
|
|
for (i = 0; i < test_setup->n_crtcs; i++)
|
|
|
|
{
|
|
|
|
int current_mode_index;
|
2016-12-09 02:49:54 -05:00
|
|
|
MetaCrtcMode *current_mode;
|
2016-12-05 08:28:22 -05:00
|
|
|
|
2016-12-07 00:54:32 -05:00
|
|
|
current_mode_index = test_case->setup.crtcs[i].current_mode;
|
|
|
|
if (current_mode_index == -1)
|
|
|
|
current_mode = NULL;
|
|
|
|
else
|
|
|
|
current_mode = &test_setup->modes[current_mode_index];
|
2016-12-05 08:28:22 -05:00
|
|
|
|
2016-12-07 23:15:28 -05:00
|
|
|
test_setup->crtcs[i] = (MetaCrtc) {
|
2016-12-07 00:54:32 -05:00
|
|
|
.crtc_id = i + 1,
|
|
|
|
.current_mode = current_mode,
|
|
|
|
.transform = META_MONITOR_TRANSFORM_NORMAL,
|
|
|
|
.all_transforms = ALL_TRANSFORMS
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
test_setup->n_outputs = test_case->setup.n_outputs;
|
|
|
|
test_setup->outputs = g_new0 (MetaOutput, test_setup->n_outputs);
|
|
|
|
for (i = 0; i < test_setup->n_outputs; i++)
|
2016-12-05 08:28:22 -05:00
|
|
|
{
|
2016-12-07 00:54:32 -05:00
|
|
|
int crtc_index;
|
2016-12-07 23:15:28 -05:00
|
|
|
MetaCrtc *crtc;
|
2016-12-07 00:54:32 -05:00
|
|
|
int preferred_mode_index;
|
2016-12-09 02:49:54 -05:00
|
|
|
MetaCrtcMode *preferred_mode;
|
|
|
|
MetaCrtcMode **modes;
|
2016-12-07 00:54:32 -05:00
|
|
|
int n_modes;
|
|
|
|
int j;
|
2016-12-07 23:15:28 -05:00
|
|
|
MetaCrtc **possible_crtcs;
|
2016-12-07 00:54:32 -05:00
|
|
|
int n_possible_crtcs;
|
2016-12-07 04:42:30 -05:00
|
|
|
int scale;
|
2016-12-07 00:54:32 -05:00
|
|
|
|
|
|
|
crtc_index = test_case->setup.outputs[i].crtc;
|
|
|
|
if (crtc_index == -1)
|
|
|
|
crtc = NULL;
|
|
|
|
else
|
|
|
|
crtc = &test_setup->crtcs[crtc_index];
|
|
|
|
|
|
|
|
preferred_mode_index = test_case->setup.outputs[i].preferred_mode;
|
|
|
|
if (preferred_mode_index == -1)
|
|
|
|
preferred_mode = NULL;
|
|
|
|
else
|
|
|
|
preferred_mode = &test_setup->modes[preferred_mode_index];
|
|
|
|
|
|
|
|
n_modes = test_case->setup.outputs[i].n_modes;
|
2016-12-09 02:49:54 -05:00
|
|
|
modes = g_new0 (MetaCrtcMode *, n_modes);
|
2016-12-07 00:54:32 -05:00
|
|
|
for (j = 0; j < n_modes; j++)
|
|
|
|
{
|
|
|
|
int mode_index;
|
|
|
|
|
|
|
|
mode_index = test_case->setup.outputs[i].modes[j];
|
|
|
|
modes[j] = &test_setup->modes[mode_index];
|
|
|
|
}
|
|
|
|
|
|
|
|
n_possible_crtcs = test_case->setup.outputs[i].n_possible_crtcs;
|
2016-12-07 23:15:28 -05:00
|
|
|
possible_crtcs = g_new0 (MetaCrtc *, n_possible_crtcs);
|
2016-12-07 00:54:32 -05:00
|
|
|
for (j = 0; j < n_possible_crtcs; j++)
|
|
|
|
{
|
|
|
|
int possible_crtc_index;
|
|
|
|
|
|
|
|
possible_crtc_index = test_case->setup.outputs[i].possible_crtcs[j];
|
|
|
|
possible_crtcs[j] = &test_setup->crtcs[possible_crtc_index];
|
|
|
|
}
|
|
|
|
|
2016-12-07 04:42:30 -05:00
|
|
|
scale = test_case->setup.outputs[i].scale;
|
|
|
|
if (scale < 1)
|
|
|
|
scale = 1;
|
|
|
|
|
2016-12-07 00:54:32 -05:00
|
|
|
test_setup->outputs[i] = (MetaOutput) {
|
|
|
|
.crtc = crtc,
|
2016-12-12 21:58:41 -05:00
|
|
|
.winsys_id = i,
|
2016-12-07 00:54:32 -05:00
|
|
|
.name = g_strdup_printf ("LVDS%d", i + 1),
|
|
|
|
.vendor = g_strdup ("MetaProducts Inc."),
|
|
|
|
.product = g_strdup ("unknown"),
|
|
|
|
.serial = g_strdup ("0xC0FFEE"),
|
|
|
|
.suggested_x = -1,
|
|
|
|
.suggested_y = -1,
|
|
|
|
.hotplug_mode_update = TRUE, /* Results in config being ignored */
|
|
|
|
.width_mm = test_case->setup.outputs[i].width_mm,
|
|
|
|
.height_mm = test_case->setup.outputs[i].height_mm,
|
|
|
|
.subpixel_order = COGL_SUBPIXEL_ORDER_UNKNOWN,
|
|
|
|
.preferred_mode = preferred_mode,
|
|
|
|
.n_modes = n_modes,
|
|
|
|
.modes = modes,
|
|
|
|
.n_possible_crtcs = n_possible_crtcs,
|
|
|
|
.possible_crtcs = possible_crtcs,
|
|
|
|
.n_possible_clones = 0,
|
|
|
|
.possible_clones = NULL,
|
|
|
|
.backlight = -1,
|
|
|
|
.connector_type = META_CONNECTOR_TYPE_LVDS,
|
2016-12-07 04:42:06 -05:00
|
|
|
.tile_info = test_case->setup.outputs[i].tile_info,
|
2016-12-07 04:42:30 -05:00
|
|
|
.scale = scale
|
2016-12-07 00:54:32 -05:00
|
|
|
};
|
2016-12-05 08:28:22 -05:00
|
|
|
}
|
|
|
|
|
2016-12-07 00:54:32 -05:00
|
|
|
return test_setup;
|
2016-12-05 08:28:22 -05:00
|
|
|
}
|
|
|
|
|
2016-12-07 01:18:28 -05:00
|
|
|
static void
|
|
|
|
meta_test_monitor_initial_linear_config (void)
|
|
|
|
{
|
|
|
|
check_monitor_configuration (&initial_test_case);
|
|
|
|
}
|
|
|
|
|
2016-12-07 02:15:25 -05:00
|
|
|
static void
|
|
|
|
emulate_hotplug (MetaMonitorTestSetup *test_setup)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
|
|
|
MetaMonitorManagerTest *monitor_manager_test =
|
|
|
|
META_MONITOR_MANAGER_TEST (monitor_manager);
|
|
|
|
|
|
|
|
meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_test_monitor_one_disconnected_linear_config (void)
|
|
|
|
{
|
|
|
|
MonitorTestCase test_case = initial_test_case;
|
|
|
|
MetaMonitorTestSetup *test_setup;
|
|
|
|
|
|
|
|
test_case.setup.n_outputs = 1;
|
|
|
|
|
|
|
|
test_case.expect = (MonitorTestCaseExpect) {
|
2016-12-12 21:58:41 -05:00
|
|
|
.monitors = {
|
|
|
|
{
|
|
|
|
.outputs = { 0 },
|
|
|
|
.n_outputs = 1,
|
2016-12-14 04:23:44 -05:00
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 1024,
|
|
|
|
.height = 768,
|
|
|
|
.crtc_modes = {
|
|
|
|
{
|
|
|
|
.output = 0,
|
|
|
|
.crtc_mode = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_modes = 1,
|
2016-12-12 21:58:41 -05:00
|
|
|
.width_mm = 222,
|
|
|
|
.height_mm = 125
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_monitors = 1,
|
2016-12-07 02:15:25 -05:00
|
|
|
.logical_monitors = {
|
|
|
|
{
|
|
|
|
.layout = { .x = 0, .y = 0, .width = 1024, .height = 768 },
|
|
|
|
.scale = 1
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.n_logical_monitors = 1,
|
|
|
|
.n_outputs = 1,
|
|
|
|
.n_crtcs = 2,
|
|
|
|
.screen_width = 1024,
|
|
|
|
.screen_height = 768
|
|
|
|
};
|
|
|
|
|
|
|
|
test_setup = create_monitor_test_setup (&test_case);
|
|
|
|
emulate_hotplug (test_setup);
|
|
|
|
check_monitor_configuration (&test_case);
|
|
|
|
}
|
|
|
|
|
2016-12-07 02:16:12 -05:00
|
|
|
static void
|
|
|
|
meta_test_monitor_one_off_linear_config (void)
|
|
|
|
{
|
|
|
|
MonitorTestCase test_case;
|
|
|
|
MetaMonitorTestSetup *test_setup;
|
|
|
|
MonitorTestCaseOutput outputs[] = {
|
|
|
|
{
|
|
|
|
.crtc = 0,
|
|
|
|
.modes = { 0 },
|
|
|
|
.n_modes = 1,
|
|
|
|
.preferred_mode = 0,
|
|
|
|
.possible_crtcs = { 0 },
|
|
|
|
.n_possible_crtcs = 1,
|
|
|
|
.width_mm = 222,
|
|
|
|
.height_mm = 125
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.crtc = -1,
|
|
|
|
.modes = { 0 },
|
|
|
|
.n_modes = 1,
|
|
|
|
.preferred_mode = 0,
|
|
|
|
.possible_crtcs = { 1 },
|
|
|
|
.n_possible_crtcs = 1,
|
2016-12-12 21:58:41 -05:00
|
|
|
.width_mm = 224,
|
|
|
|
.height_mm = 126
|
2016-12-07 02:16:12 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
test_case = initial_test_case;
|
|
|
|
|
|
|
|
memcpy (&test_case.setup.outputs, &outputs, sizeof (outputs));
|
|
|
|
test_case.setup.n_outputs = G_N_ELEMENTS (outputs);
|
|
|
|
|
|
|
|
test_case.setup.crtcs[1].current_mode = -1;
|
|
|
|
|
|
|
|
test_case.expect = (MonitorTestCaseExpect) {
|
2016-12-12 21:58:41 -05:00
|
|
|
.monitors = {
|
|
|
|
{
|
|
|
|
.outputs = { 0 },
|
|
|
|
.n_outputs = 1,
|
2016-12-14 04:23:44 -05:00
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 1024,
|
|
|
|
.height = 768,
|
|
|
|
.crtc_modes = {
|
|
|
|
{
|
|
|
|
.output = 0,
|
|
|
|
.crtc_mode = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_modes = 1,
|
2016-12-12 21:58:41 -05:00
|
|
|
.width_mm = 222,
|
|
|
|
.height_mm = 125
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.outputs = { 1 },
|
|
|
|
.n_outputs = 1,
|
2016-12-14 04:23:44 -05:00
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 1024,
|
|
|
|
.height = 768,
|
|
|
|
.crtc_modes = {
|
|
|
|
{
|
|
|
|
.output = 1,
|
|
|
|
.crtc_mode = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_modes = 1,
|
2016-12-12 21:58:41 -05:00
|
|
|
.width_mm = 224,
|
|
|
|
.height_mm = 126
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_monitors = 2,
|
2016-12-07 02:16:12 -05:00
|
|
|
.logical_monitors = {
|
|
|
|
{
|
|
|
|
.layout = { .x = 0, .y = 0, .width = 1024, .height = 768 },
|
|
|
|
.scale = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.layout = { .x = 1024, .y = 0, .width = 1024, .height = 768 },
|
|
|
|
.scale = 1
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.n_logical_monitors = 2,
|
|
|
|
.n_outputs = 2,
|
|
|
|
.n_crtcs = 2,
|
|
|
|
.screen_width = 1024 * 2,
|
|
|
|
.screen_height = 768
|
|
|
|
};
|
|
|
|
|
|
|
|
test_setup = create_monitor_test_setup (&test_case);
|
|
|
|
emulate_hotplug (test_setup);
|
|
|
|
check_monitor_configuration (&test_case);
|
|
|
|
}
|
|
|
|
|
2016-12-07 02:33:45 -05:00
|
|
|
static void
|
|
|
|
meta_test_monitor_preferred_linear_config (void)
|
|
|
|
{
|
|
|
|
MonitorTestCase test_case = {
|
|
|
|
.setup = {
|
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 800,
|
|
|
|
.height = 600,
|
|
|
|
.refresh_rate = 60.0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.width = 1024,
|
|
|
|
.height = 768,
|
|
|
|
.refresh_rate = 60.0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.width = 1280,
|
|
|
|
.height = 720,
|
|
|
|
.refresh_rate = 60.0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_modes = 3,
|
|
|
|
.outputs = {
|
|
|
|
{
|
|
|
|
.crtc = -1,
|
|
|
|
.modes = { 0, 1, 2 },
|
|
|
|
.n_modes = 3,
|
|
|
|
.preferred_mode = 1,
|
|
|
|
.possible_crtcs = { 0 },
|
|
|
|
.n_possible_crtcs = 1,
|
|
|
|
.width_mm = 222,
|
|
|
|
.height_mm = 125
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_outputs = 1,
|
|
|
|
.crtcs = {
|
|
|
|
{
|
|
|
|
.current_mode = -1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_crtcs = 1
|
|
|
|
},
|
|
|
|
|
|
|
|
.expect = {
|
2016-12-12 21:58:41 -05:00
|
|
|
.monitors = {
|
|
|
|
{
|
|
|
|
.outputs = { 0 },
|
|
|
|
.n_outputs = 1,
|
2016-12-14 04:23:44 -05:00
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 800,
|
|
|
|
.height = 600,
|
|
|
|
.crtc_modes = {
|
|
|
|
{
|
|
|
|
.output = 0,
|
|
|
|
.crtc_mode = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.width = 1024,
|
|
|
|
.height = 768,
|
|
|
|
.crtc_modes = {
|
|
|
|
{
|
|
|
|
.output = 0,
|
|
|
|
.crtc_mode = 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.width = 1280,
|
|
|
|
.height = 720,
|
|
|
|
.crtc_modes = {
|
|
|
|
{
|
|
|
|
.output = 0,
|
|
|
|
.crtc_mode = 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_modes = 3,
|
2016-12-12 21:58:41 -05:00
|
|
|
.width_mm = 222,
|
|
|
|
.height_mm = 125
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_monitors = 1,
|
2016-12-07 02:33:45 -05:00
|
|
|
.logical_monitors = {
|
|
|
|
{
|
|
|
|
.layout = { .x = 0, .y = 0, .width = 1024, .height = 768 },
|
|
|
|
.scale = 1
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.n_logical_monitors = 1,
|
|
|
|
.n_outputs = 1,
|
|
|
|
.n_crtcs = 1,
|
|
|
|
.screen_width = 1024,
|
|
|
|
.screen_height = 768,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
MetaMonitorTestSetup *test_setup;
|
|
|
|
|
|
|
|
test_setup = create_monitor_test_setup (&test_case);
|
|
|
|
emulate_hotplug (test_setup);
|
|
|
|
check_monitor_configuration (&test_case);
|
|
|
|
}
|
|
|
|
|
2016-12-07 04:42:06 -05:00
|
|
|
static void
|
|
|
|
meta_test_monitor_tiled_linear_config (void)
|
|
|
|
{
|
|
|
|
MonitorTestCase test_case = {
|
|
|
|
.setup = {
|
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 400,
|
|
|
|
.height = 600,
|
|
|
|
.refresh_rate = 60.0
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.n_modes = 1,
|
|
|
|
.outputs = {
|
|
|
|
{
|
|
|
|
.crtc = -1,
|
|
|
|
.modes = { 0 },
|
|
|
|
.n_modes = 1,
|
|
|
|
.preferred_mode = 0,
|
|
|
|
.possible_crtcs = { 0 },
|
|
|
|
.n_possible_crtcs = 1,
|
|
|
|
.width_mm = 222,
|
|
|
|
.height_mm = 125,
|
|
|
|
.tile_info = {
|
|
|
|
.group_id = 1,
|
|
|
|
.max_h_tiles = 2,
|
|
|
|
.max_v_tiles = 1,
|
|
|
|
.loc_h_tile = 0,
|
|
|
|
.loc_v_tile = 0,
|
|
|
|
.tile_w = 400,
|
|
|
|
.tile_h = 600
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.crtc = -1,
|
|
|
|
.modes = { 0 },
|
|
|
|
.n_modes = 1,
|
|
|
|
.preferred_mode = 0,
|
|
|
|
.possible_crtcs = { 1 },
|
|
|
|
.n_possible_crtcs = 1,
|
|
|
|
.width_mm = 222,
|
|
|
|
.height_mm = 125,
|
|
|
|
.tile_info = {
|
|
|
|
.group_id = 1,
|
|
|
|
.max_h_tiles = 2,
|
|
|
|
.max_v_tiles = 1,
|
|
|
|
.loc_h_tile = 1,
|
|
|
|
.loc_v_tile = 0,
|
|
|
|
.tile_w = 400,
|
|
|
|
.tile_h = 600
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_outputs = 2,
|
|
|
|
.crtcs = {
|
|
|
|
{
|
|
|
|
.current_mode = -1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.current_mode = -1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_crtcs = 2
|
|
|
|
},
|
|
|
|
|
|
|
|
.expect = {
|
2016-12-12 21:58:41 -05:00
|
|
|
.monitors = {
|
|
|
|
{
|
|
|
|
.outputs = { 0, 1 },
|
|
|
|
.n_outputs = 2,
|
2016-12-14 04:23:44 -05:00
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 800,
|
|
|
|
.height = 600,
|
|
|
|
.crtc_modes = {
|
|
|
|
{
|
|
|
|
.output = 0,
|
|
|
|
.crtc_mode = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.output = 1,
|
|
|
|
.crtc_mode = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.n_modes = 1,
|
2016-12-12 21:58:41 -05:00
|
|
|
.width_mm = 222,
|
|
|
|
.height_mm = 125,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_monitors = 1,
|
2016-12-07 04:42:06 -05:00
|
|
|
.logical_monitors = {
|
|
|
|
{
|
|
|
|
.layout = { .x = 0, .y = 0, .width = 800, .height = 600 },
|
|
|
|
.scale = 1
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.n_logical_monitors = 1,
|
|
|
|
.n_outputs = 2,
|
|
|
|
.n_crtcs = 2,
|
2016-12-13 07:11:48 -05:00
|
|
|
.n_tiled_monitors = 1,
|
2016-12-07 04:42:06 -05:00
|
|
|
.screen_width = 800,
|
|
|
|
.screen_height = 600,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
MetaMonitorTestSetup *test_setup;
|
|
|
|
|
|
|
|
test_setup = create_monitor_test_setup (&test_case);
|
|
|
|
emulate_hotplug (test_setup);
|
|
|
|
check_monitor_configuration (&test_case);
|
|
|
|
}
|
|
|
|
|
2016-12-07 04:42:30 -05:00
|
|
|
static void
|
|
|
|
meta_test_monitor_hidpi_linear_config (void)
|
|
|
|
{
|
|
|
|
MonitorTestCase test_case = {
|
|
|
|
.setup = {
|
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 1280,
|
|
|
|
.height = 720,
|
|
|
|
.refresh_rate = 60.0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.width = 1024,
|
|
|
|
.height = 768,
|
|
|
|
.refresh_rate = 60.0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_modes = 2,
|
|
|
|
.outputs = {
|
|
|
|
{
|
|
|
|
.crtc = 0,
|
|
|
|
.modes = { 0 },
|
|
|
|
.n_modes = 1,
|
|
|
|
.preferred_mode = 0,
|
|
|
|
.possible_crtcs = { 0 },
|
|
|
|
.n_possible_crtcs = 1,
|
|
|
|
/* These will result in DPI of about 216" */
|
|
|
|
.width_mm = 150,
|
|
|
|
.height_mm = 85,
|
|
|
|
.scale = 2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.crtc = 1,
|
|
|
|
.modes = { 1 },
|
|
|
|
.n_modes = 1,
|
|
|
|
.preferred_mode = 1,
|
|
|
|
.possible_crtcs = { 1 },
|
|
|
|
.n_possible_crtcs = 1,
|
|
|
|
.width_mm = 222,
|
|
|
|
.height_mm = 125,
|
|
|
|
.scale = 1,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_outputs = 2,
|
|
|
|
.crtcs = {
|
|
|
|
{
|
|
|
|
.current_mode = -1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.current_mode = -1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_crtcs = 2
|
|
|
|
},
|
|
|
|
|
|
|
|
.expect = {
|
2016-12-12 21:58:41 -05:00
|
|
|
.monitors = {
|
|
|
|
{
|
|
|
|
.outputs = { 0 },
|
|
|
|
.n_outputs = 1,
|
2016-12-14 04:23:44 -05:00
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 1280,
|
|
|
|
.height = 720,
|
|
|
|
.crtc_modes = {
|
|
|
|
{
|
|
|
|
.output = 0,
|
|
|
|
.crtc_mode = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.n_modes = 1,
|
2016-12-12 21:58:41 -05:00
|
|
|
.width_mm = 150,
|
|
|
|
.height_mm = 85
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.outputs = { 1 },
|
|
|
|
.n_outputs = 1,
|
2016-12-14 04:23:44 -05:00
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 1024,
|
|
|
|
.height = 768,
|
|
|
|
.crtc_modes = {
|
|
|
|
{
|
|
|
|
.output = 1,
|
|
|
|
.crtc_mode = 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.n_modes = 1,
|
2016-12-12 21:58:41 -05:00
|
|
|
.width_mm = 222,
|
|
|
|
.height_mm = 125
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_monitors = 2,
|
2016-12-07 04:42:30 -05:00
|
|
|
.logical_monitors = {
|
|
|
|
{
|
|
|
|
.layout = { .x = 0, .y = 0, .width = 1280, .height = 720 },
|
|
|
|
.scale = 2
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.layout = { .x = 1280, .y = 0, .width = 1024, .height = 768 },
|
|
|
|
.scale = 1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_logical_monitors = 2,
|
|
|
|
.n_outputs = 2,
|
|
|
|
.n_crtcs = 2,
|
|
|
|
.screen_width = 1280 + 1024,
|
|
|
|
.screen_height = 768
|
|
|
|
}
|
|
|
|
};
|
|
|
|
MetaMonitorTestSetup *test_setup;
|
|
|
|
|
|
|
|
test_setup = create_monitor_test_setup (&test_case);
|
|
|
|
emulate_hotplug (test_setup);
|
|
|
|
check_monitor_configuration (&test_case);
|
|
|
|
}
|
|
|
|
|
2016-12-20 10:15:45 -05:00
|
|
|
static void
|
|
|
|
meta_test_monitor_suggested_config (void)
|
|
|
|
{
|
|
|
|
MonitorTestCase test_case = {
|
|
|
|
.setup = {
|
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 800,
|
|
|
|
.height = 600,
|
|
|
|
.refresh_rate = 60.0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.width = 1024,
|
|
|
|
.height = 768,
|
|
|
|
.refresh_rate = 60.0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_modes = 2,
|
|
|
|
.outputs = {
|
|
|
|
{
|
|
|
|
.crtc = 0,
|
|
|
|
.modes = { 0 },
|
|
|
|
.n_modes = 1,
|
|
|
|
.preferred_mode = 0,
|
|
|
|
.possible_crtcs = { 0 },
|
|
|
|
.n_possible_crtcs = 1,
|
|
|
|
.width_mm = 222,
|
|
|
|
.height_mm = 125
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.crtc = 1,
|
|
|
|
.modes = { 1 },
|
|
|
|
.n_modes = 1,
|
|
|
|
.preferred_mode = 1,
|
|
|
|
.possible_crtcs = { 1 },
|
|
|
|
.n_possible_crtcs = 1,
|
|
|
|
.width_mm = 220,
|
|
|
|
.height_mm = 124
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_outputs = 2,
|
|
|
|
.crtcs = {
|
|
|
|
{
|
|
|
|
.current_mode = -1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.current_mode = -1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_crtcs = 2
|
|
|
|
},
|
|
|
|
|
|
|
|
.expect = {
|
|
|
|
.monitors = {
|
|
|
|
{
|
|
|
|
.outputs = { 0 },
|
|
|
|
.n_outputs = 1,
|
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 800,
|
|
|
|
.height = 600,
|
|
|
|
.crtc_modes = {
|
|
|
|
{
|
|
|
|
.output = 0,
|
|
|
|
.crtc_mode = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_modes = 1,
|
|
|
|
.width_mm = 222,
|
|
|
|
.height_mm = 125
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.outputs = { 1 },
|
|
|
|
.n_outputs = 1,
|
|
|
|
.modes = {
|
|
|
|
{
|
|
|
|
.width = 1024,
|
|
|
|
.height = 768,
|
|
|
|
.crtc_modes = {
|
|
|
|
{
|
|
|
|
.output = 1,
|
|
|
|
.crtc_mode = 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_modes = 1,
|
|
|
|
.width_mm = 220,
|
|
|
|
.height_mm = 124
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_monitors = 2,
|
|
|
|
/*
|
|
|
|
* Logical monitors expectations altered to correspond to the
|
|
|
|
* "suggested_x/y" changed further below.
|
|
|
|
*/
|
|
|
|
.logical_monitors = {
|
|
|
|
{
|
|
|
|
.layout = { .x = 1024, .y = 758, .width = 800, .height = 600 },
|
|
|
|
.scale = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.layout = { .x = 0, .y = 0, .width = 1024, .height = 768 },
|
|
|
|
.scale = 1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.n_logical_monitors = 2,
|
|
|
|
.n_outputs = 2,
|
|
|
|
.n_crtcs = 2,
|
|
|
|
.n_tiled_monitors = 0,
|
|
|
|
.screen_width = 1024 + 800,
|
|
|
|
.screen_height = 1358
|
|
|
|
}
|
|
|
|
};
|
|
|
|
MetaMonitorTestSetup *test_setup;
|
|
|
|
|
|
|
|
test_setup = create_monitor_test_setup (&test_case);
|
|
|
|
|
|
|
|
test_setup->outputs[0].suggested_x = 1024;
|
|
|
|
test_setup->outputs[0].suggested_y = 758;
|
|
|
|
test_setup->outputs[1].suggested_x = 0;
|
|
|
|
test_setup->outputs[1].suggested_y = 0;
|
|
|
|
|
|
|
|
emulate_hotplug (test_setup);
|
|
|
|
check_monitor_configuration (&test_case);
|
|
|
|
}
|
|
|
|
|
2016-12-05 05:40:44 -05:00
|
|
|
void
|
|
|
|
init_monitor_tests (void)
|
|
|
|
{
|
2016-12-07 00:54:32 -05:00
|
|
|
MetaMonitorTestSetup *initial_test_setup;
|
|
|
|
|
|
|
|
initial_test_setup = create_monitor_test_setup (&initial_test_case);
|
|
|
|
meta_monitor_manager_test_init_test_setup (initial_test_setup);
|
2016-12-05 08:28:22 -05:00
|
|
|
|
2016-12-07 01:18:28 -05:00
|
|
|
g_test_add_func ("/backends/monitor/initial-linear-config",
|
|
|
|
meta_test_monitor_initial_linear_config);
|
2016-12-07 02:15:25 -05:00
|
|
|
g_test_add_func ("/backends/monitor/one-disconnected-linear-config",
|
|
|
|
meta_test_monitor_one_disconnected_linear_config);
|
2016-12-07 02:16:12 -05:00
|
|
|
g_test_add_func ("/backends/monitor/one-off-linear-config",
|
|
|
|
meta_test_monitor_one_off_linear_config);
|
2016-12-07 02:33:45 -05:00
|
|
|
g_test_add_func ("/backends/monitor/preferred-linear-config",
|
|
|
|
meta_test_monitor_preferred_linear_config);
|
2016-12-07 04:42:06 -05:00
|
|
|
g_test_add_func ("/backends/monitor/tiled-linear-config",
|
|
|
|
meta_test_monitor_tiled_linear_config);
|
2016-12-07 04:42:30 -05:00
|
|
|
g_test_add_func ("/backends/monitor/hidpi-linear-config",
|
|
|
|
meta_test_monitor_hidpi_linear_config);
|
2016-12-20 10:15:45 -05:00
|
|
|
g_test_add_func ("/backends/monitor/suggested-config",
|
|
|
|
meta_test_monitor_suggested_config);
|
2016-12-05 05:40:44 -05:00
|
|
|
}
|