PageRenderTime 52ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/xts5/Xproto/pCreatePixmap.m

#
Objective C | 302 lines | 210 code | 27 blank | 65 comment | 11 complexity | 881fc5e00eb9b6af76d994609a65a361 MD5 | raw file
  1. Copyright (c) 2005 X.Org Foundation L.L.C.
  2. Permission is hereby granted, free of charge, to any person obtaining a copy of
  3. this software and associated documentation files (the "Software"), to deal in
  4. the Software without restriction, including without limitation the rights to
  5. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  6. of the Software, and to permit persons to whom the Software is furnished to do
  7. so, subject to the following conditions:
  8. The above copyright notice and this permission notice shall be included in all
  9. copies or substantial portions of the Software.
  10. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  15. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  16. SOFTWARE.
  17. Copyright (c) Applied Testing and Technology, Inc. 1995
  18. All Rights Reserved.
  19. >># Project: VSW5
  20. >>#
  21. >># File: xts5/Xproto/pCreatePixmap.m
  22. >>#
  23. >># Description:
  24. >># Tests for CreatePixmap
  25. >>#
  26. >># Modifications:
  27. >># $Log: crtpxmp.m,v $
  28. >># Revision 1.2 2005-11-03 08:44:06 jmichael
  29. >># clean up all vsw5 paths to use xts5 instead.
  30. >>#
  31. >># Revision 1.1.1.2 2005/04/15 14:05:53 anderson
  32. >># Reimport of the base with the legal name in the copyright fixed.
  33. >>#
  34. >># Revision 8.0 1998/12/23 23:32:27 mar
  35. >># Branch point for Release 5.0.2
  36. >>#
  37. >># Revision 7.0 1998/10/30 22:53:02 mar
  38. >># Branch point for Release 5.0.2b1
  39. >>#
  40. >># Revision 6.0 1998/03/02 05:23:58 tbr
  41. >># Branch point for Release 5.0.1
  42. >>#
  43. >># Revision 5.0 1998/01/26 03:20:29 tbr
  44. >># Branch point for Release 5.0.1b1
  45. >>#
  46. >># Revision 4.0 1995/12/15 09:05:08 tbr
  47. >># Branch point for Release 5.0.0
  48. >>#
  49. >># Revision 3.1 1995/12/15 01:03:58 andy
  50. >># Prepare for GA Release
  51. >>#
  52. /*
  53. Copyright (c) 1990, 1991 X Consortium
  54. Permission is hereby granted, free of charge, to any person obtaining a copy
  55. of this software and associated documentation files (the "Software"), to deal
  56. in the Software without restriction, including without limitation the rights
  57. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  58. copies of the Software, and to permit persons to whom the Software is
  59. furnished to do so, subject to the following conditions:
  60. The above copyright notice and this permission notice shall be included in
  61. all copies or substantial portions of the Software.
  62. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  63. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  64. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  65. X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  66. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  67. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  68. Except as contained in this notice, the name of the X Consortium shall not be
  69. used in advertising or otherwise to promote the sale, use or other dealings
  70. in this Software without prior written authorization from the X Consortium.
  71. Copyright 1990, 1991 by UniSoft Group Limited.
  72. Permission to use, copy, modify, distribute, and sell this software and
  73. its documentation for any purpose is hereby granted without fee,
  74. provided that the above copyright notice appear in all copies and that
  75. both that copyright notice and this permission notice appear in
  76. supporting documentation, and that the name of UniSoft not be
  77. used in advertising or publicity pertaining to distribution of the
  78. software without specific, written prior permission. UniSoft
  79. makes no representations about the suitability of this software for any
  80. purpose. It is provided "as is" without express or implied warranty.
  81. Copyright 1989 by Sequent Computer Systems, Inc., Portland, Oregon
  82. All Rights Reserved
  83. Permission to use, copy, modify, and distribute this software and its
  84. documentation for any purpose and without fee is hereby granted,
  85. provided that the above copyright notice appears in all copies and that
  86. both that copyright notice and this permission notice appear in
  87. supporting documentation, and that the name of Sequent not be used
  88. in advertising or publicity pertaining to distribution or use of the
  89. software without specific, written prior permission.
  90. SEQUENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  91. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
  92. SEQUENT BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  93. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  94. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  95. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  96. SOFTWARE.
  97. */
  98. >>TITLE CreatePixmap Xproto
  99. >>SET startup protostartup
  100. >>SET cleanup protocleanup
  101. >>EXTERN
  102. /* Touch test for CreatePixmap request */
  103. #include "Xstlib.h"
  104. #define CLIENT 0
  105. static TestType test_type = SETUP;
  106. xCreatePixmapReq *req;
  107. static
  108. void
  109. tester()
  110. {
  111. Create_Client(CLIENT);
  112. Create_Default_Window(CLIENT);
  113. Set_Test_Type(CLIENT, test_type);
  114. req = (xCreatePixmapReq *) Make_Req(CLIENT, X_CreatePixmap);
  115. if(test_type == BAD_IDCHOICE1) {
  116. Send_Req(CLIENT, (xReq *) req);
  117. Log_Trace("client %d sent CreatePixmap request\n", CLIENT);
  118. Expect_Nothing(CLIENT);
  119. }
  120. if(test_type == BAD_IDCHOICE2) {
  121. req->pid = 0xffffffff; /* top 2 bits set ==> invalid */
  122. }
  123. Send_Req(CLIENT, (xReq *) req);
  124. Set_Test_Type(CLIENT, GOOD);
  125. switch(test_type) {
  126. case GOOD:
  127. Log_Trace("client %d sent default CreatePixmap request\n", CLIENT);
  128. Expect_Nothing(CLIENT);
  129. break;
  130. case BAD_IDCHOICE1:
  131. Log_Trace("client %d sent CreatePixmap request with same resource ID\n", CLIENT);
  132. Expect_BadIDChoice(CLIENT);
  133. Expect_Nothing(CLIENT);
  134. break;
  135. case BAD_IDCHOICE2:
  136. Log_Trace("client %d sent CreatePixmap request with out-of-range resource ID\n", CLIENT);
  137. Expect_BadIDChoice(CLIENT);
  138. Expect_Nothing(CLIENT);
  139. break;
  140. case BAD_LENGTH:
  141. Log_Trace("client %d sent CreatePixmap request with bad length (%d)\n", CLIENT, req->length);
  142. Expect_BadLength(CLIENT);
  143. Expect_Nothing(CLIENT);
  144. break;
  145. case TOO_LONG:
  146. case JUST_TOO_LONG:
  147. Log_Trace("client %d sent overlong CreatePixmap request (%d)\n", CLIENT, req->length);
  148. Expect_BadLength(CLIENT);
  149. Expect_Nothing(CLIENT);
  150. break;
  151. default:
  152. Log_Err("INTERNAL ERROR: test_type %d not one of GOOD(%d), BAD_LENGTH(%d), TOO_LONG(%d) or JUST_TOO_LONG(%d)\n",
  153. test_type, GOOD, BAD_LENGTH, TOO_LONG, JUST_TOO_LONG);
  154. Abort();
  155. /*NOTREACHED*/
  156. break;
  157. }
  158. Free_Req(req);
  159. Exit_OK();
  160. }
  161. >>ASSERTION Good A
  162. When a client sends a valid xname protocol request to the X server,
  163. then the X server does not send back an error, event or reply to the client.
  164. >>STRATEGY
  165. Call library function testfunc() to do the following:
  166. Open a connection to the X server using native byte sex.
  167. Send a valid xname protocol request to the X server.
  168. Verify that the X server does not send back an error, event or reply.
  169. Open a connection to the X server using reversed byte sex.
  170. Send a valid xname protocol request to the X server.
  171. Verify that the X server does not send back an error, event or reply.
  172. >>CODE
  173. test_type = GOOD;
  174. /* Call a library function to exercise the test code */
  175. testfunc(tester);
  176. >>ASSERTION Bad A
  177. When a client sends an invalid xname protocol request to the X server,
  178. in which the length field of the request is not the minimum length required to
  179. contain the request,
  180. then the X server sends back a BadLength error to the client.
  181. >>STRATEGY
  182. Call library function testfunc() to do the following:
  183. Open a connection to the X server using native byte sex.
  184. Send an invalid xname protocol request to the X server with length
  185. one less than the minimum length required to contain the request.
  186. Verify that the X server sends back a BadLength error.
  187. Open a connection to the X server using reversed byte sex.
  188. Send an invalid xname protocol request to the X server with length
  189. one less than the minimum length required to contain the request.
  190. Verify that the X server sends back a BadLength error.
  191. Open a connection to the X server using native byte sex.
  192. Send an invalid xname protocol request to the X server with length
  193. one greater than the minimum length required to contain the request.
  194. Verify that the X server sends back a BadLength error.
  195. Open a connection to the X server using reversed byte sex.
  196. Send an invalid xname protocol request to the X server with length
  197. one greater than the minimum length required to contain the request.
  198. Verify that the X server sends back a BadLength error.
  199. >>CODE
  200. test_type = BAD_LENGTH; /* < minimum */
  201. /* Call a library function to exercise the test code */
  202. testfunc(tester);
  203. test_type = JUST_TOO_LONG; /* > minimum */
  204. /* Call a library function to exercise the test code */
  205. testfunc(tester);
  206. >>ASSERTION Bad B 1
  207. When a client sends an invalid xname protocol request to the X server,
  208. in which the length field of the request exceeds the maximum length accepted
  209. by the X server,
  210. then the X server sends back a BadLength error to the client.
  211. >>STRATEGY
  212. Call library function testfunc() to do the following:
  213. Open a connection to the X server using native byte sex.
  214. Send an invalid xname protocol request to the X server with length
  215. one greater than the maximum length accepted by the server.
  216. Verify that the X server sends back a BadLength error.
  217. Open a connection to the X server using reversed byte sex.
  218. Send an invalid xname protocol request to the X server with length
  219. one greater than the maximum length accepted by the server.
  220. Verify that the X server sends back a BadLength error.
  221. >>CODE
  222. test_type = TOO_LONG;
  223. /* Call a library function to exercise the test code */
  224. testfunc(tester);
  225. >>ASSERTION Bad A
  226. When a client sends an invalid xname protocol request to the X server,
  227. in which the resource ID is already in use,
  228. then the X server sends back a BadIDChoice error to the client.
  229. >>STRATEGY
  230. Call library function testfunc() to do the following:
  231. Open a connection to the X server using native byte sex.
  232. Send a valid xname protocol request to the X server.
  233. Send an invalid xname protocol request with identical resource ID
  234. to the X server.
  235. Verify that the X server sends back a BadIDChoice error.
  236. Open a connection to the X server using reversed byte sex.
  237. Send a valid xname protocol request to the X server.
  238. Send an invalid xname protocol request with identical resource ID
  239. to the X server.
  240. Verify that the X server sends back a BadIDChoice error.
  241. >>CODE
  242. test_type = BAD_IDCHOICE1;
  243. /* Call a library function to exercise the test code */
  244. testfunc(tester);
  245. >>ASSERTION Bad A
  246. When a client sends an invalid xname protocol request to the X server,
  247. in which the resource ID is outside the range assigned to the client,
  248. then the X server sends back a BadIDChoice error to the client.
  249. >>STRATEGY
  250. Call library function testfunc() to do the following:
  251. Open a connection to the X server using native byte sex.
  252. Send a valid xname protocol request to the X server.
  253. Send an invalid xname protocol request to the X server with a resource ID
  254. outside the range assigned to the client.
  255. Verify that the X server sends back a BadIDChoice error.
  256. Open a connection to the X server using reversed byte sex.
  257. Send a valid xname protocol request to the X server.
  258. Send an invalid xname protocol request to the X server with a resource ID
  259. outside the range assigned to the client.
  260. Verify that the X server sends back a BadIDChoice error.
  261. >>CODE
  262. test_type = BAD_IDCHOICE2;
  263. /* Call a library function to exercise the test code */
  264. testfunc(tester);