82 lines
2.9 KiB
HTML
82 lines
2.9 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
|
|
<script src="resources/test-view.js"></script>
|
|
<script>
|
|
function test()
|
|
{
|
|
InspectorTest.redirectRequestAnimationFrame();
|
|
|
|
let suite = InspectorTest.createSyncSuite("View.SynchronousLayout");
|
|
|
|
suite.addTestCase({
|
|
name: "View.updateLayout",
|
|
test() {
|
|
let view1 = new WI.TestView;
|
|
WI.View.rootView().addSubview(view1);
|
|
InspectorTest.log("Update layout for attached view.");
|
|
view1.updateLayout();
|
|
InspectorTest.expectEqual(view1.initialLayoutCount, 1, "View should do an initial layout.");
|
|
InspectorTest.expectEqual(view1.layoutCount, 1, "View should update its layout once.");
|
|
InspectorTest.expectFalse(view1.layoutPending, "View should not have a pending layout.");
|
|
|
|
let view2 = new WI.TestView;
|
|
InspectorTest.log("Update layout for detached view.");
|
|
view2.updateLayout();
|
|
InspectorTest.expectEqual(view2.initialLayoutCount, 1, "View should do an initial layout.");
|
|
InspectorTest.expectEqual(view2.layoutCount, 1, "View should update its layout once.");
|
|
InspectorTest.expectFalse(view2.layoutPending, "View should not have a pending layout.");
|
|
|
|
return true;
|
|
}
|
|
});
|
|
|
|
suite.addTestCase({
|
|
name: "View.updateLayout.propogateToSubviews",
|
|
test() {
|
|
let parent = new WI.TestView;
|
|
let child = new WI.TestView;
|
|
|
|
WI.View.rootView().addSubview(parent);
|
|
parent.addSubview(child);
|
|
|
|
InspectorTest.log("Update parent view layout.");
|
|
parent.updateLayout();
|
|
InspectorTest.expectEqual(child.initialLayoutCount, 1, "Child view should do an initial layout.");
|
|
InspectorTest.expectEqual(child.layoutCount, 1, "Child view should update its layout once.");
|
|
|
|
return true;
|
|
}
|
|
});
|
|
|
|
suite.addTestCase({
|
|
name: "View.updateLayoutIfNeeded",
|
|
test() {
|
|
let view1 = new WI.TestView;
|
|
view1.updateLayoutIfNeeded();
|
|
InspectorTest.expectEqual(view1.layoutCount, 1, "View should update if an initial layout never happened.");
|
|
|
|
let view2 = new WI.TestView;
|
|
view2.needsLayout();
|
|
view2.updateLayoutIfNeeded();
|
|
InspectorTest.expectEqual(view2.layoutCount, 1, "View should update if a layout is pending.");
|
|
|
|
let view3 = new WI.TestView;
|
|
view3.updateLayout();
|
|
view3.updateLayoutIfNeeded();
|
|
InspectorTest.expectEqual(view3.layoutCount, 1, "View should not update if no layout is pending.");
|
|
|
|
return true;
|
|
}
|
|
});
|
|
|
|
suite.runTestCasesAndFinish();
|
|
}
|
|
</script>
|
|
</head>
|
|
<body onload="runTest()">
|
|
<p>Testing synchronous View layout operations: updateLayout, updateLayoutIfNeeded.</p>
|
|
</body>
|
|
</html>
|