4928638d730b1bff86ebf55ce734f91cda90ab0b.svn-base 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title>Dijit raw programatic test suite | The Dojo Toolkit</title>
  6. <style type="text/css">
  7. @import "../../dojo/resources/dojo.css";
  8. @import "css/dijitTests.css";
  9. body, html { width:100%; height:100%; margin:0; padding:0; background:#fff !important; }
  10. </style>
  11. <script type="text/javascript" src="../../dojo/dojo.js"
  12. djConfig="parseOnLoad: true, isDebug: true"></script>
  13. <script type="text/javascript" src="_testCommon.js"></script>
  14. <script language="JavaScript" type="text/javascript">
  15. dojo.require("dojo.data.ItemFileReadStore");
  16. dojo.require("dijit.dijit-all");
  17. var randomParams = function(){
  18. // need better params to test passing
  19. return { "length" : 20 };
  20. };
  21. var inspectClass = function(fullClassName){
  22. var newDijit, newDijitDom, newDijitParam = null;
  23. var createdWidgets = [];
  24. className = eval(fullClassName); //
  25. // just try to make the class:
  26. try{
  27. newDijit = new className({});
  28. createdWidgets.push(newDijit);
  29. }catch(e){
  30. console.warn('new only: ',fullClassName,e);
  31. }
  32. // try starting this widget
  33. try{
  34. if (newDijit && newDijit.startup){ newDijit.startup(); }
  35. }catch(e){
  36. console.warn('call startup: ',fullClassName,e);
  37. }
  38. // try with a div in the dom
  39. try{
  40. var tmpDiv = dojo.body().appendChild(document.createElement('div'));
  41. newDijitDom = new className({},tmpDiv);
  42. createdWidgets.push(newDijitDom);
  43. }catch(e){
  44. console.warn('attached to div: ',fullClassName,e);
  45. }
  46. // lets pass random parameters
  47. try{
  48. var tmpDiv = dojo.body().appendChild(document.createElement('div'));
  49. newDijitParam = new className(randomParams(),tmpDiv);
  50. createdWidgets.push(newDijitParam);
  51. }catch(e){
  52. console.warn('random param test: ',fullClassName,e);
  53. }
  54. // add more tests ...
  55. // cleanup after ourselves
  56. dojo.forEach(createdWidgets,function(byeWidget){
  57. try{
  58. if(byeWidget.destroy){ byeWidget.destroy(); }
  59. }catch(e){
  60. console.warn('destroying: ',byeWidget.declaredClass,e,byeWidget);
  61. }
  62. });
  63. };
  64. var storeError = function(e,request){
  65. console.warn(e,request);
  66. };
  67. var storeReady = function(items,request){
  68. dojo.forEach(items,function(item){
  69. var testClass = theStore.getValue(item,"className");
  70. try{
  71. inspectClass(testClass);
  72. }catch(e){
  73. console.warn(e);
  74. }
  75. });
  76. };
  77. var init = function(){
  78. var request = {
  79. query: { },
  80. onComplete: storeReady,
  81. onError: storeError
  82. };
  83. theStore.fetch(request);
  84. };
  85. dojo.addOnLoad(init);
  86. </script>
  87. </head>
  88. <body>
  89. <div dojoType="dojo.data.ItemFileReadStore" jsId="theStore"
  90. url="../tests/_data/dijits.json"></div>
  91. </body>
  92. </html>