5 int main(int argc
, char **argv
)
7 const unsigned int width
= 16, height
= 16;
8 const unsigned int mc_types
[2] = {XVMC_MOCOMP
| XVMC_MPEG_2
, XVMC_IDCT
| XVMC_MPEG_2
};
13 unsigned int is_overlay
, intra_unsigned
;
15 XvMCContext context
= {0};
17 display
= XOpenDisplay(NULL
);
24 XVMC_CHROMA_FORMAT_420
,
33 XCloseDisplay(display
);
34 error(1, 0, "Error, unable to find a good port.\n");
39 Atom xv_colorkey
= XInternAtom(display
, "XV_COLORKEY", 0);
40 XvGetPortAttribute(display
, port_num
, xv_colorkey
, &colorkey
);
43 /* Test NULL context */
44 /* XXX: XvMCBadContext not a valid return for XvMCCreateContext in the XvMC API, but openChrome driver returns it */
45 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
, height
, XVMC_DIRECT
, NULL
) == XvMCBadContext
);
46 /* Test invalid port */
47 /* XXX: Success and XvBadPort have the same value, if this call actually gets passed the validation step as of now we'll crash later */
48 assert(XvMCCreateContext(display
, -1, surface_type_id
, width
, height
, XVMC_DIRECT
, &context
) == XvBadPort
);
49 /* Test invalid surface */
50 assert(XvMCCreateContext(display
, port_num
, -1, width
, height
, XVMC_DIRECT
, &context
) == BadMatch
);
51 /* Test invalid flags */
52 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
, height
, -1, &context
) == BadValue
);
54 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, 16384, height
, XVMC_DIRECT
, &context
) == BadValue
);
55 /* Test huge height */
56 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
, 16384, XVMC_DIRECT
, &context
) == BadValue
);
57 /* Test huge width & height */
58 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, 16384, 16384, XVMC_DIRECT
, &context
) == BadValue
);
59 /* Test valid params */
60 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
, height
, XVMC_DIRECT
, &context
) == Success
);
61 /* Test context id assigned */
62 assert(context
.context_id
!= 0);
63 /* Test surface type id assigned and correct */
64 assert(context
.surface_type_id
== surface_type_id
);
65 /* Test width & height assigned and correct */
66 assert(context
.width
== width
&& context
.height
== height
);
67 /* Test port assigned and correct */
68 assert(context
.port
== port_num
);
69 /* Test flags assigned and correct */
70 assert(context
.flags
== XVMC_DIRECT
);
71 /* Test NULL context */
72 assert(XvMCDestroyContext(display
, NULL
) == XvMCBadContext
);
73 /* Test valid params */
74 assert(XvMCDestroyContext(display
, &context
) == Success
);
75 /* Test awkward but valid width */
76 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
+ 1, height
, XVMC_DIRECT
, &context
) == Success
);
77 assert(context
.width
>= width
+ 1);
78 assert(XvMCDestroyContext(display
, &context
) == Success
);
79 /* Test awkward but valid height */
80 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
, height
+ 1, XVMC_DIRECT
, &context
) == Success
);
81 assert(context
.height
>= height
+ 1);
82 assert(XvMCDestroyContext(display
, &context
) == Success
);
83 /* Test awkward but valid width & height */
84 assert(XvMCCreateContext(display
, port_num
, surface_type_id
, width
+ 1, height
+ 1, XVMC_DIRECT
, &context
) == Success
);
85 assert(context
.width
>= width
+ 1 && context
.height
>= height
+ 1);
86 assert(XvMCDestroyContext(display
, &context
) == Success
);
88 XvUngrabPort(display
, port_num
, CurrentTime
);
89 XCloseDisplay(display
);