1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2011 Intel Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci#include <gtest/gtest.h> 24bf215546Sopenharmony_ci#include <string.h> 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci#include "glxclient.h" 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci#include <xcb/glx.h> 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci#include "mock_xdisplay.h" 31bf215546Sopenharmony_ci#include "fake_glx_screen.h" 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_ci/** 34bf215546Sopenharmony_ci * \name Wrappers around some X structures to make the more usable for tests 35bf215546Sopenharmony_ci */ 36bf215546Sopenharmony_ci/*@{*/ 37bf215546Sopenharmony_ciclass fake_glx_screen; 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_ciclass fake_glx_display : public glx_display { 40bf215546Sopenharmony_cipublic: 41bf215546Sopenharmony_ci fake_glx_display(mock_XDisplay *dpy, int major, int minor) 42bf215546Sopenharmony_ci { 43bf215546Sopenharmony_ci this->next = 0; 44bf215546Sopenharmony_ci this->dpy = dpy; 45bf215546Sopenharmony_ci this->minorVersion = minor; 46bf215546Sopenharmony_ci this->glXDrawHash = 0; 47bf215546Sopenharmony_ci 48bf215546Sopenharmony_ci this->screens = new glx_screen *[dpy->nscreens]; 49bf215546Sopenharmony_ci memset(this->screens, 0, sizeof(struct glx_screen *) * dpy->nscreens); 50bf215546Sopenharmony_ci } 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_ci ~fake_glx_display() 53bf215546Sopenharmony_ci { 54bf215546Sopenharmony_ci for (int i = 0; i < this->dpy->nscreens; i++) { 55bf215546Sopenharmony_ci if (this->screens[i] != NULL) 56bf215546Sopenharmony_ci delete (fake_glx_screen *)this->screens[i]; 57bf215546Sopenharmony_ci } 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_ci delete [] this->screens; 60bf215546Sopenharmony_ci } 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci void init_screen(int i, const char *ext); 63bf215546Sopenharmony_ci}; 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_ciclass glX_send_client_info_test : public ::testing::Test { 66bf215546Sopenharmony_cipublic: 67bf215546Sopenharmony_ci glX_send_client_info_test(); 68bf215546Sopenharmony_ci virtual ~glX_send_client_info_test(); 69bf215546Sopenharmony_ci virtual void SetUp(); 70bf215546Sopenharmony_ci virtual void TearDown(); 71bf215546Sopenharmony_ci 72bf215546Sopenharmony_ci void common_protocol_expected_false_test(unsigned major, unsigned minor, 73bf215546Sopenharmony_ci const char *glx_ext, bool *value); 74bf215546Sopenharmony_ci 75bf215546Sopenharmony_ci void common_protocol_expected_true_test(unsigned major, unsigned minor, 76bf215546Sopenharmony_ci const char *glx_ext, bool *value); 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_ci void create_single_screen_display(unsigned major, unsigned minor, 79bf215546Sopenharmony_ci const char *glx_ext); 80bf215546Sopenharmony_ci 81bf215546Sopenharmony_ci void destroy_display(); 82bf215546Sopenharmony_ci 83bf215546Sopenharmony_ciprotected: 84bf215546Sopenharmony_ci fake_glx_display *glx_dpy; 85bf215546Sopenharmony_ci mock_XDisplay *display; 86bf215546Sopenharmony_ci}; 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_civoid 89bf215546Sopenharmony_cifake_glx_display::init_screen(int i, const char *ext) 90bf215546Sopenharmony_ci{ 91bf215546Sopenharmony_ci if (this->screens[i] != NULL) 92bf215546Sopenharmony_ci delete this->screens[i]; 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_ci this->screens[i] = new fake_glx_screen(this, i, ext); 95bf215546Sopenharmony_ci} 96bf215546Sopenharmony_ci/*@}*/ 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_cistatic const char ext[] = "GL_XXX_dummy"; 99bf215546Sopenharmony_ci 100bf215546Sopenharmony_cistatic bool ClientInfo_was_sent; 101bf215546Sopenharmony_cistatic bool SetClientInfoARB_was_sent; 102bf215546Sopenharmony_cistatic bool SetClientInfo2ARB_was_sent; 103bf215546Sopenharmony_cistatic xcb_connection_t *connection_used; 104bf215546Sopenharmony_cistatic int gl_ext_length; 105bf215546Sopenharmony_cistatic char *gl_ext_string; 106bf215546Sopenharmony_cistatic int glx_ext_length; 107bf215546Sopenharmony_cistatic char *glx_ext_string; 108bf215546Sopenharmony_cistatic int num_gl_versions; 109bf215546Sopenharmony_cistatic uint32_t *gl_versions; 110bf215546Sopenharmony_cistatic int glx_major; 111bf215546Sopenharmony_cistatic int glx_minor; 112bf215546Sopenharmony_ci 113bf215546Sopenharmony_ciextern "C" xcb_connection_t * 114bf215546Sopenharmony_ciXGetXCBConnection(Display *dpy) 115bf215546Sopenharmony_ci{ 116bf215546Sopenharmony_ci return (xcb_connection_t *) 0xdeadbeef; 117bf215546Sopenharmony_ci} 118bf215546Sopenharmony_ci 119bf215546Sopenharmony_ciextern "C" xcb_void_cookie_t 120bf215546Sopenharmony_cixcb_glx_client_info(xcb_connection_t *c, 121bf215546Sopenharmony_ci uint32_t major_version, 122bf215546Sopenharmony_ci uint32_t minor_version, 123bf215546Sopenharmony_ci uint32_t str_len, 124bf215546Sopenharmony_ci const char *string) 125bf215546Sopenharmony_ci{ 126bf215546Sopenharmony_ci xcb_void_cookie_t cookie; 127bf215546Sopenharmony_ci 128bf215546Sopenharmony_ci ClientInfo_was_sent = true; 129bf215546Sopenharmony_ci connection_used = c; 130bf215546Sopenharmony_ci 131bf215546Sopenharmony_ci gl_ext_string = new char[str_len]; 132bf215546Sopenharmony_ci memcpy(gl_ext_string, string, str_len); 133bf215546Sopenharmony_ci gl_ext_length = str_len; 134bf215546Sopenharmony_ci 135bf215546Sopenharmony_ci glx_major = major_version; 136bf215546Sopenharmony_ci glx_minor = minor_version; 137bf215546Sopenharmony_ci 138bf215546Sopenharmony_ci cookie.sequence = 0; 139bf215546Sopenharmony_ci return cookie; 140bf215546Sopenharmony_ci} 141bf215546Sopenharmony_ci 142bf215546Sopenharmony_ciextern "C" xcb_void_cookie_t 143bf215546Sopenharmony_cixcb_glx_set_client_info_arb(xcb_connection_t *c, 144bf215546Sopenharmony_ci uint32_t major_version, 145bf215546Sopenharmony_ci uint32_t minor_version, 146bf215546Sopenharmony_ci uint32_t num_versions, 147bf215546Sopenharmony_ci uint32_t gl_str_len, 148bf215546Sopenharmony_ci uint32_t glx_str_len, 149bf215546Sopenharmony_ci const uint32_t *versions, 150bf215546Sopenharmony_ci const char *gl_string, 151bf215546Sopenharmony_ci const char *glx_string) 152bf215546Sopenharmony_ci{ 153bf215546Sopenharmony_ci xcb_void_cookie_t cookie; 154bf215546Sopenharmony_ci 155bf215546Sopenharmony_ci SetClientInfoARB_was_sent = true; 156bf215546Sopenharmony_ci connection_used = c; 157bf215546Sopenharmony_ci 158bf215546Sopenharmony_ci gl_ext_string = new char[gl_str_len]; 159bf215546Sopenharmony_ci memcpy(gl_ext_string, gl_string, gl_str_len); 160bf215546Sopenharmony_ci gl_ext_length = gl_str_len; 161bf215546Sopenharmony_ci 162bf215546Sopenharmony_ci glx_ext_string = new char[glx_str_len]; 163bf215546Sopenharmony_ci memcpy(glx_ext_string, glx_string, glx_str_len); 164bf215546Sopenharmony_ci glx_ext_length = glx_str_len; 165bf215546Sopenharmony_ci 166bf215546Sopenharmony_ci gl_versions = new uint32_t[num_versions * 2]; 167bf215546Sopenharmony_ci memcpy(gl_versions, versions, sizeof(uint32_t) * num_versions * 2); 168bf215546Sopenharmony_ci num_gl_versions = num_versions; 169bf215546Sopenharmony_ci 170bf215546Sopenharmony_ci glx_major = major_version; 171bf215546Sopenharmony_ci glx_minor = minor_version; 172bf215546Sopenharmony_ci 173bf215546Sopenharmony_ci cookie.sequence = 0; 174bf215546Sopenharmony_ci return cookie; 175bf215546Sopenharmony_ci} 176bf215546Sopenharmony_ci 177bf215546Sopenharmony_ciextern "C" xcb_void_cookie_t 178bf215546Sopenharmony_cixcb_glx_set_client_info_2arb(xcb_connection_t *c, 179bf215546Sopenharmony_ci uint32_t major_version, 180bf215546Sopenharmony_ci uint32_t minor_version, 181bf215546Sopenharmony_ci uint32_t num_versions, 182bf215546Sopenharmony_ci uint32_t gl_str_len, 183bf215546Sopenharmony_ci uint32_t glx_str_len, 184bf215546Sopenharmony_ci const uint32_t *versions, 185bf215546Sopenharmony_ci const char *gl_string, 186bf215546Sopenharmony_ci const char *glx_string) 187bf215546Sopenharmony_ci{ 188bf215546Sopenharmony_ci xcb_void_cookie_t cookie; 189bf215546Sopenharmony_ci 190bf215546Sopenharmony_ci SetClientInfo2ARB_was_sent = true; 191bf215546Sopenharmony_ci connection_used = c; 192bf215546Sopenharmony_ci 193bf215546Sopenharmony_ci gl_ext_string = new char[gl_str_len]; 194bf215546Sopenharmony_ci memcpy(gl_ext_string, gl_string, gl_str_len); 195bf215546Sopenharmony_ci gl_ext_length = gl_str_len; 196bf215546Sopenharmony_ci 197bf215546Sopenharmony_ci glx_ext_string = new char[glx_str_len]; 198bf215546Sopenharmony_ci memcpy(glx_ext_string, glx_string, glx_str_len); 199bf215546Sopenharmony_ci glx_ext_length = glx_str_len; 200bf215546Sopenharmony_ci 201bf215546Sopenharmony_ci gl_versions = new uint32_t[num_versions * 3]; 202bf215546Sopenharmony_ci memcpy(gl_versions, versions, sizeof(uint32_t) * num_versions * 3); 203bf215546Sopenharmony_ci num_gl_versions = num_versions; 204bf215546Sopenharmony_ci 205bf215546Sopenharmony_ci glx_major = major_version; 206bf215546Sopenharmony_ci glx_minor = minor_version; 207bf215546Sopenharmony_ci 208bf215546Sopenharmony_ci cookie.sequence = 0; 209bf215546Sopenharmony_ci return cookie; 210bf215546Sopenharmony_ci} 211bf215546Sopenharmony_ci 212bf215546Sopenharmony_ciextern "C" char * 213bf215546Sopenharmony_ci__glXGetClientGLExtensionString() 214bf215546Sopenharmony_ci{ 215bf215546Sopenharmony_ci char *str = (char *) malloc(sizeof(ext)); 216bf215546Sopenharmony_ci 217bf215546Sopenharmony_ci memcpy(str, ext, sizeof(ext)); 218bf215546Sopenharmony_ci return str; 219bf215546Sopenharmony_ci} 220bf215546Sopenharmony_ci 221bf215546Sopenharmony_ciglX_send_client_info_test::glX_send_client_info_test() 222bf215546Sopenharmony_ci : glx_dpy(0), display(0) 223bf215546Sopenharmony_ci{ 224bf215546Sopenharmony_ci /* empty */ 225bf215546Sopenharmony_ci} 226bf215546Sopenharmony_ci 227bf215546Sopenharmony_ciglX_send_client_info_test::~glX_send_client_info_test() 228bf215546Sopenharmony_ci{ 229bf215546Sopenharmony_ci if (glx_dpy) 230bf215546Sopenharmony_ci delete glx_dpy; 231bf215546Sopenharmony_ci 232bf215546Sopenharmony_ci if (display) 233bf215546Sopenharmony_ci delete display; 234bf215546Sopenharmony_ci} 235bf215546Sopenharmony_ci 236bf215546Sopenharmony_civoid 237bf215546Sopenharmony_ciglX_send_client_info_test::SetUp() 238bf215546Sopenharmony_ci{ 239bf215546Sopenharmony_ci ClientInfo_was_sent = false; 240bf215546Sopenharmony_ci SetClientInfoARB_was_sent = false; 241bf215546Sopenharmony_ci SetClientInfo2ARB_was_sent = false; 242bf215546Sopenharmony_ci connection_used = (xcb_connection_t *) ~0; 243bf215546Sopenharmony_ci gl_ext_length = 0; 244bf215546Sopenharmony_ci gl_ext_string = (char *) 0; 245bf215546Sopenharmony_ci glx_ext_length = 0; 246bf215546Sopenharmony_ci glx_ext_string = (char *) 0; 247bf215546Sopenharmony_ci num_gl_versions = 0; 248bf215546Sopenharmony_ci gl_versions = (uint32_t *) 0; 249bf215546Sopenharmony_ci glx_major = 0; 250bf215546Sopenharmony_ci glx_minor = 0; 251bf215546Sopenharmony_ci} 252bf215546Sopenharmony_ci 253bf215546Sopenharmony_civoid 254bf215546Sopenharmony_ciglX_send_client_info_test::TearDown() 255bf215546Sopenharmony_ci{ 256bf215546Sopenharmony_ci if (gl_ext_string) 257bf215546Sopenharmony_ci delete [] gl_ext_string; 258bf215546Sopenharmony_ci if (glx_ext_string) 259bf215546Sopenharmony_ci delete [] glx_ext_string; 260bf215546Sopenharmony_ci if (gl_versions) 261bf215546Sopenharmony_ci delete [] gl_versions; 262bf215546Sopenharmony_ci} 263bf215546Sopenharmony_ci 264bf215546Sopenharmony_civoid 265bf215546Sopenharmony_ciglX_send_client_info_test::create_single_screen_display(unsigned major, 266bf215546Sopenharmony_ci unsigned minor, 267bf215546Sopenharmony_ci const char *glx_ext) 268bf215546Sopenharmony_ci{ 269bf215546Sopenharmony_ci this->display = new mock_XDisplay(1); 270bf215546Sopenharmony_ci 271bf215546Sopenharmony_ci this->glx_dpy = new fake_glx_display(this->display, major, minor); 272bf215546Sopenharmony_ci this->glx_dpy->init_screen(0, glx_ext); 273bf215546Sopenharmony_ci} 274bf215546Sopenharmony_ci 275bf215546Sopenharmony_civoid 276bf215546Sopenharmony_ciglX_send_client_info_test::common_protocol_expected_false_test(unsigned major, 277bf215546Sopenharmony_ci unsigned minor, 278bf215546Sopenharmony_ci const char *glx_ext, 279bf215546Sopenharmony_ci bool *value) 280bf215546Sopenharmony_ci{ 281bf215546Sopenharmony_ci create_single_screen_display(major, minor, glx_ext); 282bf215546Sopenharmony_ci __glX_send_client_info(this->glx_dpy); 283bf215546Sopenharmony_ci EXPECT_FALSE(*value); 284bf215546Sopenharmony_ci} 285bf215546Sopenharmony_ci 286bf215546Sopenharmony_civoid 287bf215546Sopenharmony_ciglX_send_client_info_test::common_protocol_expected_true_test(unsigned major, 288bf215546Sopenharmony_ci unsigned minor, 289bf215546Sopenharmony_ci const char *glx_ext, 290bf215546Sopenharmony_ci bool *value) 291bf215546Sopenharmony_ci{ 292bf215546Sopenharmony_ci create_single_screen_display(major, minor, glx_ext); 293bf215546Sopenharmony_ci __glX_send_client_info(this->glx_dpy); 294bf215546Sopenharmony_ci EXPECT_TRUE(*value); 295bf215546Sopenharmony_ci} 296bf215546Sopenharmony_ci 297bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, doesnt_send_ClientInfo_for_1_0) 298bf215546Sopenharmony_ci{ 299bf215546Sopenharmony_ci /* The glXClientInfo protocol was added in GLX 1.1. Verify that no 300bf215546Sopenharmony_ci * glXClientInfo is sent to a GLX server that only has GLX 1.0. 301bf215546Sopenharmony_ci */ 302bf215546Sopenharmony_ci common_protocol_expected_false_test(1, 0, "", &ClientInfo_was_sent); 303bf215546Sopenharmony_ci} 304bf215546Sopenharmony_ci 305bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_0) 306bf215546Sopenharmony_ci{ 307bf215546Sopenharmony_ci /* The glXSetClientInfoARB protocol was added in GLX 1.4 with the 308bf215546Sopenharmony_ci * GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is 309bf215546Sopenharmony_ci * sent to a GLX server that only has GLX 1.0 regardless of the extension 310bf215546Sopenharmony_ci * setting. 311bf215546Sopenharmony_ci */ 312bf215546Sopenharmony_ci common_protocol_expected_false_test(1, 0, 313bf215546Sopenharmony_ci "GLX_ARB_create_context", 314bf215546Sopenharmony_ci &SetClientInfoARB_was_sent); 315bf215546Sopenharmony_ci} 316bf215546Sopenharmony_ci 317bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_1) 318bf215546Sopenharmony_ci{ 319bf215546Sopenharmony_ci /* The glXSetClientInfoARB protocol was added in GLX 1.4 with the 320bf215546Sopenharmony_ci * GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is 321bf215546Sopenharmony_ci * sent to a GLX server that only has GLX 1.0 regardless of the extension 322bf215546Sopenharmony_ci * setting. 323bf215546Sopenharmony_ci */ 324bf215546Sopenharmony_ci common_protocol_expected_false_test(1, 1, 325bf215546Sopenharmony_ci "GLX_ARB_create_context", 326bf215546Sopenharmony_ci &SetClientInfoARB_was_sent); 327bf215546Sopenharmony_ci} 328bf215546Sopenharmony_ci 329bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_4_with_empty_extensions) 330bf215546Sopenharmony_ci{ 331bf215546Sopenharmony_ci /* The glXSetClientInfoARB protocol was added in GLX 1.4 with the 332bf215546Sopenharmony_ci * GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is 333bf215546Sopenharmony_ci * sent to a GLX server that has GLX 1.4 but has an empty extension string 334bf215546Sopenharmony_ci * (i.e., no extensions at all). 335bf215546Sopenharmony_ci */ 336bf215546Sopenharmony_ci common_protocol_expected_false_test(1, 4, 337bf215546Sopenharmony_ci "", 338bf215546Sopenharmony_ci &SetClientInfoARB_was_sent); 339bf215546Sopenharmony_ci} 340bf215546Sopenharmony_ci 341bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_4_without_extension) 342bf215546Sopenharmony_ci{ 343bf215546Sopenharmony_ci /* The glXSetClientInfoARB protocol was added in GLX 1.4 with the 344bf215546Sopenharmony_ci * GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is 345bf215546Sopenharmony_ci * sent to a GLX server that has GLX 1.4 but doesn't have the extension. 346bf215546Sopenharmony_ci */ 347bf215546Sopenharmony_ci common_protocol_expected_false_test(1, 4, 348bf215546Sopenharmony_ci "GLX_EXT_texture_from_pixmap", 349bf215546Sopenharmony_ci &SetClientInfoARB_was_sent); 350bf215546Sopenharmony_ci} 351bf215546Sopenharmony_ci 352bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_4_with_wrong_extension) 353bf215546Sopenharmony_ci{ 354bf215546Sopenharmony_ci /* The glXSetClientInfoARB protocol was added in GLX 1.4 with the 355bf215546Sopenharmony_ci * GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is 356bf215546Sopenharmony_ci * sent to a GLX server that has GLX 1.4 but does not have the extension. 357bf215546Sopenharmony_ci * 358bf215546Sopenharmony_ci * This test differs from 359bf215546Sopenharmony_ci * doesnt_send_SetClientInfoARB_for_1_4_without_extension in that an 360bf215546Sopenharmony_ci * extension exists that looks like the correct extension but isn't. 361bf215546Sopenharmony_ci */ 362bf215546Sopenharmony_ci common_protocol_expected_false_test(1, 4, 363bf215546Sopenharmony_ci "GLX_ARB_create_context2", 364bf215546Sopenharmony_ci &SetClientInfoARB_was_sent); 365bf215546Sopenharmony_ci} 366bf215546Sopenharmony_ci 367bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_4_with_profile_extension) 368bf215546Sopenharmony_ci{ 369bf215546Sopenharmony_ci /* The glXSetClientInfoARB protocol was added in GLX 1.4 with the 370bf215546Sopenharmony_ci * GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is 371bf215546Sopenharmony_ci * sent to a GLX server that has GLX 1.4 but does not have the extension. 372bf215546Sopenharmony_ci * 373bf215546Sopenharmony_ci * This test differs from 374bf215546Sopenharmony_ci * doesnt_send_SetClientInfoARB_for_1_4_without_extension in that an 375bf215546Sopenharmony_ci * extension exists that looks like the correct extension but isn't. 376bf215546Sopenharmony_ci */ 377bf215546Sopenharmony_ci common_protocol_expected_false_test(1, 4, 378bf215546Sopenharmony_ci "GLX_ARB_create_context_profile", 379bf215546Sopenharmony_ci &SetClientInfoARB_was_sent); 380bf215546Sopenharmony_ci} 381bf215546Sopenharmony_ci 382bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_0) 383bf215546Sopenharmony_ci{ 384bf215546Sopenharmony_ci /* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the 385bf215546Sopenharmony_ci * GLX_ARB_create_context_profile extension. Verify that no 386bf215546Sopenharmony_ci * glXSetClientInfo2ARB is sent to a GLX server that only has GLX 1.0 387bf215546Sopenharmony_ci * regardless of the extension setting. 388bf215546Sopenharmony_ci */ 389bf215546Sopenharmony_ci common_protocol_expected_false_test(1, 0, 390bf215546Sopenharmony_ci "GLX_ARB_create_context_profile", 391bf215546Sopenharmony_ci &SetClientInfo2ARB_was_sent); 392bf215546Sopenharmony_ci} 393bf215546Sopenharmony_ci 394bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_1) 395bf215546Sopenharmony_ci{ 396bf215546Sopenharmony_ci /* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the 397bf215546Sopenharmony_ci * GLX_ARB_create_context_profile extension. Verify that no 398bf215546Sopenharmony_ci * glXSetClientInfo2ARB is sent to a GLX server that only has GLX 1.1 399bf215546Sopenharmony_ci * regardless of the extension setting. 400bf215546Sopenharmony_ci */ 401bf215546Sopenharmony_ci common_protocol_expected_false_test(1, 1, 402bf215546Sopenharmony_ci "GLX_ARB_create_context_profile", 403bf215546Sopenharmony_ci &SetClientInfo2ARB_was_sent); 404bf215546Sopenharmony_ci} 405bf215546Sopenharmony_ci 406bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_4_with_empty_extensions) 407bf215546Sopenharmony_ci{ 408bf215546Sopenharmony_ci /* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the 409bf215546Sopenharmony_ci * GLX_ARB_create_context_profile extension. Verify that no 410bf215546Sopenharmony_ci * glXSetClientInfo2ARB is sent to a GLX server that has GLX 1.4 but has an 411bf215546Sopenharmony_ci * empty extension string (i.e., no extensions at all). 412bf215546Sopenharmony_ci */ 413bf215546Sopenharmony_ci common_protocol_expected_false_test(1, 4, 414bf215546Sopenharmony_ci "", 415bf215546Sopenharmony_ci &SetClientInfo2ARB_was_sent); 416bf215546Sopenharmony_ci} 417bf215546Sopenharmony_ci 418bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_4_without_extension) 419bf215546Sopenharmony_ci{ 420bf215546Sopenharmony_ci /* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the 421bf215546Sopenharmony_ci * GLX_ARB_create_context_profile extension. Verify that no 422bf215546Sopenharmony_ci * glXSetClientInfo2ARB is sent to a GLX server that has GLX 1.4 but 423bf215546Sopenharmony_ci * doesn't have the extension. 424bf215546Sopenharmony_ci */ 425bf215546Sopenharmony_ci common_protocol_expected_false_test(1, 4, 426bf215546Sopenharmony_ci "GLX_EXT_texture_from_pixmap", 427bf215546Sopenharmony_ci &SetClientInfo2ARB_was_sent); 428bf215546Sopenharmony_ci} 429bf215546Sopenharmony_ci 430bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_4_with_wrong_extension) 431bf215546Sopenharmony_ci{ 432bf215546Sopenharmony_ci /* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the 433bf215546Sopenharmony_ci * GLX_ARB_create_context_profile extension. Verify that no 434bf215546Sopenharmony_ci * glXSetClientInfo2ARB is sent to a GLX server that has GLX 1.4 but does 435bf215546Sopenharmony_ci * not have the extension. 436bf215546Sopenharmony_ci * 437bf215546Sopenharmony_ci * This test differs from 438bf215546Sopenharmony_ci * doesnt_send_SetClientInfo2ARB_for_1_4_without_extension in that an 439bf215546Sopenharmony_ci * extension exists that looks like the correct extension but isn't. 440bf215546Sopenharmony_ci */ 441bf215546Sopenharmony_ci common_protocol_expected_false_test(1, 4, 442bf215546Sopenharmony_ci "GLX_ARB_create_context_profile2", 443bf215546Sopenharmony_ci &SetClientInfo2ARB_was_sent); 444bf215546Sopenharmony_ci} 445bf215546Sopenharmony_ci 446bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, does_send_ClientInfo_for_1_1) 447bf215546Sopenharmony_ci{ 448bf215546Sopenharmony_ci /* The glXClientInfo protocol was added in GLX 1.1. Verify that 449bf215546Sopenharmony_ci * glXClientInfo is sent to a GLX server that has GLX 1.1. 450bf215546Sopenharmony_ci */ 451bf215546Sopenharmony_ci common_protocol_expected_true_test(1, 1, 452bf215546Sopenharmony_ci "", 453bf215546Sopenharmony_ci &ClientInfo_was_sent); 454bf215546Sopenharmony_ci} 455bf215546Sopenharmony_ci 456bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, does_send_SetClientInfoARB_for_1_4_with_extension) 457bf215546Sopenharmony_ci{ 458bf215546Sopenharmony_ci /* The glXSetClientInfoARB protocol was added in GLX 1.4 with the 459bf215546Sopenharmony_ci * GLX_ARB_create_context extension. Verify that glXSetClientInfoARB is 460bf215546Sopenharmony_ci * sent to a GLX server that has GLX 1.4 and the extension. 461bf215546Sopenharmony_ci */ 462bf215546Sopenharmony_ci common_protocol_expected_true_test(1, 4, 463bf215546Sopenharmony_ci "GLX_ARB_create_context", 464bf215546Sopenharmony_ci &SetClientInfoARB_was_sent); 465bf215546Sopenharmony_ci} 466bf215546Sopenharmony_ci 467bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, does_send_SetClientInfo2ARB_for_1_4_with_just_profile_extension) 468bf215546Sopenharmony_ci{ 469bf215546Sopenharmony_ci /* The glXSetClientInfoARB protocol was added in GLX 1.4 with the 470bf215546Sopenharmony_ci * GLX_ARB_create_context extension. Verify that glXSetClientInfoARB is 471bf215546Sopenharmony_ci * sent to a GLX server that has GLX 1.4 and the extension. 472bf215546Sopenharmony_ci */ 473bf215546Sopenharmony_ci common_protocol_expected_true_test(1, 4, 474bf215546Sopenharmony_ci "GLX_ARB_create_context_profile", 475bf215546Sopenharmony_ci &SetClientInfo2ARB_was_sent); 476bf215546Sopenharmony_ci} 477bf215546Sopenharmony_ci 478bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, does_send_SetClientInfo2ARB_for_1_4_with_both_extensions) 479bf215546Sopenharmony_ci{ 480bf215546Sopenharmony_ci /* The glXSetClientInfoARB protocol was added in GLX 1.4 with the 481bf215546Sopenharmony_ci * GLX_ARB_create_context extension. Verify that glXSetClientInfoARB is 482bf215546Sopenharmony_ci * sent to a GLX server that has GLX 1.4 and the extension. 483bf215546Sopenharmony_ci */ 484bf215546Sopenharmony_ci common_protocol_expected_true_test(1, 4, 485bf215546Sopenharmony_ci "GLX_ARB_create_context " 486bf215546Sopenharmony_ci "GLX_ARB_create_context_profile", 487bf215546Sopenharmony_ci &SetClientInfo2ARB_was_sent); 488bf215546Sopenharmony_ci} 489bf215546Sopenharmony_ci 490bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, does_send_SetClientInfo2ARB_for_1_4_with_both_extensions_reversed) 491bf215546Sopenharmony_ci{ 492bf215546Sopenharmony_ci /* The glXSetClientInfoARB protocol was added in GLX 1.4 with the 493bf215546Sopenharmony_ci * GLX_ARB_create_context extension. Verify that glXSetClientInfoARB is 494bf215546Sopenharmony_ci * sent to a GLX server that has GLX 1.4 and the extension. 495bf215546Sopenharmony_ci */ 496bf215546Sopenharmony_ci common_protocol_expected_true_test(1, 4, 497bf215546Sopenharmony_ci "GLX_ARB_create_context_profile " 498bf215546Sopenharmony_ci "GLX_ARB_create_context", 499bf215546Sopenharmony_ci &SetClientInfo2ARB_was_sent); 500bf215546Sopenharmony_ci} 501bf215546Sopenharmony_ci 502bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, uses_correct_connection) 503bf215546Sopenharmony_ci{ 504bf215546Sopenharmony_ci create_single_screen_display(1, 1, ""); 505bf215546Sopenharmony_ci __glX_send_client_info(this->glx_dpy); 506bf215546Sopenharmony_ci EXPECT_EQ((xcb_connection_t *) 0xdeadbeef, connection_used); 507bf215546Sopenharmony_ci} 508bf215546Sopenharmony_ci 509bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, sends_correct_gl_extension_string) 510bf215546Sopenharmony_ci{ 511bf215546Sopenharmony_ci create_single_screen_display(1, 1, ""); 512bf215546Sopenharmony_ci __glX_send_client_info(this->glx_dpy); 513bf215546Sopenharmony_ci 514bf215546Sopenharmony_ci ASSERT_EQ((int) sizeof(ext), gl_ext_length); 515bf215546Sopenharmony_ci ASSERT_NE((char *) 0, gl_ext_string); 516bf215546Sopenharmony_ci EXPECT_EQ(0, memcmp(gl_ext_string, ext, sizeof(ext))); 517bf215546Sopenharmony_ci} 518bf215546Sopenharmony_ci 519bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, gl_versions_are_sane) 520bf215546Sopenharmony_ci{ 521bf215546Sopenharmony_ci create_single_screen_display(1, 4, "GLX_ARB_create_context"); 522bf215546Sopenharmony_ci __glX_send_client_info(this->glx_dpy); 523bf215546Sopenharmony_ci 524bf215546Sopenharmony_ci ASSERT_NE(0, num_gl_versions); 525bf215546Sopenharmony_ci 526bf215546Sopenharmony_ci unsigned versions_below_3_0 = 0; 527bf215546Sopenharmony_ci for (int i = 0; i < num_gl_versions; i++) { 528bf215546Sopenharmony_ci EXPECT_LT(0u, gl_versions[i * 2]); 529bf215546Sopenharmony_ci EXPECT_GE(4u, gl_versions[i * 2]); 530bf215546Sopenharmony_ci 531bf215546Sopenharmony_ci /* Verify that the minor version advertised with the major version makes 532bf215546Sopenharmony_ci * sense. 533bf215546Sopenharmony_ci */ 534bf215546Sopenharmony_ci switch (gl_versions[i * 2]) { 535bf215546Sopenharmony_ci case 1: 536bf215546Sopenharmony_ci EXPECT_GE(5u, gl_versions[i * 2 + 1]); 537bf215546Sopenharmony_ci versions_below_3_0++; 538bf215546Sopenharmony_ci break; 539bf215546Sopenharmony_ci case 2: 540bf215546Sopenharmony_ci EXPECT_GE(1u, gl_versions[i * 2 + 1]); 541bf215546Sopenharmony_ci versions_below_3_0++; 542bf215546Sopenharmony_ci break; 543bf215546Sopenharmony_ci case 3: 544bf215546Sopenharmony_ci EXPECT_GE(3u, gl_versions[i * 2 + 1]); 545bf215546Sopenharmony_ci break; 546bf215546Sopenharmony_ci case 4: 547bf215546Sopenharmony_ci EXPECT_GE(2u, gl_versions[i * 2 + 1]); 548bf215546Sopenharmony_ci break; 549bf215546Sopenharmony_ci } 550bf215546Sopenharmony_ci } 551bf215546Sopenharmony_ci 552bf215546Sopenharmony_ci /* From the GLX_ARB_create_context spec: 553bf215546Sopenharmony_ci * 554bf215546Sopenharmony_ci * "Only the highest supported version below 3.0 should be sent, since 555bf215546Sopenharmony_ci * OpenGL 2.1 is backwards compatible with all earlier versions." 556bf215546Sopenharmony_ci */ 557bf215546Sopenharmony_ci EXPECT_LE(versions_below_3_0, 1u); 558bf215546Sopenharmony_ci} 559bf215546Sopenharmony_ci 560bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, gl_versions_and_profiles_are_sane) 561bf215546Sopenharmony_ci{ 562bf215546Sopenharmony_ci create_single_screen_display(1, 4, "GLX_ARB_create_context_profile"); 563bf215546Sopenharmony_ci __glX_send_client_info(this->glx_dpy); 564bf215546Sopenharmony_ci 565bf215546Sopenharmony_ci ASSERT_NE(0, num_gl_versions); 566bf215546Sopenharmony_ci 567bf215546Sopenharmony_ci const uint32_t all_valid_bits = GLX_CONTEXT_CORE_PROFILE_BIT_ARB 568bf215546Sopenharmony_ci | GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; 569bf215546Sopenharmony_ci const uint32_t es_bit = GLX_CONTEXT_ES2_PROFILE_BIT_EXT; 570bf215546Sopenharmony_ci 571bf215546Sopenharmony_ci unsigned versions_below_3_0 = 0; 572bf215546Sopenharmony_ci 573bf215546Sopenharmony_ci for (int i = 0; i < num_gl_versions; i++) { 574bf215546Sopenharmony_ci EXPECT_LT(0u, gl_versions[i * 3]); 575bf215546Sopenharmony_ci EXPECT_GE(4u, gl_versions[i * 3]); 576bf215546Sopenharmony_ci 577bf215546Sopenharmony_ci /* Verify that the minor version advertised with the major version makes 578bf215546Sopenharmony_ci * sense. 579bf215546Sopenharmony_ci */ 580bf215546Sopenharmony_ci switch (gl_versions[i * 3]) { 581bf215546Sopenharmony_ci case 1: 582bf215546Sopenharmony_ci if (gl_versions[i * 3 + 2] & es_bit) { 583bf215546Sopenharmony_ci EXPECT_GE(1u, gl_versions[i * 3 + 1]); 584bf215546Sopenharmony_ci EXPECT_EQ(es_bit, gl_versions[i * 3 + 2]); 585bf215546Sopenharmony_ci } else { 586bf215546Sopenharmony_ci EXPECT_GE(5u, gl_versions[i * 3 + 1]); 587bf215546Sopenharmony_ci EXPECT_EQ(0u, gl_versions[i * 3 + 2]); 588bf215546Sopenharmony_ci versions_below_3_0++; 589bf215546Sopenharmony_ci } 590bf215546Sopenharmony_ci break; 591bf215546Sopenharmony_ci case 2: 592bf215546Sopenharmony_ci if (gl_versions[i * 3 + 2] & es_bit) { 593bf215546Sopenharmony_ci EXPECT_EQ(0u, gl_versions[i * 3 + 1]); 594bf215546Sopenharmony_ci EXPECT_EQ(es_bit, gl_versions[i * 3 + 2]); 595bf215546Sopenharmony_ci } else { 596bf215546Sopenharmony_ci EXPECT_GE(1u, gl_versions[i * 3 + 1]); 597bf215546Sopenharmony_ci EXPECT_EQ(0u, gl_versions[i * 3 + 2]); 598bf215546Sopenharmony_ci versions_below_3_0++; 599bf215546Sopenharmony_ci } 600bf215546Sopenharmony_ci break; 601bf215546Sopenharmony_ci case 3: 602bf215546Sopenharmony_ci EXPECT_GE(3u, gl_versions[i * 3 + 1]); 603bf215546Sopenharmony_ci 604bf215546Sopenharmony_ci /* Profiles were not introduced until OpenGL 3.2. 605bf215546Sopenharmony_ci */ 606bf215546Sopenharmony_ci if (gl_versions[i * 3 + 1] < 2) { 607bf215546Sopenharmony_ci EXPECT_EQ(0u, gl_versions[i * 3 + 2] & ~(es_bit)); 608bf215546Sopenharmony_ci } else if (gl_versions[i * 3 + 1] == 2) { 609bf215546Sopenharmony_ci EXPECT_EQ(0u, gl_versions[i * 3 + 2] & ~(all_valid_bits | es_bit)); 610bf215546Sopenharmony_ci } else { 611bf215546Sopenharmony_ci EXPECT_EQ(0u, gl_versions[i * 3 + 2] & ~(all_valid_bits)); 612bf215546Sopenharmony_ci } 613bf215546Sopenharmony_ci break; 614bf215546Sopenharmony_ci case 4: 615bf215546Sopenharmony_ci EXPECT_GE(6u, gl_versions[i * 3 + 1]); 616bf215546Sopenharmony_ci EXPECT_EQ(0u, gl_versions[i * 3 + 2] & ~(all_valid_bits)); 617bf215546Sopenharmony_ci break; 618bf215546Sopenharmony_ci } 619bf215546Sopenharmony_ci } 620bf215546Sopenharmony_ci 621bf215546Sopenharmony_ci /* From the GLX_ARB_create_context_profile spec: 622bf215546Sopenharmony_ci * 623bf215546Sopenharmony_ci * "Only the highest supported version below 3.0 should be sent, since 624bf215546Sopenharmony_ci * OpenGL 2.1 is backwards compatible with all earlier versions." 625bf215546Sopenharmony_ci */ 626bf215546Sopenharmony_ci EXPECT_LE(versions_below_3_0, 1u); 627bf215546Sopenharmony_ci} 628bf215546Sopenharmony_ci 629bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_1) 630bf215546Sopenharmony_ci{ 631bf215546Sopenharmony_ci create_single_screen_display(1, 1, ""); 632bf215546Sopenharmony_ci __glX_send_client_info(this->glx_dpy); 633bf215546Sopenharmony_ci 634bf215546Sopenharmony_ci EXPECT_EQ(1, glx_major); 635bf215546Sopenharmony_ci EXPECT_EQ(4, glx_minor); 636bf215546Sopenharmony_ci} 637bf215546Sopenharmony_ci 638bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_4) 639bf215546Sopenharmony_ci{ 640bf215546Sopenharmony_ci create_single_screen_display(1, 4, ""); 641bf215546Sopenharmony_ci __glX_send_client_info(this->glx_dpy); 642bf215546Sopenharmony_ci 643bf215546Sopenharmony_ci EXPECT_EQ(1, glx_major); 644bf215546Sopenharmony_ci EXPECT_EQ(4, glx_minor); 645bf215546Sopenharmony_ci} 646bf215546Sopenharmony_ci 647bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_4_with_ARB_create_context) 648bf215546Sopenharmony_ci{ 649bf215546Sopenharmony_ci create_single_screen_display(1, 4, "GLX_ARB_create_context"); 650bf215546Sopenharmony_ci __glX_send_client_info(this->glx_dpy); 651bf215546Sopenharmony_ci 652bf215546Sopenharmony_ci EXPECT_EQ(1, glx_major); 653bf215546Sopenharmony_ci EXPECT_EQ(4, glx_minor); 654bf215546Sopenharmony_ci} 655bf215546Sopenharmony_ci 656bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_4_with_ARB_create_context_profile) 657bf215546Sopenharmony_ci{ 658bf215546Sopenharmony_ci create_single_screen_display(1, 4, "GLX_ARB_create_context_profile"); 659bf215546Sopenharmony_ci __glX_send_client_info(this->glx_dpy); 660bf215546Sopenharmony_ci 661bf215546Sopenharmony_ci EXPECT_EQ(1, glx_major); 662bf215546Sopenharmony_ci EXPECT_EQ(4, glx_minor); 663bf215546Sopenharmony_ci} 664bf215546Sopenharmony_ci 665bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_5) 666bf215546Sopenharmony_ci{ 667bf215546Sopenharmony_ci create_single_screen_display(1, 5, ""); 668bf215546Sopenharmony_ci __glX_send_client_info(this->glx_dpy); 669bf215546Sopenharmony_ci 670bf215546Sopenharmony_ci EXPECT_EQ(1, glx_major); 671bf215546Sopenharmony_ci EXPECT_EQ(4, glx_minor); 672bf215546Sopenharmony_ci} 673bf215546Sopenharmony_ci 674bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, glx_extensions_has_GLX_ARB_create_context) 675bf215546Sopenharmony_ci{ 676bf215546Sopenharmony_ci create_single_screen_display(1, 4, "GLX_ARB_create_context"); 677bf215546Sopenharmony_ci __glX_send_client_info(this->glx_dpy); 678bf215546Sopenharmony_ci 679bf215546Sopenharmony_ci ASSERT_NE(0, glx_ext_length); 680bf215546Sopenharmony_ci ASSERT_NE((char *) 0, glx_ext_string); 681bf215546Sopenharmony_ci 682bf215546Sopenharmony_ci bool found_GLX_ARB_create_context = false; 683bf215546Sopenharmony_ci const char *const needle = "GLX_ARB_create_context"; 684bf215546Sopenharmony_ci const unsigned len = strlen(needle); 685bf215546Sopenharmony_ci char *haystack = glx_ext_string; 686bf215546Sopenharmony_ci while (haystack != NULL) { 687bf215546Sopenharmony_ci char *match = strstr(haystack, needle); 688bf215546Sopenharmony_ci 689bf215546Sopenharmony_ci if (match[len] == '\0' || match[len] == ' ') { 690bf215546Sopenharmony_ci found_GLX_ARB_create_context = true; 691bf215546Sopenharmony_ci break; 692bf215546Sopenharmony_ci } 693bf215546Sopenharmony_ci 694bf215546Sopenharmony_ci haystack = match + len; 695bf215546Sopenharmony_ci } 696bf215546Sopenharmony_ci 697bf215546Sopenharmony_ci EXPECT_TRUE(found_GLX_ARB_create_context); 698bf215546Sopenharmony_ci} 699bf215546Sopenharmony_ci 700bf215546Sopenharmony_ciTEST_F(glX_send_client_info_test, glx_extensions_has_GLX_ARB_create_context_profile) 701bf215546Sopenharmony_ci{ 702bf215546Sopenharmony_ci create_single_screen_display(1, 4, "GLX_ARB_create_context_profile"); 703bf215546Sopenharmony_ci __glX_send_client_info(this->glx_dpy); 704bf215546Sopenharmony_ci 705bf215546Sopenharmony_ci ASSERT_NE(0, glx_ext_length); 706bf215546Sopenharmony_ci ASSERT_NE((char *) 0, glx_ext_string); 707bf215546Sopenharmony_ci 708bf215546Sopenharmony_ci bool found_GLX_ARB_create_context_profile = false; 709bf215546Sopenharmony_ci const char *const needle = "GLX_ARB_create_context_profile"; 710bf215546Sopenharmony_ci const unsigned len = strlen(needle); 711bf215546Sopenharmony_ci char *haystack = glx_ext_string; 712bf215546Sopenharmony_ci while (haystack != NULL) { 713bf215546Sopenharmony_ci char *match = strstr(haystack, needle); 714bf215546Sopenharmony_ci 715bf215546Sopenharmony_ci if (match[len] == '\0' || match[len] == ' ') { 716bf215546Sopenharmony_ci found_GLX_ARB_create_context_profile = true; 717bf215546Sopenharmony_ci break; 718bf215546Sopenharmony_ci } 719bf215546Sopenharmony_ci 720bf215546Sopenharmony_ci haystack = match + len; 721bf215546Sopenharmony_ci } 722bf215546Sopenharmony_ci 723bf215546Sopenharmony_ci EXPECT_TRUE(found_GLX_ARB_create_context_profile); 724bf215546Sopenharmony_ci} 725