1848b8605Smrg/*
2848b8605Smrg * Copyright © 2011 Intel Corporation
3848b8605Smrg *
4848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a
5848b8605Smrg * copy of this software and associated documentation files (the "Software"),
6848b8605Smrg * to deal in the Software without restriction, including without limitation
7848b8605Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8848b8605Smrg * and/or sell copies of the Software, and to permit persons to whom the
9848b8605Smrg * Software is furnished to do so, subject to the following conditions:
10848b8605Smrg *
11848b8605Smrg * The above copyright notice and this permission notice (including the next
12848b8605Smrg * paragraph) shall be included in all copies or substantial portions of the
13848b8605Smrg * Software.
14848b8605Smrg *
15848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16848b8605Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18848b8605Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19848b8605Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20848b8605Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21848b8605Smrg * DEALINGS IN THE SOFTWARE.
22848b8605Smrg */
23848b8605Smrg#include <gtest/gtest.h>
24848b8605Smrg#include <string.h>
25848b8605Smrg
26848b8605Smrg#include "glxclient.h"
27848b8605Smrg#include "glx_error.h"
28848b8605Smrg
29848b8605Smrg#include <xcb/glx.h>
30848b8605Smrg#include "mock_xdisplay.h"
31848b8605Smrg#include "fake_glx_screen.h"
32848b8605Smrg
33848b8605Smrgstatic bool CreateContextAttribsARB_was_sent;
34848b8605Smrgstatic xcb_glx_create_context_attribs_arb_request_t req;
35848b8605Smrgstatic uint32_t sent_attribs[1024];
36848b8605Smrgstatic uint32_t next_id;
37848b8605Smrg
38848b8605Smrg
39848b8605Smrgstruct glx_screen *psc;
40848b8605Smrg
41848b8605Smrgextern "C" Bool
42848b8605Smrgglx_context_init(struct glx_context *gc,
43848b8605Smrg		 struct glx_screen *psc, struct glx_config *config)
44848b8605Smrg{
45848b8605Smrg   gc->majorOpcode = 123;
46848b8605Smrg   gc->screen = psc->scr;
47848b8605Smrg   gc->psc = psc;
48848b8605Smrg   gc->config = config;
49848b8605Smrg   gc->isDirect = GL_TRUE;
50848b8605Smrg   gc->currentContextTag = -1;
51848b8605Smrg
52848b8605Smrg   return GL_TRUE;
53848b8605Smrg}
54848b8605Smrg
55848b8605Smrgbool GetGLXScreenConfigs_called = false;
56848b8605Smrg
57848b8605Smrgextern "C" struct glx_screen *
58848b8605SmrgGetGLXScreenConfigs(Display * dpy, int scrn)
59848b8605Smrg{
60848b8605Smrg   (void) dpy;
61848b8605Smrg   (void) scrn;
62848b8605Smrg
63848b8605Smrg   GetGLXScreenConfigs_called = true;
64848b8605Smrg   return psc;
65848b8605Smrg}
66848b8605Smrg
67848b8605Smrgextern "C" uint32_t
68848b8605Smrgxcb_generate_id(xcb_connection_t *c)
69848b8605Smrg{
70848b8605Smrg   (void) c;
71848b8605Smrg
72848b8605Smrg   return next_id++;
73848b8605Smrg}
74848b8605Smrg
75848b8605Smrgextern "C" xcb_void_cookie_t
76848b8605Smrgxcb_glx_create_context_attribs_arb_checked(xcb_connection_t *c,
77848b8605Smrg					   xcb_glx_context_t context,
78848b8605Smrg					   uint32_t fbconfig,
79848b8605Smrg					   uint32_t screen,
80848b8605Smrg					   uint32_t share_list,
81848b8605Smrg					   uint8_t is_direct,
82848b8605Smrg					   uint32_t num_attribs,
83848b8605Smrg					   const uint32_t *attribs)
84848b8605Smrg{
85848b8605Smrg   (void) c;
86848b8605Smrg
87848b8605Smrg   CreateContextAttribsARB_was_sent = true;
88848b8605Smrg   req.context = context;
89848b8605Smrg   req.fbconfig = fbconfig;
90848b8605Smrg   req.screen = screen;
91848b8605Smrg   req.share_list = share_list;
92848b8605Smrg   req.is_direct = is_direct;
93848b8605Smrg   req.num_attribs = num_attribs;
94848b8605Smrg
95848b8605Smrg   if (num_attribs != 0 && attribs != NULL)
96848b8605Smrg      memcpy(sent_attribs, attribs, num_attribs * 2 * sizeof(uint32_t));
97848b8605Smrg
98848b8605Smrg   xcb_void_cookie_t cookie;
99848b8605Smrg   cookie.sequence = 0xbadc0de;
100848b8605Smrg
101848b8605Smrg   return cookie;
102848b8605Smrg}
103848b8605Smrg
104848b8605Smrgextern "C" xcb_generic_error_t *
105848b8605Smrgxcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie)
106848b8605Smrg{
107848b8605Smrg   return NULL;
108848b8605Smrg}
109848b8605Smrg
110848b8605Smrgextern "C" void
111848b8605Smrg__glXSendErrorForXcb(Display * dpy, const xcb_generic_error_t *err)
112848b8605Smrg{
113848b8605Smrg}
114848b8605Smrg
115848b8605Smrgextern "C" void
116848b8605Smrg__glXSendError(Display * dpy, int_fast8_t errorCode, uint_fast32_t resourceID,
117848b8605Smrg               uint_fast16_t minorCode, bool coreX11error)
118848b8605Smrg{
119848b8605Smrg}
120848b8605Smrg
121848b8605Smrgclass glXCreateContextAttribARB_test : public ::testing::Test {
122848b8605Smrgpublic:
123848b8605Smrg   virtual void SetUp();
124848b8605Smrg
125848b8605Smrg   /**
126848b8605Smrg    * Replace the existing screen with a direct-rendering screen
127848b8605Smrg    */
128848b8605Smrg   void use_direct_rendering_screen();
129848b8605Smrg
130848b8605Smrg   mock_XDisplay *dpy;
131848b8605Smrg   struct glx_config fbc;
132848b8605Smrg};
133848b8605Smrg
134848b8605Smrgvoid
135848b8605SmrgglXCreateContextAttribARB_test::SetUp()
136848b8605Smrg{
137848b8605Smrg   CreateContextAttribsARB_was_sent = false;
138848b8605Smrg   memset(&req, 0, sizeof(req));
139848b8605Smrg   next_id = 99;
140848b8605Smrg   fake_glx_context::contexts_allocated = 0;
141848b8605Smrg   psc = new fake_glx_screen(NULL, 0, "");
142848b8605Smrg
143848b8605Smrg   this->dpy = new mock_XDisplay(1);
144848b8605Smrg
145848b8605Smrg   memset(&this->fbc, 0, sizeof(this->fbc));
146848b8605Smrg   this->fbc.fbconfigID = 0xbeefcafe;
147848b8605Smrg}
148848b8605Smrg
149848b8605Smrgvoid
150848b8605SmrgglXCreateContextAttribARB_test::use_direct_rendering_screen()
151848b8605Smrg{
152848b8605Smrg   struct glx_screen *direct_psc =
153848b8605Smrg      new fake_glx_screen_direct(psc->display,
154848b8605Smrg				 psc->scr,
155848b8605Smrg				 psc->serverGLXexts);
156848b8605Smrg
157848b8605Smrg   delete psc;
158848b8605Smrg   psc = direct_psc;
159848b8605Smrg}
160848b8605Smrg
161848b8605Smrg/**
162848b8605Smrg * \name Verify detection of client-side errors
163848b8605Smrg */
164848b8605Smrg/*@{*/
165848b8605SmrgTEST_F(glXCreateContextAttribARB_test, NULL_display_returns_None)
166848b8605Smrg{
167848b8605Smrg   GLXContext ctx =
168848b8605Smrg      glXCreateContextAttribsARB(NULL, (GLXFBConfig) &this->fbc, 0,
169848b8605Smrg				 False, NULL);
170848b8605Smrg
171848b8605Smrg   EXPECT_EQ(None, ctx);
172848b8605Smrg   EXPECT_EQ(0, fake_glx_context::contexts_allocated);
173848b8605Smrg}
174848b8605Smrg
175848b8605SmrgTEST_F(glXCreateContextAttribARB_test, NULL_fbconfig_returns_None)
176848b8605Smrg{
177848b8605Smrg   GLXContext ctx =
178848b8605Smrg      glXCreateContextAttribsARB(this->dpy, NULL, 0, False, NULL);
179848b8605Smrg
180848b8605Smrg   EXPECT_EQ(None, ctx);
181848b8605Smrg   EXPECT_EQ(0, fake_glx_context::contexts_allocated);
182848b8605Smrg}
183848b8605Smrg
184848b8605SmrgTEST_F(glXCreateContextAttribARB_test, NULL_screen_returns_None)
185848b8605Smrg{
186848b8605Smrg   delete psc;
187848b8605Smrg   psc = NULL;
188848b8605Smrg
189848b8605Smrg   GLXContext ctx =
190848b8605Smrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
191848b8605Smrg				 False, NULL);
192848b8605Smrg
193848b8605Smrg   EXPECT_EQ(None, ctx);
194848b8605Smrg   EXPECT_EQ(0, fake_glx_context::contexts_allocated);
195848b8605Smrg}
196848b8605Smrg/*@}*/
197848b8605Smrg
198848b8605Smrg/**
199848b8605Smrg * \name Verify that correct protocol bits are sent to the server.
200848b8605Smrg */
201848b8605Smrg/*@{*/
202848b8605SmrgTEST_F(glXCreateContextAttribARB_test, does_send_protocol)
203848b8605Smrg{
204848b8605Smrg   glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
205848b8605Smrg			      False, NULL);
206848b8605Smrg
207848b8605Smrg   EXPECT_TRUE(CreateContextAttribsARB_was_sent);
208848b8605Smrg}
209848b8605Smrg
210848b8605SmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_context)
211848b8605Smrg{
212848b8605Smrg   glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
213848b8605Smrg			      False, NULL);
214848b8605Smrg
215848b8605Smrg   EXPECT_EQ(99u, req.context);
216848b8605Smrg}
217848b8605Smrg
218848b8605SmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_fbconfig)
219848b8605Smrg{
220848b8605Smrg   glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
221848b8605Smrg			      False, NULL);
222848b8605Smrg
223848b8605Smrg   EXPECT_EQ(0xbeefcafe, req.fbconfig);
224848b8605Smrg}
225848b8605Smrg
226848b8605SmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_share_list)
227848b8605Smrg{
228848b8605Smrg   GLXContext share =
229848b8605Smrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
230848b8605Smrg				 False, NULL);
231848b8605Smrg
232848b8605Smrg   ASSERT_NE((GLXContext) 0, share);
233848b8605Smrg
234848b8605Smrg   glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, share,
235848b8605Smrg			      False, NULL);
236848b8605Smrg
237848b8605Smrg   struct glx_context *glx_ctx = (struct glx_context *) share;
238848b8605Smrg   EXPECT_EQ(glx_ctx->xid, req.share_list);
239848b8605Smrg}
240848b8605Smrg
241848b8605SmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_indirect_screen_and_direct_set_to_true)
242848b8605Smrg{
243848b8605Smrg   glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
244848b8605Smrg			      True, NULL);
245848b8605Smrg
246848b8605Smrg   EXPECT_FALSE(req.is_direct);
247848b8605Smrg}
248848b8605Smrg
249848b8605SmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_indirect_screen_and_direct_set_to_false)
250848b8605Smrg{
251848b8605Smrg   glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
252848b8605Smrg			      False, NULL);
253848b8605Smrg
254848b8605Smrg   EXPECT_FALSE(req.is_direct);
255848b8605Smrg}
256848b8605Smrg
257848b8605SmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_direct_screen_and_direct_set_to_true)
258848b8605Smrg{
259848b8605Smrg   this->use_direct_rendering_screen();
260848b8605Smrg
261848b8605Smrg   glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
262848b8605Smrg			      True, NULL);
263848b8605Smrg
264848b8605Smrg   EXPECT_TRUE(req.is_direct);
265848b8605Smrg}
266848b8605Smrg
267848b8605SmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_direct_screen_and_direct_set_to_false)
268848b8605Smrg{
269848b8605Smrg   this->use_direct_rendering_screen();
270848b8605Smrg
271848b8605Smrg   glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
272848b8605Smrg			      False, NULL);
273848b8605Smrg
274848b8605Smrg   EXPECT_FALSE(req.is_direct);
275848b8605Smrg}
276848b8605Smrg
277848b8605SmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_screen)
278848b8605Smrg{
279848b8605Smrg   this->fbc.screen = 7;
280848b8605Smrg   psc->scr = 7;
281848b8605Smrg
282848b8605Smrg   glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
283848b8605Smrg			      False, NULL);
284848b8605Smrg
285848b8605Smrg   EXPECT_EQ(7u, req.screen);
286848b8605Smrg}
287848b8605Smrg
288848b8605SmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_num_attribs)
289848b8605Smrg{
290848b8605Smrg   /* Use zeros in the second half of each attribute pair to try and trick the
291848b8605Smrg    * implementation into termiating the list early.
292848b8605Smrg    *
293848b8605Smrg    * Use non-zero in the second half of the last attribute pair to try and
294848b8605Smrg    * trick the implementation into not terminating the list early enough.
295848b8605Smrg    */
296848b8605Smrg   static const int attribs[] = {
297848b8605Smrg      1, 0,
298848b8605Smrg      2, 0,
299848b8605Smrg      3, 0,
300848b8605Smrg      4, 0,
301848b8605Smrg      0, 6,
302848b8605Smrg      0, 0
303848b8605Smrg   };
304848b8605Smrg
305848b8605Smrg   glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
306848b8605Smrg			      False, attribs);
307848b8605Smrg
308848b8605Smrg   EXPECT_EQ(4u, req.num_attribs);
309848b8605Smrg}
310848b8605Smrg
311848b8605SmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_num_attribs_empty_list)
312848b8605Smrg{
313848b8605Smrg   static const int attribs[] = {
314848b8605Smrg      0,
315848b8605Smrg   };
316848b8605Smrg
317848b8605Smrg   glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
318848b8605Smrg			      False, attribs);
319848b8605Smrg
320848b8605Smrg   EXPECT_EQ(0u, req.num_attribs);
321848b8605Smrg}
322848b8605Smrg
323848b8605SmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_num_attribs_NULL_list_pointer)
324848b8605Smrg{
325848b8605Smrg   glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
326848b8605Smrg			      False, NULL);
327848b8605Smrg
328848b8605Smrg   EXPECT_EQ(0u, req.num_attribs);
329848b8605Smrg}
330848b8605Smrg
331848b8605SmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_attrib_list)
332848b8605Smrg{
333848b8605Smrg   int attribs[] = {
334848b8605Smrg      GLX_RENDER_TYPE, GLX_RGBA_TYPE,
335848b8605Smrg      GLX_CONTEXT_MAJOR_VERSION_ARB, 1,
336848b8605Smrg      GLX_CONTEXT_MINOR_VERSION_ARB, 2,
337848b8605Smrg      0
338848b8605Smrg   };
339848b8605Smrg
340848b8605Smrg   glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
341848b8605Smrg			      False, attribs);
342848b8605Smrg
343848b8605Smrg   for (unsigned i = 0; i < 6; i++) {
344848b8605Smrg      EXPECT_EQ((uint32_t) attribs[i], sent_attribs[i]);
345848b8605Smrg   }
346848b8605Smrg}
347848b8605Smrg/*@}*/
348848b8605Smrg
349848b8605Smrg/**
350848b8605Smrg * \name Verify details of the returned GLXContext
351848b8605Smrg */
352848b8605Smrg/*@{*/
353848b8605SmrgTEST_F(glXCreateContextAttribARB_test, correct_context)
354848b8605Smrg{
355848b8605Smrg   GLXContext ctx =
356848b8605Smrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
357848b8605Smrg				 False, NULL);
358848b8605Smrg
359848b8605Smrg   /* Since the server did not return an error, the GLXContext should not be
360848b8605Smrg    * NULL.
361848b8605Smrg    */
362848b8605Smrg   EXPECT_NE((GLXContext)0, ctx);
363848b8605Smrg
364848b8605Smrg   /* It shouldn't be the XID of the context either.
365848b8605Smrg    */
366848b8605Smrg   EXPECT_NE((GLXContext)99, ctx);
367848b8605Smrg}
368848b8605Smrg
369848b8605SmrgTEST_F(glXCreateContextAttribARB_test, correct_context_xid)
370848b8605Smrg{
371848b8605Smrg   GLXContext ctx =
372848b8605Smrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
373848b8605Smrg				 False, NULL);
374848b8605Smrg
375848b8605Smrg   /* Since the server did not return an error, the GLXContext should not be
376848b8605Smrg    * NULL.
377848b8605Smrg    */
378848b8605Smrg   ASSERT_NE((GLXContext)0, ctx);
379848b8605Smrg
380848b8605Smrg   struct glx_context *glx_ctx = (struct glx_context *) ctx;
381848b8605Smrg   EXPECT_EQ(99u, glx_ctx->xid);
382848b8605Smrg}
383848b8605Smrg
384848b8605SmrgTEST_F(glXCreateContextAttribARB_test, correct_context_share_xid)
385848b8605Smrg{
386848b8605Smrg   GLXContext first =
387848b8605Smrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
388848b8605Smrg				 False, NULL);
389848b8605Smrg
390848b8605Smrg   ASSERT_NE((GLXContext) 0, first);
391848b8605Smrg
392848b8605Smrg   GLXContext second =
393848b8605Smrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, first,
394848b8605Smrg				 False, NULL);
395848b8605Smrg
396848b8605Smrg   ASSERT_NE((GLXContext) 0, second);
397848b8605Smrg
398848b8605Smrg   struct glx_context *share = (struct glx_context *) first;
399848b8605Smrg   struct glx_context *ctx = (struct glx_context *) second;
400848b8605Smrg   EXPECT_EQ(share->xid, ctx->share_xid);
401848b8605Smrg}
402848b8605Smrg
403848b8605SmrgTEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_indirect_screen_and_direct_set_to_true)
404848b8605Smrg{
405848b8605Smrg   GLXContext ctx =
406848b8605Smrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
407848b8605Smrg				 True, NULL);
408848b8605Smrg
409848b8605Smrg   ASSERT_NE((GLXContext) 0, ctx);
410848b8605Smrg
411848b8605Smrg   struct glx_context *gc = (struct glx_context *) ctx;
412848b8605Smrg
413848b8605Smrg   EXPECT_FALSE(gc->isDirect);
414848b8605Smrg}
415848b8605Smrg
416848b8605SmrgTEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_indirect_screen_and_direct_set_to_false)
417848b8605Smrg{
418848b8605Smrg   GLXContext ctx =
419848b8605Smrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
420848b8605Smrg				 False, NULL);
421848b8605Smrg
422848b8605Smrg   ASSERT_NE((GLXContext) 0, ctx);
423848b8605Smrg
424848b8605Smrg   struct glx_context *gc = (struct glx_context *) ctx;
425848b8605Smrg
426848b8605Smrg   EXPECT_FALSE(gc->isDirect);
427848b8605Smrg}
428848b8605Smrg
429848b8605SmrgTEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_direct_screen_and_direct_set_to_true)
430848b8605Smrg{
431848b8605Smrg   this->use_direct_rendering_screen();
432848b8605Smrg
433848b8605Smrg   GLXContext ctx =
434848b8605Smrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
435848b8605Smrg				 True, NULL);
436848b8605Smrg
437848b8605Smrg   ASSERT_NE((GLXContext) 0, ctx);
438848b8605Smrg
439848b8605Smrg   struct glx_context *gc = (struct glx_context *) ctx;
440848b8605Smrg
441848b8605Smrg   EXPECT_TRUE(gc->isDirect);
442848b8605Smrg}
443848b8605Smrg
444848b8605SmrgTEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_direct_screen_and_direct_set_to_false)
445848b8605Smrg{
446848b8605Smrg   this->use_direct_rendering_screen();
447848b8605Smrg
448848b8605Smrg   GLXContext ctx =
449848b8605Smrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
450848b8605Smrg				 False, NULL);
451848b8605Smrg
452848b8605Smrg   ASSERT_NE((GLXContext) 0, ctx);
453848b8605Smrg
454848b8605Smrg   struct glx_context *gc = (struct glx_context *) ctx;
455848b8605Smrg
456848b8605Smrg   EXPECT_FALSE(gc->isDirect);
457848b8605Smrg}
458848b8605Smrg
459848b8605SmrgTEST_F(glXCreateContextAttribARB_test, correct_indirect_context_client_state_private)
460848b8605Smrg{
461848b8605Smrg   GLXContext ctx =
462848b8605Smrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
463848b8605Smrg				 False, NULL);
464848b8605Smrg
465848b8605Smrg   ASSERT_NE((GLXContext) 0, ctx);
466848b8605Smrg
467848b8605Smrg   struct glx_context *gc = (struct glx_context *) ctx;
468848b8605Smrg
469848b8605Smrg   ASSERT_FALSE(gc->isDirect);
470848b8605Smrg   EXPECT_EQ((struct __GLXattributeRec *) 0xcafebabe,
471848b8605Smrg	     gc->client_state_private);
472848b8605Smrg}
473848b8605Smrg
474848b8605SmrgTEST_F(glXCreateContextAttribARB_test, correct_indirect_context_config)
475848b8605Smrg{
476848b8605Smrg   GLXContext ctx =
477848b8605Smrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
478848b8605Smrg				 False, NULL);
479848b8605Smrg
480848b8605Smrg   ASSERT_NE((GLXContext) 0, ctx);
481848b8605Smrg
482848b8605Smrg   struct glx_context *gc = (struct glx_context *) ctx;
483848b8605Smrg
484848b8605Smrg   EXPECT_EQ(&this->fbc, gc->config);
485848b8605Smrg}
486848b8605Smrg
487848b8605SmrgTEST_F(glXCreateContextAttribARB_test, correct_context_screen_number)
488848b8605Smrg{
489848b8605Smrg   this->fbc.screen = 7;
490848b8605Smrg   psc->scr = 7;
491848b8605Smrg
492848b8605Smrg   GLXContext ctx =
493848b8605Smrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
494848b8605Smrg				 False, NULL);
495848b8605Smrg
496848b8605Smrg   ASSERT_NE((GLXContext) 0, ctx);
497848b8605Smrg
498848b8605Smrg   struct glx_context *gc = (struct glx_context *) ctx;
499848b8605Smrg
500848b8605Smrg   EXPECT_EQ(7, gc->screen);
501848b8605Smrg}
502848b8605Smrg
503848b8605SmrgTEST_F(glXCreateContextAttribARB_test, correct_context_screen_pointer)
504848b8605Smrg{
505848b8605Smrg   GLXContext ctx =
506848b8605Smrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
507848b8605Smrg				 False, NULL);
508848b8605Smrg
509848b8605Smrg   ASSERT_NE((GLXContext) 0, ctx);
510848b8605Smrg
511848b8605Smrg   struct glx_context *gc = (struct glx_context *) ctx;
512848b8605Smrg
513848b8605Smrg   EXPECT_EQ(psc, gc->psc);
514848b8605Smrg}
515848b8605Smrg/*@}*/
516