blob: d39de100fb4748b9d7f1e54e8f67411ea4a0c22c [file] [log] [blame]
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script type="text/javascript">
var test = function()
{
function createFakeTab(title, width)
{
function toString()
{
return title;
}
return { width: function() { return width; }, title: title, toString: toString };
}
var tabbedPane = new WebInspector.TabbedPane();
var dropDownButtonMeasuredWidth = 10;
function getTabsToShowAndDumpResults(tabsOrdered, tabsHistory, totalWidth)
{
var tabsToShowIndexes = WebInspector.TabbedPane.prototype._tabsToShowIndexes.call(tabbedPane, tabsOrdered, tabsHistory, totalWidth, dropDownButtonMeasuredWidth);
InspectorTest.addResult(" tabsToShowIndexes = [" + String(tabsToShowIndexes) + "]");
}
function testWidthsAndHistory(widths, history, totalWidth)
{
var tabsOrdered = [];
var tabsHistory = [];
for (var i = 0; i < widths.length; i++)
tabsOrdered.push(createFakeTab("tab " + i, widths[i]));
for (var i = 0; i < history.length; i++)
tabsHistory.push(tabsOrdered[history[i]]);
InspectorTest.addResult("Running tabs to show test:");
InspectorTest.addResult(" widths = [" + String(widths) + "]");
InspectorTest.addResult(" tabsHistory = [" + String(tabsHistory) + "]");
InspectorTest.addResult(" totalWidth = " + totalWidth + ", dropDownButtonMeasuredWidth = " + dropDownButtonMeasuredWidth);
getTabsToShowAndDumpResults(tabsOrdered, tabsHistory, totalWidth);
}
function testWithDifferentTotalWidths(widths, history)
{
testWidthsAndHistory(widths, history, 370);
testWidthsAndHistory(widths, history, 360);
testWidthsAndHistory(widths, history, 350);
testWidthsAndHistory(widths, history, 300);
testWidthsAndHistory(widths, history, 250);
testWidthsAndHistory(widths, history, 200);
testWidthsAndHistory(widths, history, 150);
testWidthsAndHistory(widths, history, 100);
testWidthsAndHistory(widths, history, 60);
testWidthsAndHistory(widths, history, 50);
InspectorTest.addResult("");
}
var widths = [50, 50, 60, 60, 70, 70];
testWithDifferentTotalWidths(widths, [0, 1, 2, 3, 4, 5]);
testWithDifferentTotalWidths(widths, [5, 4, 3, 2, 1, 0]);
testWithDifferentTotalWidths(widths, [0, 2, 4, 1, 3, 5]);
testWithDifferentTotalWidths(widths, [5, 3, 1, 4, 2, 0]);
tabbedPane.setRetainTabsOrder(true);
testWithDifferentTotalWidths(widths, [0, 1, 2, 3, 4, 5]);
testWithDifferentTotalWidths(widths, [5, 4, 3, 2, 1, 0]);
testWithDifferentTotalWidths(widths, [0, 2, 4, 1, 3, 5]);
testWithDifferentTotalWidths(widths, [5, 3, 1, 4, 2, 0]);
InspectorTest.completeTest();
}
</script>
</head>
<body onload="runTest()">
<p>Tests tabbed pane tabs to show calculation.</p>
<a href="https://bugs.webkit.org/show_bug.cgi?id=75085">Bug 75085</a>
</body>
</html>