3 <script src=
"../http/tests/inspector/inspector-test.js"></script>
9 function createAndShowSplitWidget(isVertical
, secondIsSidebar
, settingName
, defaultSidebarWidth
, defaultSidebarHeight
, shouldSaveShowMode
)
11 var splitWidget
= new WebInspector
.SplitWidget(isVertical
, secondIsSidebar
, 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
);
26 function dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
)
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
+ ", showMode = " + splitWidget
.showMode() + ", " + orientation
);
31 InspectorTest
.addResult(" Setting value: " + JSON
.stringify(WebInspector
.settings
.settingForTest(splitWidget
._setting
._name
).get()));
34 function testSplitWidgetSizes(useFraction
, shouldSaveShowMode
)
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;
44 InspectorTest
.addResult("Create default split widget");
45 var params
= "useFraction = " + useFraction
+ ", shouldSaveShowMode = " + shouldSaveShowMode
;
46 InspectorTest
.addResult("Running split widget test with the following parameters: " + params
);
48 InspectorTest
.addResult("Creating split widget");
49 splitWidget
= createAndShowSplitWidget(true, secondIsSidebar
, settingName
, defaultSidebarWidth
, defaultSidebarHeight
, shouldSaveShowMode
);
50 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
52 InspectorTest
.addResult("Hiding sidebar");
53 splitWidget
.hideSidebar();
54 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
56 InspectorTest
.addResult("Showing sidebar");
57 splitWidget
.showBoth();
58 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
60 InspectorTest
.addResult("Resizing");
61 splitWidget
.setSidebarSize(newWidth
);
62 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
64 InspectorTest
.addResult("Hiding sidebar");
65 splitWidget
.hideSidebar();
66 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
68 InspectorTest
.addResult("Showing sidebar");
69 splitWidget
.showBoth();
70 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
72 InspectorTest
.addResult("Making horizontal");
73 splitWidget
.setVertical(false);
74 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
76 InspectorTest
.addResult("Resizing");
77 splitWidget
.setSidebarSize(newHeight
);
78 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
80 InspectorTest
.addResult("Hiding sidebar");
81 splitWidget
.hideSidebar();
82 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
84 splitWidget
.element
.remove();
86 InspectorTest
.addResult("Recreating split widget");
87 splitWidget
= createAndShowSplitWidget(true, secondIsSidebar
, settingName
, defaultSidebarWidth
, defaultSidebarHeight
, shouldSaveShowMode
);
88 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
90 InspectorTest
.addResult("Hiding sidebar");
91 splitWidget
.hideSidebar();
92 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
94 InspectorTest
.addResult("Making horizontal");
95 splitWidget
.setVertical(false);
96 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
98 InspectorTest
.addResult("Showing sidebar");
99 splitWidget
.showBoth();
100 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
102 splitWidget
.element
.remove();
104 InspectorTest
.addResult("Recreating split widget");
105 splitWidget
= createAndShowSplitWidget(true, secondIsSidebar
, settingName
, defaultSidebarWidth
, defaultSidebarHeight
, shouldSaveShowMode
);
106 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
108 InspectorTest
.addResult("Making horizontal");
109 splitWidget
.setVertical(false);
110 dumpSplitWidgetOrientationShowModeAndSidebarSize(splitWidget
);
112 splitWidget
.element
.remove();
113 InspectorTest
.addResult("");
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();
125 <body onload=
"runTest()">
126 <p>Tests how split widget saving to settings works.
</p>