2013-02-08 16:57:00 +04:00
|
|
|
/*
|
2015-05-05 21:16:51 +03:00
|
|
|
* Copyright © 2015 Samsung Electronics Co., Ltd
|
2013-02-08 16:57:00 +04:00
|
|
|
*
|
2015-06-12 01:39:40 +03:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
2013-02-08 16:57:00 +04:00
|
|
|
*
|
2015-06-12 01:39:40 +03:00
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial
|
|
|
|
* portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2013-02-08 16:57:00 +04:00
|
|
|
*
|
2015-01-30 01:44:55 +03:00
|
|
|
* xwayland-test: Confirm that we can map a window and we're running
|
|
|
|
* under Xwayland, not just X.
|
2013-02-08 16:57:00 +04:00
|
|
|
*
|
2015-01-30 01:44:55 +03:00
|
|
|
* This is done in steps:
|
|
|
|
* 1) Confirm that the WL_SURFACE_ID atom exists
|
|
|
|
* 2) Confirm that the window manager's name is "Weston WM"
|
|
|
|
* 3) Make sure we can map a window
|
2013-02-08 16:57:00 +04:00
|
|
|
*/
|
|
|
|
|
2014-11-20 04:18:33 +03:00
|
|
|
#include "config.h"
|
2013-02-08 16:57:00 +04:00
|
|
|
|
2015-01-30 01:44:55 +03:00
|
|
|
#include <unistd.h>
|
2013-02-08 16:57:00 +04:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2015-01-30 01:44:55 +03:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xatom.h>
|
2013-02-08 16:57:00 +04:00
|
|
|
#include <string.h>
|
|
|
|
|
2014-11-20 04:18:33 +03:00
|
|
|
#include "weston-test-runner.h"
|
2019-11-13 17:41:46 +03:00
|
|
|
#include "weston-test-fixture-compositor.h"
|
|
|
|
|
|
|
|
static enum test_result_code
|
|
|
|
fixture_setup(struct weston_test_harness *harness)
|
|
|
|
{
|
|
|
|
struct compositor_setup setup;
|
|
|
|
|
|
|
|
compositor_setup_defaults(&setup);
|
|
|
|
setup.xwayland = true;
|
|
|
|
|
|
|
|
return weston_test_harness_execute_as_client(harness, &setup);
|
|
|
|
}
|
|
|
|
DECLARE_FIXTURE_SETUP(fixture_setup);
|
2014-11-20 04:18:33 +03:00
|
|
|
|
2015-01-30 01:44:55 +03:00
|
|
|
TEST(xwayland_client_test)
|
2013-02-08 16:57:00 +04:00
|
|
|
{
|
2015-01-30 01:44:55 +03:00
|
|
|
Display *display;
|
|
|
|
Window window, root, *support;
|
|
|
|
XEvent event;
|
|
|
|
int screen, status, actual_format;
|
|
|
|
unsigned long nitems, bytes;
|
|
|
|
Atom atom, type_atom, actual_type;
|
|
|
|
char *wm_name;
|
|
|
|
|
2016-11-29 14:05:49 +03:00
|
|
|
if (access(XSERVER_PATH, X_OK) != 0)
|
|
|
|
exit(77);
|
|
|
|
|
2015-01-30 01:44:55 +03:00
|
|
|
display = XOpenDisplay(NULL);
|
|
|
|
if (!display)
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
|
|
|
atom = XInternAtom(display, "WL_SURFACE_ID", True);
|
|
|
|
assert(atom != None);
|
|
|
|
|
|
|
|
atom = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", True);
|
|
|
|
assert(atom != None);
|
|
|
|
|
|
|
|
screen = DefaultScreen(display);
|
|
|
|
root = RootWindow(display, screen);
|
|
|
|
|
|
|
|
status = XGetWindowProperty(display, root, atom, 0L, ~0L,
|
|
|
|
False, XA_WINDOW, &actual_type,
|
|
|
|
&actual_format, &nitems, &bytes,
|
|
|
|
(void *)&support);
|
|
|
|
assert(status == Success);
|
|
|
|
|
|
|
|
atom = XInternAtom(display, "_NET_WM_NAME", True);
|
|
|
|
assert(atom != None);
|
|
|
|
type_atom = XInternAtom(display, "UTF8_STRING", True);
|
|
|
|
assert(atom != None);
|
|
|
|
status = XGetWindowProperty(display, *support, atom, 0L, BUFSIZ,
|
|
|
|
False, type_atom, &actual_type,
|
|
|
|
&actual_format, &nitems, &bytes,
|
|
|
|
(void *)&wm_name);
|
|
|
|
assert(status == Success);
|
|
|
|
assert(nitems);
|
|
|
|
assert(strcmp("Weston WM", wm_name) == 0);
|
|
|
|
free(support);
|
|
|
|
free(wm_name);
|
|
|
|
|
|
|
|
window = XCreateSimpleWindow(display, root, 100, 100, 300, 300, 1,
|
|
|
|
BlackPixel(display, screen),
|
|
|
|
WhitePixel(display, screen));
|
|
|
|
XSelectInput(display, window, ExposureMask);
|
|
|
|
XMapWindow(display, window);
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
XNextEvent(display, &event);
|
|
|
|
if (event.type == Expose)
|
|
|
|
break;
|
2013-02-08 16:57:00 +04:00
|
|
|
}
|
|
|
|
|
2015-01-30 01:44:55 +03:00
|
|
|
XCloseDisplay(display);
|
2013-02-08 16:57:00 +04:00
|
|
|
}
|