Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 1 | /* |
Derek Foreman | 8771a14 | 2015-01-29 16:44:55 -0600 | [diff] [blame^] | 2 | * Copyright © 2015 Samsung |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 3 | * |
| 4 | * Permission to use, copy, modify, distribute, and sell this software and |
| 5 | * its documentation for any purpose is hereby granted without fee, provided |
| 6 | * that the above copyright notice appear in all copies and that both that |
| 7 | * copyright notice and this permission notice appear in supporting |
| 8 | * documentation, and that the name of the copyright holders not be used in |
| 9 | * advertising or publicity pertaining to distribution of the software |
| 10 | * without specific, written prior permission. The copyright holders make |
| 11 | * no representations about the suitability of this software for any |
| 12 | * purpose. It is provided "as is" without express or implied warranty. |
| 13 | * |
| 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS |
| 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER |
| 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF |
| 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 21 | * |
Derek Foreman | 8771a14 | 2015-01-29 16:44:55 -0600 | [diff] [blame^] | 22 | * xwayland-test: Confirm that we can map a window and we're running |
| 23 | * under Xwayland, not just X. |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 24 | * |
Derek Foreman | 8771a14 | 2015-01-29 16:44:55 -0600 | [diff] [blame^] | 25 | * This is done in steps: |
| 26 | * 1) Confirm that the WL_SURFACE_ID atom exists |
| 27 | * 2) Confirm that the window manager's name is "Weston WM" |
| 28 | * 3) Make sure we can map a window |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 29 | */ |
| 30 | |
Bryce Harrington | 12cc405 | 2014-11-19 17:18:33 -0800 | [diff] [blame] | 31 | #include "config.h" |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 32 | |
Derek Foreman | 8771a14 | 2015-01-29 16:44:55 -0600 | [diff] [blame^] | 33 | #include <unistd.h> |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 34 | #include <assert.h> |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 35 | #include <stdlib.h> |
| 36 | #include <stdio.h> |
Derek Foreman | 8771a14 | 2015-01-29 16:44:55 -0600 | [diff] [blame^] | 37 | #include <X11/Xlib.h> |
| 38 | #include <X11/Xatom.h> |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 39 | #include <string.h> |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 40 | |
Bryce Harrington | 12cc405 | 2014-11-19 17:18:33 -0800 | [diff] [blame] | 41 | #include "weston-test-runner.h" |
| 42 | |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 43 | TEST(xwayland_client_test) |
| 44 | { |
Derek Foreman | 8771a14 | 2015-01-29 16:44:55 -0600 | [diff] [blame^] | 45 | Display *display; |
| 46 | Window window, root, *support; |
| 47 | XEvent event; |
| 48 | int screen, status, actual_format; |
| 49 | unsigned long nitems, bytes; |
| 50 | Atom atom, type_atom, actual_type; |
| 51 | char *wm_name; |
| 52 | |
| 53 | display = XOpenDisplay(NULL); |
| 54 | if (!display) |
| 55 | exit(EXIT_FAILURE); |
| 56 | |
| 57 | atom = XInternAtom(display, "WL_SURFACE_ID", True); |
| 58 | assert(atom != None); |
| 59 | |
| 60 | atom = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", True); |
| 61 | assert(atom != None); |
| 62 | |
| 63 | screen = DefaultScreen(display); |
| 64 | root = RootWindow(display, screen); |
| 65 | |
| 66 | status = XGetWindowProperty(display, root, atom, 0L, ~0L, |
| 67 | False, XA_WINDOW, &actual_type, |
| 68 | &actual_format, &nitems, &bytes, |
| 69 | (void *)&support); |
| 70 | assert(status == Success); |
| 71 | |
| 72 | atom = XInternAtom(display, "_NET_WM_NAME", True); |
| 73 | assert(atom != None); |
| 74 | type_atom = XInternAtom(display, "UTF8_STRING", True); |
| 75 | assert(atom != None); |
| 76 | status = XGetWindowProperty(display, *support, atom, 0L, BUFSIZ, |
| 77 | False, type_atom, &actual_type, |
| 78 | &actual_format, &nitems, &bytes, |
| 79 | (void *)&wm_name); |
| 80 | assert(status == Success); |
| 81 | assert(nitems); |
| 82 | assert(strcmp("Weston WM", wm_name) == 0); |
| 83 | free(support); |
| 84 | free(wm_name); |
| 85 | |
| 86 | window = XCreateSimpleWindow(display, root, 100, 100, 300, 300, 1, |
| 87 | BlackPixel(display, screen), |
| 88 | WhitePixel(display, screen)); |
| 89 | XSelectInput(display, window, ExposureMask); |
| 90 | XMapWindow(display, window); |
| 91 | |
| 92 | alarm(4); |
| 93 | while (1) { |
| 94 | XNextEvent(display, &event); |
| 95 | if (event.type == Expose) |
| 96 | break; |
| 97 | } |
| 98 | |
| 99 | XCloseDisplay(display); |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 100 | exit(EXIT_SUCCESS); |
| 101 | } |