<!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.createAsyncSuite("View.AsynchronousLayout");

    suite.addTestCase({
        name: "View.automaticLayout",
        test(resolve, reject) {
            let view = new WI.TestView;
            WI.View.rootView().addSubview(view);
            InspectorTest.expectThat(view.layoutPending, "View should have a pending layout once it is attached.");

            view.evaluateAfterLayout(() => {
                InspectorTest.log("Layout complete.");
                InspectorTest.expectEqual(view.initialLayoutCount, 1, "View should do an initial layout.");
                InspectorTest.expectEqual(view.layoutCount, 1, "View should update its layout.");
                InspectorTest.expectFalse(view.layoutPending, "View should not have a pending layout.");
                resolve();
            });
        }
    });

    suite.addTestCase({
        name: "View.automaticLayout.cancelled",
        test(resolve, reject) {
            let view = new WI.TestView;

            WI.View.rootView().addSubview(view);
            InspectorTest.expectThat(view.layoutPending, "View should have a pending layout once it is attached.");

            WI.View.rootView().removeSubview(view);
            InspectorTest.expectFalse(view.layoutPending, "View should not have a pending layout once it is detached.");
            resolve();
        }
    });

    suite.addTestCase({
        name: "View.needsLayout",
        test(resolve, reject) {
            let view = new WI.TestView;
            WI.View.rootView().addSubview(view);

            InspectorTest.log("Flush pending layouts, then schedule an update.");
            view.updateLayout();
            view.needsLayout();
            InspectorTest.expectThat(view.layoutPending, "View should have a pending layout.");

            view.evaluateAfterLayout(() => {
                InspectorTest.log("Layout complete.");
                InspectorTest.expectEqual(view.layoutCount, 2, "View should update its layout.");
                InspectorTest.expectFalse(view.layoutPending, "View should not have a pending layout.");
                resolve();
            });
        }
    });

    suite.addTestCase({
        name: "View.SyncronousLayoutDuringAsyncronousLayout",
        test(resolve, reject) {
            let UpdateLayoutTestView = class UpdateLayoutTestView extends WI.TestView {
                layout() {
                    super.layout();

                    this.subviews[0].updateLayout();
                }
            }

            let rootView = WI.View.rootView();
            let parentView = new UpdateLayoutTestView;
            let childView = new WI.TestView;

            rootView.addSubview(parentView);
            parentView.addSubview(childView);

            InspectorTest.expectEqual(rootView._dirtyDescendantsCount, 2, "Root view should have 2 dirty descendants.");
            InspectorTest.expectEqual(parentView._dirtyDescendantsCount, 1, "Parent view should have 1 dirty descendant.");
            InspectorTest.expectEqual(childView._dirtyDescendantsCount, 0, "Child view should have 0 dirty descendants.");
            InspectorTest.expectThat(parentView.layoutPending, "View should have a pending layout.");

            childView.evaluateAfterLayout(() => {
                InspectorTest.log("Child view completed a layout.");

                InspectorTest.expectEqual(rootView._dirtyDescendantsCount, 0, "Root view should have 1 dirty descendant.");
                InspectorTest.expectEqual(parentView._dirtyDescendantsCount, 0, "Parent view should have 0 dirty descendants.");
                InspectorTest.expectEqual(childView._dirtyDescendantsCount, 0, "Child view should have 0 dirty descendants.");

                InspectorTest.expectEqual(parentView.layoutCount, 1, "Parent view should have started a layout.");
                InspectorTest.expectEqual(childView.layoutCount, 1, "Child view should have completed 1 layout.");

                childView.evaluateAfterLayout(() => {
                    InspectorTest.log("Child view completed a layout.");
                    InspectorTest.expectEqual(rootView._dirtyDescendantsCount, 0, "Root view should have 0 dirty descendants.");
                    InspectorTest.expectEqual(parentView._dirtyDescendantsCount, 0, "Parent view should have 0 dirty descendants.");
                    InspectorTest.expectEqual(childView._dirtyDescendantsCount, 0, "Child view should have 0 dirty descendants.");

                    InspectorTest.expectEqual(parentView.layoutCount, 1, "Parent view should have started a layout.");
                    InspectorTest.expectEqual(childView.layoutCount, 2, "Child view should have completed 2 layouts.");
                });
            });

            parentView.evaluateAfterLayout(() => {
                InspectorTest.log("Parent view completed a layout.");

                InspectorTest.expectEqual(rootView._dirtyDescendantsCount, 0, "Root view should have 0 dirty descendants.");
                InspectorTest.expectEqual(parentView._dirtyDescendantsCount, 0, "Root view should have 0 dirty descendants.");
                InspectorTest.expectEqual(childView._dirtyDescendantsCount, 0, "Root view should have 0 dirty descendants.");

                InspectorTest.expectEqual(parentView.layoutCount, 1, "Parent view should have completed 1 layout.");
                InspectorTest.expectFalse(parentView.layoutPending, "Parent view should not have a pending layout.");

                resolve();
            });
        }
    });

    suite.addTestCase({
        name: "View.needsLayout.propogateToSubview",
        test(resolve, reject) {
            let parent = new WI.TestView;
            let child = new WI.TestView;
            WI.View.rootView().addSubview(parent);
            parent.addSubview(child);
            InspectorTest.log("Schedule parent view update.");
            parent.needsLayout();

            child.evaluateAfterLayout(() => {
                InspectorTest.log("Layout complete.");
                InspectorTest.expectEqual(child.initialLayoutCount, 1, "Chlid view should do an initial layout.");
                InspectorTest.expectEqual(child.layoutCount, 1, "Child view should update its layout.");
                resolve();
            });
        }
    });

    suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
    <p>Testing asynchronous View layout operations: needsLayout, cancelLayout.</p>
</body>
</html>
