1 38 package com.gargoylesoftware.htmlunit.javascript.host; 39 40 import java.util.ArrayList; 41 import java.util.Arrays; 42 import java.util.List; 43 44 import com.gargoylesoftware.htmlunit.WebTestCase; 45 46 56 public class ScreenTest extends WebTestCase { 57 58 61 public ScreenTest(final String name) { 62 super(name); 63 } 64 65 69 public void testProperties() throws Exception { 70 final String content = "<html><head><title>test</title>\n" 71 + " <script>\n" 72 + " function doTest(){\n" 73 + " var props = {\n" 74 + " availHeight: 600, \n" 75 + " availLeft: 0, \n" 76 + " availTop: 0, \n" 77 + " availWidth: 800, \n" 78 + " bufferDepth: 24, \n" 79 + " deviceXDPI: 96, \n" 80 + " deviceYDPI: 96, \n" 81 + " fontSmoothingEnabled: true, \n" 82 + " height: 600, \n" 83 + " left: 0, \n" 84 + " logicalXDPI: 96, \n" 85 + " logicalYDPI: 96, \n" 86 + " pixelDepth: 24, \n" 87 + " top: 0, \n" 88 + " updateInterval: 0, \n" 89 + " width: 800 \n" 90 + " }; \n" 91 + " var nbTests = 0;\n" 92 + " for (var i in props) {" 93 + " var myExpr = 'window.screen.' + i;\n" 94 + " var result = eval(myExpr);\n" 95 + " if (props[i] != result) {" 96 + " alert(myExpr + ': ' + result + ' != ' + props[i]);\n" 97 + " }\n" 98 + " ++nbTests;\n" 99 + " }\n" 100 + " alert(nbTests);\n" 101 + " }\n" 102 + " </script>\n" 103 + "</head>\n" 104 + "<body onload='doTest()'>\n" 105 + "</body></html>"; 106 final List collectedAlerts = new ArrayList(); 107 loadPage(content, collectedAlerts); 108 final List expectedAlerts = Arrays.asList(new String[]{"16"}); 109 assertEquals(expectedAlerts, collectedAlerts); 110 } 111 } 112 | Popular Tags |