Home | History | Annotate | Download | only in hybridPixmap
      1 <html>
      2     <head>
      3         <style>
      4             img { display: block; border-style: groove}
      5         </style>
      6         <script>
      7             function startTest()
      8             {
      9                 var obj = myWidget.image;
     10                 var pxm = myWidget.pixmap;
     11 
     12                 var img = obj.toHTMLImageElement();
     13                 var img1 = document.getElementById("img1");
     14                 var img2 = document.getElementById("img2");
     15                 document.body.appendChild(img);
     16                 document.body.appendChild(pxm.toHTMLImageElement());
     17                 var signalsFired = 0;
     18                 myWidget.compare(obj.toString(),"[Qt Native Pixmap "+obj.width+","+obj.height+"]");
     19                 myWidget.compare(String(pxm),"[Qt Native Pixmap "+pxm.width+","+pxm.height+"]");
     20 
     21                 // this shouldn't work but shouldn't crash
     22                 myWidget.randomSlot("foobar");
     23 
     24                 myWidget.pixmapSignal.connect(function(imgFromSignal) {
     25                     myWidget.compare(imgFromSignal.height, img2.height);
     26                     if (++signalsFired == 2)
     27                         myWidget.completeTest();
     28                 });
     29 
     30                 myWidget.imageSignal.connect(function(imgFromSignal) {
     31                     myWidget.compare(pxm.height, img2.height);
     32                     if (++signalsFired == 2)
     33                         myWidget.completeTest();
     34                 });
     35 
     36                 function continueTestAfterImagesAreLoaded()
     37                 {
     38                     if (img1.complete && img2.complete) {
     39                         myWidget.compare(pxm.height, img2.height);
     40                         myWidget.pixmapSlot(img);
     41                         myWidget.imageSlot(pxm);
     42                     }
     43                 }
     44                 img1.onload = continueTestAfterImagesAreLoaded;
     45                 img2.onload = continueTestAfterImagesAreLoaded;
     46                 img1.src = obj.toDataUrl();
     47                 img2.src = myWidget.pixmap.toDataUrl();
     48                 myWidget.image = pxm;
     49                 myWidget.pixmap = img;
     50             }
     51         </script>
     52     </head>
     53     <body onload="startTest()">
     54         <img id="img1" />
     55         <img id="img2" />
     56     </body>
     57 </html>
     58