3 <script src=
"../http/tests/inspector/inspector-test.js"></script>
8 function showRootSplitWidget(splitWidget
)
10 splitWidget
.element
.style
.position
= "absolute";
11 splitWidget
.element
.style
.top
= "0";
12 splitWidget
.element
.style
.left
= "0";
13 splitWidget
.element
.style
.height
= "500px";
14 splitWidget
.element
.style
.width
= "500px";
15 splitWidget
.markAsRoot();
16 splitWidget
.show(document
.body
);
20 function dumpBoundingBoxes(widgets
)
22 for (var name
in widgets
) {
23 var box
= widgets
[name
].element
.getBoundingClientRect();
24 InspectorTest
.addResult("[" + name
+ "] left = " + box
.left
+ "; right = " + box
.right
+ "; top = " + box
.top
+ "; bottom = " + box
.bottom
);
28 InspectorTest
.addResult("Creating simple hierarchy");
29 var splitWidget
= new WebInspector
.SplitWidget(true, true, "splitWidgetStateSettingName.splitWidget", 250, 250);
30 showRootSplitWidget(splitWidget
);
32 var mainWidget
= new WebInspector
.Widget();
33 mainWidget
.setMinimumSize(100, 80);
34 splitWidget
.setMainWidget(mainWidget
);
36 var firstSidebarWidget
= new WebInspector
.Widget();
37 firstSidebarWidget
.setMinimumSize(40, 70);
38 splitWidget
.setSidebarWidget(firstSidebarWidget
);
40 var widgets
= {"splitWidget": splitWidget
, "mainWidget": mainWidget
, "sidebarWidget": firstSidebarWidget
};
41 dumpBoundingBoxes(widgets
);
43 InspectorTest
.addResult("Changing sidebar size");
44 splitWidget
.setSidebarSize(30);
45 dumpBoundingBoxes(widgets
);
47 InspectorTest
.addResult("Changing sidebar widget minimum size");
48 firstSidebarWidget
.setMinimumSize(90, 70);
49 dumpBoundingBoxes(widgets
);
51 InspectorTest
.addResult("Changing orientation");
52 splitWidget
.setVertical(false);
53 dumpBoundingBoxes(widgets
);
55 InspectorTest
.addResult("Changing main widget minimum size");
56 mainWidget
.setMinimumSize(450, 450);
57 dumpBoundingBoxes(widgets
);
59 InspectorTest
.addResult("Changing main widget minimum size back and resizing");
60 mainWidget
.setMinimumSize(100, 80);
61 splitWidget
.setSidebarSize(450);
62 dumpBoundingBoxes(widgets
);
64 InspectorTest
.addResult("Wrapping main widget to a split widget");
65 var childsplitWidget
= new WebInspector
.SplitWidget(false, true, "splitWidgetStateSettingName.childsplitWidget", 100, 100);
66 childsplitWidget
.hideSidebar();
67 childsplitWidget
.setMainWidget(mainWidget
);
68 splitWidget
.setMainWidget(childsplitWidget
);
69 widgets
["childSplitWidget"] = childsplitWidget
;
70 dumpBoundingBoxes(widgets
);
72 InspectorTest
.addResult("Adding invisble sidebar");
73 var secondSidebarWidget
= new WebInspector
.Widget();
74 secondSidebarWidget
.setMinimumSize(60, 60);
75 childsplitWidget
.setSidebarWidget(secondSidebarWidget
);
76 widgets
["secondSidebarWidget"] = secondSidebarWidget
;
77 dumpBoundingBoxes(widgets
);
79 InspectorTest
.addResult("Showing sidebar");
80 childsplitWidget
.showBoth();
81 dumpBoundingBoxes(widgets
);
83 InspectorTest
.addResult("Detaching sidebar");
84 secondSidebarWidget
.detach();
85 delete widgets
["secondSidebarWidget"];
86 dumpBoundingBoxes(widgets
);
88 InspectorTest
.addResult("Attaching another sidebar");
89 var thirdSidebarWidget
= new WebInspector
.Widget();
90 thirdSidebarWidget
.setMinimumSize(80, 80);
91 childsplitWidget
.setSidebarWidget(thirdSidebarWidget
);
92 widgets
["thirdSidebarWidget"] = thirdSidebarWidget
;
93 dumpBoundingBoxes(widgets
);
95 InspectorTest
.addResult("Swapping main and sidebar");
96 splitWidget
.setSecondIsSidebar(false);
97 dumpBoundingBoxes(widgets
);
99 InspectorTest
.addResult("Arranging preferred sizes");
100 firstSidebarWidget
.setMinimumAndPreferredSizes(50, 50, 100, 100);
101 mainWidget
.setMinimumAndPreferredSizes(50, 50, 200, 200);
102 thirdSidebarWidget
.setMinimumAndPreferredSizes(49, 49, 99, 99);
103 splitWidget
.setSidebarSize(260);
104 dumpBoundingBoxes(widgets
);
106 InspectorTest
.addResult("Less than sidebar preferred size");
107 splitWidget
.setSidebarSize(80);
108 dumpBoundingBoxes(widgets
);
110 InspectorTest
.addResult("Size changes proportionally");
111 splitWidget
.setSidebarSize(320);
112 dumpBoundingBoxes(widgets
);
114 InspectorTest
.addResult("Manual resize inside child split widget");
115 childsplitWidget
.setSidebarSize(50);
116 dumpBoundingBoxes(widgets
);
118 InspectorTest
.addResult("Manual resize inside child split widget");
119 childsplitWidget
.setSidebarSize(120);
120 dumpBoundingBoxes(widgets
);
122 InspectorTest
.addResult("Child split widget gets more space");
123 splitWidget
.setSidebarSize(170);
124 dumpBoundingBoxes(widgets
);
126 InspectorTest
.addResult("Child split widget gets less space");
127 splitWidget
.setSidebarSize(360);
128 dumpBoundingBoxes(widgets
);
130 InspectorTest
.completeTest();
134 <body onload=
"runTest()">
135 <p>Tests how widget minimum size works.
</p>