Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 1 | /* |
Bryce Harrington | a20db38 | 2015-05-05 11:16:51 -0700 | [diff] [blame] | 2 | * Copyright © 2015 Samsung Electronics Co., Ltd |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 3 | * |
Bryce Harrington | 2cc9297 | 2015-06-11 15:39:40 -0700 | [diff] [blame^] | 4 | * Permission is hereby granted, free of charge, to any person obtaining |
| 5 | * a copy of this software and associated documentation files (the |
| 6 | * "Software"), to deal in the Software without restriction, including |
| 7 | * without limitation the rights to use, copy, modify, merge, publish, |
| 8 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 9 | * permit persons to whom the Software is furnished to do so, subject to |
| 10 | * the following conditions: |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 11 | * |
Bryce Harrington | 2cc9297 | 2015-06-11 15:39:40 -0700 | [diff] [blame^] | 12 | * The above copyright notice and this permission notice (including the |
| 13 | * next paragraph) shall be included in all copies or substantial |
| 14 | * portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 20 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 21 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | * SOFTWARE. |
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 | * xwayland-test: Confirm that we can map a window and we're running |
| 26 | * under Xwayland, not just X. |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 27 | * |
Derek Foreman | 8771a14 | 2015-01-29 16:44:55 -0600 | [diff] [blame] | 28 | * This is done in steps: |
| 29 | * 1) Confirm that the WL_SURFACE_ID atom exists |
| 30 | * 2) Confirm that the window manager's name is "Weston WM" |
| 31 | * 3) Make sure we can map a window |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 32 | */ |
| 33 | |
Bryce Harrington | 12cc405 | 2014-11-19 17:18:33 -0800 | [diff] [blame] | 34 | #include "config.h" |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 35 | |
Derek Foreman | 8771a14 | 2015-01-29 16:44:55 -0600 | [diff] [blame] | 36 | #include <unistd.h> |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 37 | #include <assert.h> |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 38 | #include <stdlib.h> |
| 39 | #include <stdio.h> |
Derek Foreman | 8771a14 | 2015-01-29 16:44:55 -0600 | [diff] [blame] | 40 | #include <X11/Xlib.h> |
| 41 | #include <X11/Xatom.h> |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 42 | #include <string.h> |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 43 | |
Bryce Harrington | 12cc405 | 2014-11-19 17:18:33 -0800 | [diff] [blame] | 44 | #include "weston-test-runner.h" |
| 45 | |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 46 | TEST(xwayland_client_test) |
| 47 | { |
Derek Foreman | 8771a14 | 2015-01-29 16:44:55 -0600 | [diff] [blame] | 48 | Display *display; |
| 49 | Window window, root, *support; |
| 50 | XEvent event; |
| 51 | int screen, status, actual_format; |
| 52 | unsigned long nitems, bytes; |
| 53 | Atom atom, type_atom, actual_type; |
| 54 | char *wm_name; |
| 55 | |
| 56 | display = XOpenDisplay(NULL); |
| 57 | if (!display) |
| 58 | exit(EXIT_FAILURE); |
| 59 | |
| 60 | atom = XInternAtom(display, "WL_SURFACE_ID", True); |
| 61 | assert(atom != None); |
| 62 | |
| 63 | atom = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", True); |
| 64 | assert(atom != None); |
| 65 | |
| 66 | screen = DefaultScreen(display); |
| 67 | root = RootWindow(display, screen); |
| 68 | |
| 69 | status = XGetWindowProperty(display, root, atom, 0L, ~0L, |
| 70 | False, XA_WINDOW, &actual_type, |
| 71 | &actual_format, &nitems, &bytes, |
| 72 | (void *)&support); |
| 73 | assert(status == Success); |
| 74 | |
| 75 | atom = XInternAtom(display, "_NET_WM_NAME", True); |
| 76 | assert(atom != None); |
| 77 | type_atom = XInternAtom(display, "UTF8_STRING", True); |
| 78 | assert(atom != None); |
| 79 | status = XGetWindowProperty(display, *support, atom, 0L, BUFSIZ, |
| 80 | False, type_atom, &actual_type, |
| 81 | &actual_format, &nitems, &bytes, |
| 82 | (void *)&wm_name); |
| 83 | assert(status == Success); |
| 84 | assert(nitems); |
| 85 | assert(strcmp("Weston WM", wm_name) == 0); |
| 86 | free(support); |
| 87 | free(wm_name); |
| 88 | |
| 89 | window = XCreateSimpleWindow(display, root, 100, 100, 300, 300, 1, |
| 90 | BlackPixel(display, screen), |
| 91 | WhitePixel(display, screen)); |
| 92 | XSelectInput(display, window, ExposureMask); |
| 93 | XMapWindow(display, window); |
| 94 | |
| 95 | alarm(4); |
| 96 | while (1) { |
| 97 | XNextEvent(display, &event); |
| 98 | if (event.type == Expose) |
| 99 | break; |
| 100 | } |
| 101 | |
| 102 | XCloseDisplay(display); |
Tiago Vignatti | 19dadf2 | 2013-02-08 14:57:00 +0200 | [diff] [blame] | 103 | exit(EXIT_SUCCESS); |
| 104 | } |