1af69d88dSmrg/*
2af69d88dSmrg * Copyright © 2011 Intel Corporation
3af69d88dSmrg *
4af69d88dSmrg * Permission is hereby granted, free of charge, to any person obtaining a
5af69d88dSmrg * copy of this software and associated documentation files (the "Software"),
6af69d88dSmrg * to deal in the Software without restriction, including without limitation
7af69d88dSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8af69d88dSmrg * and/or sell copies of the Software, and to permit persons to whom the
9af69d88dSmrg * Software is furnished to do so, subject to the following conditions:
10af69d88dSmrg *
11af69d88dSmrg * The above copyright notice and this permission notice (including the next
12af69d88dSmrg * paragraph) shall be included in all copies or substantial portions of the
13af69d88dSmrg * Software.
14af69d88dSmrg *
15af69d88dSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16af69d88dSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17af69d88dSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19af69d88dSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20af69d88dSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21af69d88dSmrg * DEALINGS IN THE SOFTWARE.
22af69d88dSmrg */
23af69d88dSmrg#include <gtest/gtest.h>
24af69d88dSmrg#include <string.h>
25af69d88dSmrg
26af69d88dSmrg#include "glxclient.h"
27af69d88dSmrg#include "glx_error.h"
28af69d88dSmrg
29af69d88dSmrg#include <xcb/glx.h>
30af69d88dSmrg#include "mock_xdisplay.h"
31af69d88dSmrg#include "fake_glx_screen.h"
32af69d88dSmrg
33af69d88dSmrgstatic bool CreateContextAttribsARB_was_sent;
34af69d88dSmrgstatic xcb_glx_create_context_attribs_arb_request_t req;
35af69d88dSmrgstatic uint32_t sent_attribs[1024];
36af69d88dSmrgstatic uint32_t next_id;
37af69d88dSmrg
38af69d88dSmrg
39af69d88dSmrgstruct glx_screen *psc;
40af69d88dSmrg
41af69d88dSmrgextern "C" Bool
42af69d88dSmrgglx_context_init(struct glx_context *gc,
43af69d88dSmrg		 struct glx_screen *psc, struct glx_config *config)
44af69d88dSmrg{
45af69d88dSmrg   gc->majorOpcode = 123;
46af69d88dSmrg   gc->screen = psc->scr;
47af69d88dSmrg   gc->psc = psc;
48af69d88dSmrg   gc->config = config;
49af69d88dSmrg   gc->isDirect = GL_TRUE;
50af69d88dSmrg   gc->currentContextTag = -1;
51af69d88dSmrg
52af69d88dSmrg   return GL_TRUE;
53af69d88dSmrg}
54af69d88dSmrg
55af69d88dSmrgbool GetGLXScreenConfigs_called = false;
56af69d88dSmrg
57af69d88dSmrgextern "C" struct glx_screen *
58af69d88dSmrgGetGLXScreenConfigs(Display * dpy, int scrn)
59af69d88dSmrg{
60af69d88dSmrg   (void) dpy;
61af69d88dSmrg   (void) scrn;
62af69d88dSmrg
63af69d88dSmrg   GetGLXScreenConfigs_called = true;
64af69d88dSmrg   return psc;
65af69d88dSmrg}
66af69d88dSmrg
67af69d88dSmrgextern "C" uint32_t
68af69d88dSmrgxcb_generate_id(xcb_connection_t *c)
69af69d88dSmrg{
70af69d88dSmrg   (void) c;
71af69d88dSmrg
72af69d88dSmrg   return next_id++;
73af69d88dSmrg}
74af69d88dSmrg
75af69d88dSmrgextern "C" xcb_void_cookie_t
76af69d88dSmrgxcb_glx_create_context_attribs_arb_checked(xcb_connection_t *c,
77af69d88dSmrg					   xcb_glx_context_t context,
78af69d88dSmrg					   uint32_t fbconfig,
79af69d88dSmrg					   uint32_t screen,
80af69d88dSmrg					   uint32_t share_list,
81af69d88dSmrg					   uint8_t is_direct,
82af69d88dSmrg					   uint32_t num_attribs,
83af69d88dSmrg					   const uint32_t *attribs)
84af69d88dSmrg{
85af69d88dSmrg   (void) c;
86af69d88dSmrg
87af69d88dSmrg   CreateContextAttribsARB_was_sent = true;
88af69d88dSmrg   req.context = context;
89af69d88dSmrg   req.fbconfig = fbconfig;
90af69d88dSmrg   req.screen = screen;
91af69d88dSmrg   req.share_list = share_list;
92af69d88dSmrg   req.is_direct = is_direct;
93af69d88dSmrg   req.num_attribs = num_attribs;
94af69d88dSmrg
95af69d88dSmrg   if (num_attribs != 0 && attribs != NULL)
96af69d88dSmrg      memcpy(sent_attribs, attribs, num_attribs * 2 * sizeof(uint32_t));
97af69d88dSmrg
98af69d88dSmrg   xcb_void_cookie_t cookie;
99af69d88dSmrg   cookie.sequence = 0xbadc0de;
100af69d88dSmrg
101af69d88dSmrg   return cookie;
102af69d88dSmrg}
103af69d88dSmrg
1047ec681f3Smrgextern "C" xcb_void_cookie_t
1057ec681f3Smrgxcb_glx_destroy_context(xcb_connection_t *c, xcb_glx_context_t context)
1067ec681f3Smrg{
1077ec681f3Smrg   xcb_void_cookie_t cookie;
1087ec681f3Smrg   cookie.sequence = 0xbadc0de;
1097ec681f3Smrg
1107ec681f3Smrg   return cookie;
1117ec681f3Smrg}
1127ec681f3Smrg
113af69d88dSmrgextern "C" xcb_generic_error_t *
114af69d88dSmrgxcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie)
115af69d88dSmrg{
116af69d88dSmrg   return NULL;
117af69d88dSmrg}
118af69d88dSmrg
119af69d88dSmrgextern "C" void
120af69d88dSmrg__glXSendErrorForXcb(Display * dpy, const xcb_generic_error_t *err)
121af69d88dSmrg{
122af69d88dSmrg}
123af69d88dSmrg
124af69d88dSmrgextern "C" void
125af69d88dSmrg__glXSendError(Display * dpy, int_fast8_t errorCode, uint_fast32_t resourceID,
126af69d88dSmrg               uint_fast16_t minorCode, bool coreX11error)
127af69d88dSmrg{
128af69d88dSmrg}
129af69d88dSmrg
130af69d88dSmrgclass glXCreateContextAttribARB_test : public ::testing::Test {
131af69d88dSmrgpublic:
132af69d88dSmrg   virtual void SetUp();
1337ec681f3Smrg   virtual void TearDown();
134af69d88dSmrg
135af69d88dSmrg   /**
136af69d88dSmrg    * Replace the existing screen with a direct-rendering screen
137af69d88dSmrg    */
138af69d88dSmrg   void use_direct_rendering_screen();
139af69d88dSmrg
140af69d88dSmrg   mock_XDisplay *dpy;
1417ec681f3Smrg   GLXContext ctx;
142af69d88dSmrg   struct glx_config fbc;
143af69d88dSmrg};
144af69d88dSmrg
145af69d88dSmrgvoid
146af69d88dSmrgglXCreateContextAttribARB_test::SetUp()
147af69d88dSmrg{
148af69d88dSmrg   CreateContextAttribsARB_was_sent = false;
149af69d88dSmrg   memset(&req, 0, sizeof(req));
150af69d88dSmrg   next_id = 99;
151af69d88dSmrg   fake_glx_context::contexts_allocated = 0;
152af69d88dSmrg   psc = new fake_glx_screen(NULL, 0, "");
153af69d88dSmrg
154af69d88dSmrg   this->dpy = new mock_XDisplay(1);
155af69d88dSmrg
156af69d88dSmrg   memset(&this->fbc, 0, sizeof(this->fbc));
157af69d88dSmrg   this->fbc.fbconfigID = 0xbeefcafe;
1587ec681f3Smrg
1597ec681f3Smrg   this->ctx = NULL;
1607ec681f3Smrg}
1617ec681f3Smrg
1627ec681f3Smrgvoid
1637ec681f3SmrgglXCreateContextAttribARB_test::TearDown()
1647ec681f3Smrg{
1657ec681f3Smrg   if (ctx)
1667ec681f3Smrg      delete (fake_glx_context *)ctx;
1677ec681f3Smrg
1687ec681f3Smrg   delete (fake_glx_screen *)psc;
1697ec681f3Smrg
1707ec681f3Smrg   delete this->dpy;
171af69d88dSmrg}
172af69d88dSmrg
173af69d88dSmrgvoid
174af69d88dSmrgglXCreateContextAttribARB_test::use_direct_rendering_screen()
175af69d88dSmrg{
176af69d88dSmrg   struct glx_screen *direct_psc =
177af69d88dSmrg      new fake_glx_screen_direct(psc->display,
178af69d88dSmrg				 psc->scr,
179af69d88dSmrg				 psc->serverGLXexts);
180af69d88dSmrg
1817ec681f3Smrg   delete (fake_glx_screen *)psc;
182af69d88dSmrg   psc = direct_psc;
183af69d88dSmrg}
184af69d88dSmrg
185af69d88dSmrg/**
186af69d88dSmrg * \name Verify detection of client-side errors
187af69d88dSmrg */
188af69d88dSmrg/*@{*/
189af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, NULL_display_returns_None)
190af69d88dSmrg{
191af69d88dSmrg   GLXContext ctx =
192af69d88dSmrg      glXCreateContextAttribsARB(NULL, (GLXFBConfig) &this->fbc, 0,
193af69d88dSmrg				 False, NULL);
194af69d88dSmrg
195af69d88dSmrg   EXPECT_EQ(None, ctx);
196af69d88dSmrg   EXPECT_EQ(0, fake_glx_context::contexts_allocated);
197af69d88dSmrg}
198af69d88dSmrg
199af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, NULL_screen_returns_None)
200af69d88dSmrg{
2017ec681f3Smrg   delete (fake_glx_screen *)psc;
202af69d88dSmrg   psc = NULL;
203af69d88dSmrg
204af69d88dSmrg   GLXContext ctx =
205af69d88dSmrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
206af69d88dSmrg				 False, NULL);
207af69d88dSmrg
208af69d88dSmrg   EXPECT_EQ(None, ctx);
209af69d88dSmrg   EXPECT_EQ(0, fake_glx_context::contexts_allocated);
210af69d88dSmrg}
211af69d88dSmrg/*@}*/
212af69d88dSmrg
213af69d88dSmrg/**
214af69d88dSmrg * \name Verify that correct protocol bits are sent to the server.
215af69d88dSmrg */
216af69d88dSmrg/*@{*/
217af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, does_send_protocol)
218af69d88dSmrg{
2197ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
220af69d88dSmrg			      False, NULL);
221af69d88dSmrg
222af69d88dSmrg   EXPECT_TRUE(CreateContextAttribsARB_was_sent);
223af69d88dSmrg}
224af69d88dSmrg
225af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_context)
226af69d88dSmrg{
2277ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
228af69d88dSmrg			      False, NULL);
229af69d88dSmrg   EXPECT_EQ(99u, req.context);
230af69d88dSmrg}
231af69d88dSmrg
232af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_fbconfig)
233af69d88dSmrg{
2347ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
235af69d88dSmrg			      False, NULL);
236af69d88dSmrg
237af69d88dSmrg   EXPECT_EQ(0xbeefcafe, req.fbconfig);
238af69d88dSmrg}
239af69d88dSmrg
240af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_share_list)
241af69d88dSmrg{
242af69d88dSmrg   GLXContext share =
243af69d88dSmrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
244af69d88dSmrg				 False, NULL);
245af69d88dSmrg
246af69d88dSmrg   ASSERT_NE((GLXContext) 0, share);
247af69d88dSmrg
2487ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, share,
249af69d88dSmrg			      False, NULL);
250af69d88dSmrg
251af69d88dSmrg   struct glx_context *glx_ctx = (struct glx_context *) share;
252af69d88dSmrg   EXPECT_EQ(glx_ctx->xid, req.share_list);
2537ec681f3Smrg
2547ec681f3Smrg   delete (fake_glx_context *)share;
255af69d88dSmrg}
256af69d88dSmrg
257af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_indirect_screen_and_direct_set_to_true)
258af69d88dSmrg{
2597ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
260af69d88dSmrg			      True, NULL);
261af69d88dSmrg
262af69d88dSmrg   EXPECT_FALSE(req.is_direct);
263af69d88dSmrg}
264af69d88dSmrg
265af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_indirect_screen_and_direct_set_to_false)
266af69d88dSmrg{
2677ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
268af69d88dSmrg			      False, NULL);
269af69d88dSmrg
270af69d88dSmrg   EXPECT_FALSE(req.is_direct);
271af69d88dSmrg}
272af69d88dSmrg
273af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_direct_screen_and_direct_set_to_true)
274af69d88dSmrg{
275af69d88dSmrg   this->use_direct_rendering_screen();
276af69d88dSmrg
2777ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
278af69d88dSmrg			      True, NULL);
279af69d88dSmrg
280af69d88dSmrg   EXPECT_TRUE(req.is_direct);
281af69d88dSmrg}
282af69d88dSmrg
283af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_direct_screen_and_direct_set_to_false)
284af69d88dSmrg{
285af69d88dSmrg   this->use_direct_rendering_screen();
286af69d88dSmrg
2877ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
288af69d88dSmrg			      False, NULL);
289af69d88dSmrg
290af69d88dSmrg   EXPECT_FALSE(req.is_direct);
291af69d88dSmrg}
292af69d88dSmrg
293af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_screen)
294af69d88dSmrg{
295af69d88dSmrg   this->fbc.screen = 7;
296af69d88dSmrg   psc->scr = 7;
297af69d88dSmrg
2987ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
299af69d88dSmrg			      False, NULL);
300af69d88dSmrg
301af69d88dSmrg   EXPECT_EQ(7u, req.screen);
302af69d88dSmrg}
303af69d88dSmrg
304af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_num_attribs)
305af69d88dSmrg{
306af69d88dSmrg   /* Use zeros in the second half of each attribute pair to try and trick the
307af69d88dSmrg    * implementation into termiating the list early.
308af69d88dSmrg    *
309af69d88dSmrg    * Use non-zero in the second half of the last attribute pair to try and
310af69d88dSmrg    * trick the implementation into not terminating the list early enough.
311af69d88dSmrg    */
312af69d88dSmrg   static const int attribs[] = {
313af69d88dSmrg      1, 0,
314af69d88dSmrg      2, 0,
315af69d88dSmrg      3, 0,
316af69d88dSmrg      4, 0,
317af69d88dSmrg      0, 6,
318af69d88dSmrg      0, 0
319af69d88dSmrg   };
320af69d88dSmrg
3217ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
322af69d88dSmrg			      False, attribs);
323af69d88dSmrg
324af69d88dSmrg   EXPECT_EQ(4u, req.num_attribs);
325af69d88dSmrg}
326af69d88dSmrg
327af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_num_attribs_empty_list)
328af69d88dSmrg{
329af69d88dSmrg   static const int attribs[] = {
330af69d88dSmrg      0,
331af69d88dSmrg   };
332af69d88dSmrg
3337ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
334af69d88dSmrg			      False, attribs);
335af69d88dSmrg
336af69d88dSmrg   EXPECT_EQ(0u, req.num_attribs);
337af69d88dSmrg}
338af69d88dSmrg
339af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_num_attribs_NULL_list_pointer)
340af69d88dSmrg{
3417ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
342af69d88dSmrg			      False, NULL);
343af69d88dSmrg
344af69d88dSmrg   EXPECT_EQ(0u, req.num_attribs);
345af69d88dSmrg}
346af69d88dSmrg
347af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, sent_correct_attrib_list)
348af69d88dSmrg{
349af69d88dSmrg   int attribs[] = {
350af69d88dSmrg      GLX_RENDER_TYPE, GLX_RGBA_TYPE,
351af69d88dSmrg      GLX_CONTEXT_MAJOR_VERSION_ARB, 1,
352af69d88dSmrg      GLX_CONTEXT_MINOR_VERSION_ARB, 2,
353af69d88dSmrg      0
354af69d88dSmrg   };
355af69d88dSmrg
3567ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
357af69d88dSmrg			      False, attribs);
358af69d88dSmrg
359af69d88dSmrg   for (unsigned i = 0; i < 6; i++) {
360af69d88dSmrg      EXPECT_EQ((uint32_t) attribs[i], sent_attribs[i]);
361af69d88dSmrg   }
362af69d88dSmrg}
363af69d88dSmrg/*@}*/
364af69d88dSmrg
365af69d88dSmrg/**
366af69d88dSmrg * \name Verify details of the returned GLXContext
367af69d88dSmrg */
368af69d88dSmrg/*@{*/
369af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, correct_context)
370af69d88dSmrg{
3717ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
372af69d88dSmrg				 False, NULL);
373af69d88dSmrg
374af69d88dSmrg   /* Since the server did not return an error, the GLXContext should not be
375af69d88dSmrg    * NULL.
376af69d88dSmrg    */
377af69d88dSmrg   EXPECT_NE((GLXContext)0, ctx);
378af69d88dSmrg
379af69d88dSmrg   /* It shouldn't be the XID of the context either.
380af69d88dSmrg    */
381af69d88dSmrg   EXPECT_NE((GLXContext)99, ctx);
382af69d88dSmrg}
383af69d88dSmrg
384af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, correct_context_xid)
385af69d88dSmrg{
3867ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
387af69d88dSmrg				 False, NULL);
388af69d88dSmrg
389af69d88dSmrg   /* Since the server did not return an error, the GLXContext should not be
390af69d88dSmrg    * NULL.
391af69d88dSmrg    */
392af69d88dSmrg   ASSERT_NE((GLXContext)0, ctx);
393af69d88dSmrg
394af69d88dSmrg   struct glx_context *glx_ctx = (struct glx_context *) ctx;
395af69d88dSmrg   EXPECT_EQ(99u, glx_ctx->xid);
396af69d88dSmrg}
397af69d88dSmrg
398af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, correct_context_share_xid)
399af69d88dSmrg{
400af69d88dSmrg   GLXContext first =
401af69d88dSmrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
402af69d88dSmrg				 False, NULL);
403af69d88dSmrg
404af69d88dSmrg   ASSERT_NE((GLXContext) 0, first);
405af69d88dSmrg
406af69d88dSmrg   GLXContext second =
407af69d88dSmrg      glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, first,
408af69d88dSmrg				 False, NULL);
409af69d88dSmrg
410af69d88dSmrg   ASSERT_NE((GLXContext) 0, second);
411af69d88dSmrg
412af69d88dSmrg   struct glx_context *share = (struct glx_context *) first;
413af69d88dSmrg   struct glx_context *ctx = (struct glx_context *) second;
414af69d88dSmrg   EXPECT_EQ(share->xid, ctx->share_xid);
4157ec681f3Smrg
4167ec681f3Smrg   delete (fake_glx_context *)first;
4177ec681f3Smrg   delete (fake_glx_context *)second;
418af69d88dSmrg}
419af69d88dSmrg
420af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_indirect_screen_and_direct_set_to_true)
421af69d88dSmrg{
4227ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
423af69d88dSmrg				 True, NULL);
424af69d88dSmrg
425af69d88dSmrg   ASSERT_NE((GLXContext) 0, ctx);
426af69d88dSmrg
427af69d88dSmrg   struct glx_context *gc = (struct glx_context *) ctx;
428af69d88dSmrg
429af69d88dSmrg   EXPECT_FALSE(gc->isDirect);
430af69d88dSmrg}
431af69d88dSmrg
432af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_indirect_screen_and_direct_set_to_false)
433af69d88dSmrg{
4347ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
435af69d88dSmrg				 False, NULL);
436af69d88dSmrg
437af69d88dSmrg   ASSERT_NE((GLXContext) 0, ctx);
438af69d88dSmrg
439af69d88dSmrg   struct glx_context *gc = (struct glx_context *) ctx;
440af69d88dSmrg
441af69d88dSmrg   EXPECT_FALSE(gc->isDirect);
442af69d88dSmrg}
443af69d88dSmrg
444af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_direct_screen_and_direct_set_to_true)
445af69d88dSmrg{
446af69d88dSmrg   this->use_direct_rendering_screen();
447af69d88dSmrg
4487ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
449af69d88dSmrg				 True, NULL);
450af69d88dSmrg
451af69d88dSmrg   ASSERT_NE((GLXContext) 0, ctx);
452af69d88dSmrg
453af69d88dSmrg   struct glx_context *gc = (struct glx_context *) ctx;
454af69d88dSmrg
455af69d88dSmrg   EXPECT_TRUE(gc->isDirect);
456af69d88dSmrg}
457af69d88dSmrg
458af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_direct_screen_and_direct_set_to_false)
459af69d88dSmrg{
460af69d88dSmrg   this->use_direct_rendering_screen();
461af69d88dSmrg
4627ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
463af69d88dSmrg				 False, NULL);
464af69d88dSmrg
465af69d88dSmrg   ASSERT_NE((GLXContext) 0, ctx);
466af69d88dSmrg
467af69d88dSmrg   struct glx_context *gc = (struct glx_context *) ctx;
468af69d88dSmrg
469af69d88dSmrg   EXPECT_FALSE(gc->isDirect);
470af69d88dSmrg}
471af69d88dSmrg
472af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, correct_indirect_context_client_state_private)
473af69d88dSmrg{
4747ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
475af69d88dSmrg				 False, NULL);
476af69d88dSmrg
477af69d88dSmrg   ASSERT_NE((GLXContext) 0, ctx);
478af69d88dSmrg
479af69d88dSmrg   struct glx_context *gc = (struct glx_context *) ctx;
480af69d88dSmrg
481af69d88dSmrg   ASSERT_FALSE(gc->isDirect);
482af69d88dSmrg   EXPECT_EQ((struct __GLXattributeRec *) 0xcafebabe,
483af69d88dSmrg	     gc->client_state_private);
484af69d88dSmrg}
485af69d88dSmrg
486af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, correct_indirect_context_config)
487af69d88dSmrg{
4887ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
489af69d88dSmrg				 False, NULL);
490af69d88dSmrg
491af69d88dSmrg   ASSERT_NE((GLXContext) 0, ctx);
492af69d88dSmrg
493af69d88dSmrg   struct glx_context *gc = (struct glx_context *) ctx;
494af69d88dSmrg
495af69d88dSmrg   EXPECT_EQ(&this->fbc, gc->config);
496af69d88dSmrg}
497af69d88dSmrg
498af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, correct_context_screen_number)
499af69d88dSmrg{
500af69d88dSmrg   this->fbc.screen = 7;
501af69d88dSmrg   psc->scr = 7;
502af69d88dSmrg
5037ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
504af69d88dSmrg				 False, NULL);
505af69d88dSmrg
506af69d88dSmrg   ASSERT_NE((GLXContext) 0, ctx);
507af69d88dSmrg
508af69d88dSmrg   struct glx_context *gc = (struct glx_context *) ctx;
509af69d88dSmrg
510af69d88dSmrg   EXPECT_EQ(7, gc->screen);
511af69d88dSmrg}
512af69d88dSmrg
513af69d88dSmrgTEST_F(glXCreateContextAttribARB_test, correct_context_screen_pointer)
514af69d88dSmrg{
5157ec681f3Smrg   ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
516af69d88dSmrg				 False, NULL);
517af69d88dSmrg
518af69d88dSmrg   ASSERT_NE((GLXContext) 0, ctx);
519af69d88dSmrg
520af69d88dSmrg   struct glx_context *gc = (struct glx_context *) ctx;
521af69d88dSmrg
522af69d88dSmrg   EXPECT_EQ(psc, gc->psc);
523af69d88dSmrg}
524af69d88dSmrg/*@}*/
525