[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.22
[framework/web/webkit-efl.git] / LayoutTests / inspector / tabbed-pane-tabs-to-show.html
1 <html>
2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script type="text/javascript">
5 var test = function()
6 {
7     function createFakeTab(title, width)
8     {
9         function toString()
10         {
11             return title;
12         }
13         return { width: width, title: title, toString: toString };
14     }
15
16     var dropDownButtonMeasuredWidth = 10;
17     function getTabsToShowAndDumpResults(tabsOrdered, tabsHistory, totalWidth)
18     {
19         var tabsToShowIndexes = WebInspector.TabbedPane.prototype._tabsToShowIndexes(tabsOrdered, tabsHistory, totalWidth, dropDownButtonMeasuredWidth);
20         InspectorTest.addResult("    tabsToShowIndexes = [" + String(tabsToShowIndexes) + "]");
21     }
22
23     function testWidthsAndHistory(widths, history, totalWidth)
24     {
25         var tabsOrdered = [];
26         var tabsHistory = [];
27         for (var i = 0; i < widths.length; i++)
28             tabsOrdered.push(createFakeTab("tab " + i, widths[i]));
29         for (var i = 0; i < history.length; i++)
30             tabsHistory.push(tabsOrdered[history[i]]);
31         InspectorTest.addResult("Running tabs to show test:");
32         InspectorTest.addResult("    widths = [" + String(widths) + "]");
33         InspectorTest.addResult("    tabsHistory = [" + String(tabsHistory) + "]");
34         InspectorTest.addResult("    totalWidth = " + totalWidth + ", dropDownButtonMeasuredWidth = " + dropDownButtonMeasuredWidth);
35         getTabsToShowAndDumpResults(tabsOrdered, tabsHistory, totalWidth);
36     }
37
38     function testWithDifferentTotalWidths(widths, history)
39     {
40         testWidthsAndHistory(widths, history, 370);
41         testWidthsAndHistory(widths, history, 360);
42         testWidthsAndHistory(widths, history, 350);
43         testWidthsAndHistory(widths, history, 300);
44         testWidthsAndHistory(widths, history, 250);
45         testWidthsAndHistory(widths, history, 200);
46         testWidthsAndHistory(widths, history, 150);
47         testWidthsAndHistory(widths, history, 100);
48         testWidthsAndHistory(widths, history, 60);
49         testWidthsAndHistory(widths, history, 50);
50         InspectorTest.addResult("");
51     }
52
53     var widths = [50, 50, 60, 60, 70, 70];
54     testWithDifferentTotalWidths(widths, [0, 1, 2, 3, 4, 5]);
55     testWithDifferentTotalWidths(widths, [5, 4, 3, 2, 1, 0]);
56     testWithDifferentTotalWidths(widths, [0, 2, 4, 1, 3, 5]);
57     testWithDifferentTotalWidths(widths, [5, 3, 1, 4, 2, 0]);
58
59     InspectorTest.completeTest();
60 }
61 </script>
62 </head>
63 <body onload="runTest()">
64 <p>Tests tabbed pane tabs to show calculation.</p>
65 <a href="https://bugs.webkit.org/show_bug.cgi?id=75085">Bug 75085</a>
66 </body>
67 </html>