OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script src="../http/tests/inspector/inspector-test.js"></script> |
| 4 <script> |
| 5 |
| 6 function test() |
| 7 { |
| 8 var settingIndex = 0; |
| 9 function createAndShowSplitWidget(isVertical, secondIsSidebar, settingName,
defaultSidebarWidth, defaultSidebarHeight, shouldSaveShowMode) |
| 10 { |
| 11 var splitWidget = new WebInspector.SplitWidget(isVertical, secondIsSideb
ar, settingName, defaultSidebarWidth, defaultSidebarHeight); |
| 12 splitWidget.setMainWidget(new WebInspector.Widget()); |
| 13 splitWidget.setSidebarWidget(new WebInspector.Widget()); |
| 14 if (shouldSaveShowMode) |
| 15 splitWidget.enableShowModeSaving(); |
| 16 splitWidget.element.style.position = "absolute"; |
| 17 splitWidget.element.style.top = "0"; |
| 18 splitWidget.element.style.left = "0"; |
| 19 splitWidget.element.style.height = "500px"; |
| 20 splitWidget.element.style.width = "500px"; |
| 21 splitWidget.markAsRoot(); |
| 22 splitWidget.show(document.body); |
| 23 return splitWidget; |
| 24 } |
| 25 |
| 26 function dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget) |
| 27 { |
| 28 var sidebarSize = splitWidget.isVertical() ? splitWidget.sidebarWidget()
.element.offsetWidth : splitWidget.sidebarWidget().element.offsetHeight; |
| 29 var orientation = splitWidget.isVertical() ? "vertical" : "horizontal"; |
| 30 InspectorTest.addResult(" Sidebar size = " + sidebarSize + ", showMod
e = " + splitWidget.showMode() + ", " + orientation); |
| 31 InspectorTest.addResult(" Setting value: " + JSON.stringify(WebInspec
tor.settings.settingForTest(splitWidget._setting._name).get())); |
| 32 } |
| 33 |
| 34 function testSplitWidgetSizes(useFraction, shouldSaveShowMode) |
| 35 { |
| 36 var secondIsSidebar = true; |
| 37 var settingName = "splitWidgetStateSettingName" + (++settingIndex); |
| 38 var defaultSidebarWidth = useFraction ? 0.23 : 101; |
| 39 var defaultSidebarHeight = useFraction ? 0.24 : 102; |
| 40 var newWidth = useFraction ? 125 : 201; |
| 41 var newHeight = useFraction ? 130 : 202; |
| 42 |
| 43 var splitWidget; |
| 44 InspectorTest.addResult("Create default split widget"); |
| 45 var params = "useFraction = " + useFraction + ", shouldSaveShowMode = "
+ shouldSaveShowMode; |
| 46 InspectorTest.addResult("Running split widget test with the following pa
rameters: " + params); |
| 47 |
| 48 InspectorTest.addResult("Creating split widget"); |
| 49 splitWidget = createAndShowSplitWidget(true, secondIsSidebar, settingNam
e, defaultSidebarWidth, defaultSidebarHeight, shouldSaveShowMode); |
| 50 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 51 |
| 52 InspectorTest.addResult("Hiding sidebar"); |
| 53 splitWidget.hideSidebar(); |
| 54 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 55 |
| 56 InspectorTest.addResult("Showing sidebar"); |
| 57 splitWidget.showBoth(); |
| 58 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 59 |
| 60 InspectorTest.addResult("Resizing"); |
| 61 splitWidget.setSidebarSize(newWidth); |
| 62 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 63 |
| 64 InspectorTest.addResult("Hiding sidebar"); |
| 65 splitWidget.hideSidebar(); |
| 66 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 67 |
| 68 InspectorTest.addResult("Showing sidebar"); |
| 69 splitWidget.showBoth(); |
| 70 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 71 |
| 72 InspectorTest.addResult("Making horizontal"); |
| 73 splitWidget.setVertical(false); |
| 74 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 75 |
| 76 InspectorTest.addResult("Resizing"); |
| 77 splitWidget.setSidebarSize(newHeight); |
| 78 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 79 |
| 80 InspectorTest.addResult("Hiding sidebar"); |
| 81 splitWidget.hideSidebar(); |
| 82 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 83 |
| 84 splitWidget.element.remove(); |
| 85 |
| 86 InspectorTest.addResult("Recreating split widget"); |
| 87 splitWidget = createAndShowSplitWidget(true, secondIsSidebar, settingNam
e, defaultSidebarWidth, defaultSidebarHeight, shouldSaveShowMode); |
| 88 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 89 |
| 90 InspectorTest.addResult("Hiding sidebar"); |
| 91 splitWidget.hideSidebar(); |
| 92 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 93 |
| 94 InspectorTest.addResult("Making horizontal"); |
| 95 splitWidget.setVertical(false); |
| 96 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 97 |
| 98 InspectorTest.addResult("Showing sidebar"); |
| 99 splitWidget.showBoth(); |
| 100 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 101 |
| 102 splitWidget.element.remove(); |
| 103 |
| 104 InspectorTest.addResult("Recreating split widget"); |
| 105 splitWidget = createAndShowSplitWidget(true, secondIsSidebar, settingNam
e, defaultSidebarWidth, defaultSidebarHeight, shouldSaveShowMode); |
| 106 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 107 |
| 108 InspectorTest.addResult("Making horizontal"); |
| 109 splitWidget.setVertical(false); |
| 110 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget); |
| 111 |
| 112 splitWidget.element.remove(); |
| 113 InspectorTest.addResult(""); |
| 114 } |
| 115 |
| 116 // Test all combinations of useFraction and shouldSaveShowMode flags |
| 117 testSplitWidgetSizes(false, false); |
| 118 testSplitWidgetSizes(false, true); |
| 119 testSplitWidgetSizes(true, false); |
| 120 testSplitWidgetSizes(true, true); |
| 121 InspectorTest.completeTest(); |
| 122 } |
| 123 </script> |
| 124 </head> |
| 125 <body onload="runTest()"> |
| 126 <p>Tests how split widget saving to settings works.</p> |
| 127 </body> |
| 128 </html> |
OLD | NEW |