;;; ebox-layout-boundary-tests.el --- M2a layout dependency gates -*- lexical-binding: t; -*- ;;; Code: (require 'ert) (require 'cl-lib) (require 'ebox) (require 'ebox-fixtures) (defconst ebox-layout-boundary-test--root (expand-file-name ".." (file-name-directory (or load-file-name buffer-file-name))) "Repository root used by layout boundary tests.") (defun ebox-layout-boundary-test--source (file) "Return repository FILE as text." (with-temp-buffer (insert-file-contents (expand-file-name file ebox-layout-boundary-test--root)) (buffer-string))) (defun ebox-layout-boundary-test--legacy-static-render (node) "Render NODE through the pre-E2 static materialization edge." (let ((candidate (ebox-surface--candidate-root node t))) (let ((ebox--surface-materialization-active t) (ebox--region-box-table (make-hash-table :test #'equal)) (ebox--scroll-global-state (make-hash-table :test #'equal)) (ebox--scroll-idle-prefetch-timers (make-hash-table :test #'equal)) (ebox--smooth-scroll-state-table (make-hash-table :test #'equal)) (ebox--render-cache-table (make-hash-table :test #'equal)) (ebox--render-cache-signature-cache (make-hash-table :test #'eq)) (ebox--box-content-render-cache (make-hash-table :test #'eq)) (ebox--viewport-dependent-node-ids-cache (make-hash-table :test #'eq)) (ebox--viewport-dependent-subtree-cache (make-hash-table :test #'eq)) (ebox--viewport-height-dependent-subtree-cache (make-hash-table :test #'eq)) (ebox--flex-content-min-width-table (make-hash-table :test #'eq)) (ebox--render-runtime-revision nil) (ebox--render-cache-allow-viewport-dependent nil) (ebox--render-cache-scroll-state-region-ids nil) (ebox--render-cache-scroll-state-restorable-p nil) (ebox--render-cache-scroll-state-retained-cost-cache nil)) (ebox--render-layout candidate)))) (defun ebox-layout-boundary-test--legacy-render (input) "Render canonical INPUT through the exact pre-E2 direct call edge." (let* ((node (ebox-canonical-input--single-root input "legacy E2 artifact")) (base-source-index (ebox-canonical-input--source-index input)) (ebox--render-source-index base-source-index) (source-index (ebox-tree-source-index node t ebox--render-root-parent-kind base-source-index nil)) (rendered (if (and (not (ebox-style-cascade-active-p)) (zerop (ebox-tree-author-style-count node)) (not (ebox-surface--inline-inheritance-required-p node source-index))) (let ((ebox--region-id-counter ebox--region-id-counter) (ebox--runtime-node-id-counter ebox--runtime-node-id-counter)) (ebox-layout-boundary-test--legacy-static-render node)) (let ((ebox--surface-materialization-active t) (ebox--region-id-counter ebox--region-id-counter) (ebox--runtime-node-id-counter ebox--runtime-node-id-counter)) (tp-surface-materialize-string (ebox-surface-producer node nil t (list :source-base-index base-source-index))))))) (ebox--strip-paint-origins! rendered))) (defun ebox-layout-boundary-test--fixtures () "Return representative static and materialized layout inputs." (list (ebox-test-column (ebox-test-row (ebox-test-box (ebox-test-text "A") :width '(48)) (ebox-test-box (ebox-test-text "B") :width '(48))) (ebox-test-box (ebox-test-text "Tail") :width '(96))) (ebox-test-flex :flex-flow '(row wrap) :column-gap '(2) (ebox-test-box (ebox-test-text "One") :width '(52)) (ebox-test-box (ebox-test-text "Two") :width '(52))) (ebox-test-grid :grid-template-columns '((54) (fr 1)) (ebox-test-box (ebox-test-text "Left")) (ebox-test-box (ebox-test-text "Right"))) (ebox-test-box :font-size 16 (ebox-test-box (ebox-test-text "Inherited"))))) (ert-deftest ebox-layout-boundary-has-no-surface-or-publication-edge () "The layout module depends only on its injected render context." (let ((source (ebox-layout-boundary-test--source "ebox-layout.el"))) (should-not (string-match-p "(require[[:space:]]+'ebox-surface)" source)) (should-not (string-match-p "\\_