The cel sheet creates the place a polygon needs
This commit is contained in:
parent
6443366748
commit
3879d76d57
12 changed files with 1180 additions and 441 deletions
|
|
@ -10,6 +10,7 @@
|
|||
[arthur.domain.palette :as pal]
|
||||
[arthur.domain.pick :as pick]
|
||||
[arthur.domain.lane :as lane]
|
||||
[arthur.domain.span :as span]
|
||||
[arthur.domain.symbol :as symbol]))
|
||||
|
||||
(defn drawing [id x frames]
|
||||
|
|
@ -410,44 +411,10 @@
|
|||
{:at 4 :extent :grow-symbol})
|
||||
[:clip :symbols :main :nodes :n]))))))
|
||||
|
||||
(deftest splitting-an-cel-changes-nothing-that-is-drawn
|
||||
(let [doc (document)
|
||||
fs (range 12)
|
||||
before (drawn doc fs)]
|
||||
(doseq [[label id cut] [["a held drawing" :a 2]
|
||||
["a cel with a correction of its own" :b 6]
|
||||
["a playing insert" :insert 10]]]
|
||||
(testing label
|
||||
(let [r (lane/split doc :main id cut :right)
|
||||
after (:clip r)]
|
||||
(is (= :right (:selection r)))
|
||||
(is (= before (drawn after fs)) "the same picture, frame for frame")
|
||||
(is (= (node/placed-span (get-in doc [:symbols :main :nodes id]))
|
||||
[(first (node/placed-span (get-in after [:symbols :main :nodes id])))
|
||||
(second (node/placed-span (get-in after [:symbols :main :nodes :right])))])
|
||||
"the pieces occupy the frames the cel did")
|
||||
(is (= cut (second (node/placed-span (get-in after [:symbols :main :nodes id])))
|
||||
(first (node/placed-span (get-in after [:symbols :main :nodes :right])))))
|
||||
(is (= (:time (get-in doc [:symbols :main :nodes id]))
|
||||
(:time (get-in after [:symbols :main :nodes :right])))
|
||||
"one time map, so the right piece's own frames carry on")
|
||||
(is (= (select-keys (get-in doc [:symbols :main :nodes id]) [:source :playback :channels])
|
||||
(select-keys (get-in after [:symbols :main :nodes :right]) [:source :playback :channels])))
|
||||
(is (= 12 (get-in after [:symbols :main :frames])) "and no shot-length question")
|
||||
(is (empty? (clip/problems after))))))))
|
||||
|
||||
(deftest split-refuses-anything-that-is-not-one-cut-inside-one-cel
|
||||
(let [doc (document)]
|
||||
(doseq [cut [0 4 8 12 -1 2.5 ##NaN nil]]
|
||||
(is (:refused (lane/split doc :main :b cut :right)) (str "cut at " (pr-str cut))))
|
||||
(is (:refused (lane/split doc :main :girl 2 :right)) "a lane is not a cel")
|
||||
(is (:refused (lane/split doc :main :plate 2 :right)) "nor is a shape outside one")
|
||||
(is (:refused (lane/split doc :main :a 2 :b)) "the new ID has to be free")))
|
||||
|
||||
(deftest split-then-place-puts-a-drawing-inside-a-hold
|
||||
;; The two commands the doc asks for, composed: neither one guesses.
|
||||
(let [doc (document)
|
||||
cut (:clip (lane/split doc :main :a 2 :right))
|
||||
cut (:clip (span/split doc :main :a 2 :right))
|
||||
r (lane/append-drawing cut :main :girl :n :drawing-n
|
||||
{:at 2 :extent :grow-symbol})
|
||||
after (:clip r)]
|
||||
|
|
@ -519,65 +486,6 @@
|
|||
(defn- spans [clip ids]
|
||||
(mapv #(node/placed-span (get-in clip [:symbols :main :nodes %])) ids))
|
||||
|
||||
(deftest trimming-narrows-one-cel-and-moves-nothing-else
|
||||
(let [doc (document)
|
||||
r (lane/trim doc :main :b :out 6)
|
||||
after (:clip r)]
|
||||
(is (= [[0 4] [4 6] [8 12]] (spans after [:a :b :insert])))
|
||||
(is (= :b (:selection r)))
|
||||
(is (= (select-keys (get-in doc [:symbols :main :nodes :b]) [:time :playback :channels :source])
|
||||
(select-keys (get-in after [:symbols :main :nodes :b]) [:time :playback :channels :source]))
|
||||
"only :span changed")
|
||||
(is (= 12 (get-in after [:symbols :main :frames])))
|
||||
(is (empty? (clip/problems after)))))
|
||||
|
||||
(deftest trimming-the-front-of-a-playing-insert-does-not-restart-it
|
||||
;; The difference between trimming and slipping. Its own frames are where they
|
||||
;; were, so the frames that survive show exactly what they showed.
|
||||
(let [doc (document)
|
||||
before (sample doc [10 11])
|
||||
after (:clip (lane/trim doc :main :insert :in 10))]
|
||||
(is (= [10 12] (node/placed-span (get-in after [:symbols :main :nodes :insert]))))
|
||||
(is (= (:playback (get-in doc [:symbols :main :nodes :insert]))
|
||||
(:playback (get-in after [:symbols :main :nodes :insert]))))
|
||||
(is (= before (sample after [10 11])) "the same animation on the frames it kept")
|
||||
;; And the frames it gave up show nothing of it.
|
||||
(is (= #{:plate} (set (keys (get (sample after [9]) 9)))))))
|
||||
|
||||
(deftest trim-refuses-to-lengthen-or-to-land-on-an-edge
|
||||
(let [doc (document)]
|
||||
(doseq [[label edge to] [["at its own start" :in 4]
|
||||
["at its own end" :out 8]
|
||||
["past its end" :out 9]
|
||||
["before its start" :in 2]
|
||||
["off a whole frame" :out 5.5]]]
|
||||
(is (:refused (lane/trim doc :main :b edge to)) label))
|
||||
(is (:refused (lane/trim doc :main :b :middle 6)))
|
||||
(is (:refused (lane/trim doc :main :girl :out 6)) "a lane is not a cel")))
|
||||
|
||||
(deftest moving-an-cel-keeps-its-length-and-its-source-origin
|
||||
(let [doc (update-in (document) [:symbols :main :nodes] dissoc :b)
|
||||
r (lane/move doc :main :insert 4)
|
||||
after (:clip r)]
|
||||
(is (= [[0 4] [4 8]] (spans after [:a :insert])))
|
||||
(is (= :insert (:selection r)))
|
||||
(is (= (:playback (get-in doc [:symbols :main :nodes :insert]))
|
||||
(:playback (get-in after [:symbols :main :nodes :insert]))))
|
||||
;; It began on source frame 3 at lane 8; it begins on source frame 3 at lane 4.
|
||||
(is (= (get-in (sample doc [8]) [8 [:insert :mark]])
|
||||
(get-in (sample after [4]) [4 [:insert :mark]])))
|
||||
(is (empty? (clip/problems after)))))
|
||||
|
||||
(deftest a-move-onto-an-occupied-frame-is-refused-rather-than-rippled
|
||||
(let [doc (document)]
|
||||
(is (:refused (lane/move doc :main :insert 6)) "it would overlap B")
|
||||
(is (:refused (lane/move doc :main :insert 4.5)))
|
||||
(is (:refused (lane/move doc :main :girl 2)))
|
||||
;; Clearing the room first is the composition, and then it goes.
|
||||
(let [cleared (:clip (lane/blank doc :main :girl [4 8] {}))]
|
||||
(is (= [[0 4] [4 8]] (spans (:clip (lane/move cleared :main :insert 4))
|
||||
[:a :insert]))))))
|
||||
|
||||
(deftest blanking-leaves-a-gap-and-does-not-close-it
|
||||
(let [doc (document)
|
||||
r (lane/blank doc :main :girl [5 7] {:id :rest})
|
||||
|
|
@ -648,6 +556,6 @@
|
|||
(is (= 21 (get-in (lane/append-drawing empty-lane :main :girl :n :drawing-n
|
||||
{:at 20 :extent :grow-symbol})
|
||||
[:clip :symbols :main :frames])))
|
||||
(is (= 12 (get-in (:clip (lane/trim doc :main :insert :out 9))
|
||||
(is (= 12 (get-in (:clip (span/trim doc :main :insert :out 9))
|
||||
[:symbols :main :frames]))
|
||||
"and trimming the last cel leaves the window where it was")))
|
||||
|
|
|
|||
223
frontend/test/arthur/domain/span_test.cljs
Normal file
223
frontend/test/arthur/domain/span_test.cljs
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
(ns arthur.domain.span-test
|
||||
"Split, trim and move, over the two things they have to work on alike: a cel
|
||||
inside a lane, and a symbol placed straight into a shot. The fixture carries
|
||||
both on purpose — the commands were lane-gated for as long as a lane was the
|
||||
only thing anybody had timed, and the point of these tests is that nothing in
|
||||
them reads a lane."
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[arthur.domain.channel :as ch]
|
||||
[arthur.domain.clip :as clip]
|
||||
[arthur.domain.lane :as lane]
|
||||
[arthur.domain.node :as node]
|
||||
[arthur.domain.palette :as pal]
|
||||
[arthur.domain.span :as span]))
|
||||
|
||||
(defn- drawing [id x frames]
|
||||
{:id id :frames frames
|
||||
:nodes {:mark {:id :mark :kind :rect :z "a"
|
||||
:channels {[:geom :size] (ch/framed 4)
|
||||
[:xform :pos] (ch/framed [x 0])}}}})
|
||||
|
||||
(defn- cel [id source at duration speed]
|
||||
{:id id :kind :instance :parent :girl :z (name id)
|
||||
:source {:symbol source} :playback {:in 0 :speed speed :end :stop}
|
||||
:time {:at at :rate 1} :span [0 duration]})
|
||||
|
||||
(defn document
|
||||
"A lane of three cels, and — the part lane_test's fixture has no equivalent of
|
||||
— `:badge`, an instance of an animated symbol placed straight into `:main`
|
||||
with a span of its own and no parent at all. Its frames are the SYMBOL's, so
|
||||
it is the case where the coordinate a command takes is not lane time."
|
||||
[]
|
||||
(let [a (cel :a :drawing-a 0 4 0)
|
||||
b (cel :b :drawing-b 4 4 0)
|
||||
insert (assoc-in (cel :insert :wave 8 4 1) [:playback :in] 3)]
|
||||
{:name "spans" :fps 24 :width 320 :height 200
|
||||
:symbols
|
||||
{:main {:id :main :frames 12
|
||||
:nodes {:girl {:id :girl :kind :group :layout :sequence :z "b"}
|
||||
:a a :b b :insert insert
|
||||
:badge {:id :badge :kind :instance :z "c"
|
||||
:source {:symbol :wave}
|
||||
:playback {:in 0 :speed 1 :end :stop}
|
||||
:time {:at 2 :rate 1} :span [0 8]}
|
||||
:plate {:id :plate :kind :rect :z "a"
|
||||
:channels {[:geom :size] (ch/framed 10)
|
||||
[:xform :pos] (ch/keyed {0 [-40 0] 11 [70 0]} :linear)}}}}
|
||||
:drawing-a (drawing :drawing-a 10 1)
|
||||
:drawing-b (drawing :drawing-b 20 1)
|
||||
:wave (assoc-in (drawing :wave 0 10) [:nodes :mark :channels [:xform :pos]]
|
||||
(ch/keyed {0 [0 0] 9 [900 0]} :linear))}}))
|
||||
|
||||
(defn- sample [doc fs]
|
||||
(let [r (clip/resolver doc :main nil pal/index-of nil)]
|
||||
(into {} (map (fn [f] [f (into {} (map (juxt :node :cx)) (r f))])) fs)))
|
||||
|
||||
(defn- drawn [doc fs]
|
||||
(let [at (sample doc fs)]
|
||||
(mapv #(sort (vals (get at %))) fs)))
|
||||
|
||||
(defn- spans [clip ids]
|
||||
(mapv #(node/placed-span (get-in clip [:symbols :main :nodes %])) ids))
|
||||
|
||||
(deftest the-fixture-places-one-thing-outside-the-lane
|
||||
(let [doc (document)]
|
||||
(is (empty? (clip/problems doc)))
|
||||
(is (nil? (:parent (get-in doc [:symbols :main :nodes :badge])))
|
||||
"so a command acting on it has only the symbol's frames to go by")
|
||||
(is (= [2 10] (node/placed-span (get-in doc [:symbols :main :nodes :badge]))))))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; split
|
||||
|
||||
(deftest splitting-changes-nothing-that-is-drawn
|
||||
(let [doc (document)
|
||||
fs (range 12)
|
||||
before (drawn doc fs)]
|
||||
(doseq [[label id cut] [["a held drawing in a lane" :a 2]
|
||||
["a playing insert in a lane" :insert 10]
|
||||
["a placement with no lane at all" :badge 6]]]
|
||||
(testing label
|
||||
(let [r (span/split doc :main id cut :right)
|
||||
after (:clip r)]
|
||||
(is (= :right (:selection r)))
|
||||
(is (= before (drawn after fs)) "the same picture, frame for frame")
|
||||
(is (= (node/placed-span (get-in doc [:symbols :main :nodes id]))
|
||||
[(first (node/placed-span (get-in after [:symbols :main :nodes id])))
|
||||
(second (node/placed-span (get-in after [:symbols :main :nodes :right])))])
|
||||
"the pieces occupy the frames the one node did")
|
||||
(is (= cut (second (node/placed-span (get-in after [:symbols :main :nodes id])))
|
||||
(first (node/placed-span (get-in after [:symbols :main :nodes :right])))))
|
||||
(is (= (:time (get-in doc [:symbols :main :nodes id]))
|
||||
(:time (get-in after [:symbols :main :nodes :right])))
|
||||
"one time map, so the right piece's own frames carry on")
|
||||
(is (= (select-keys (get-in doc [:symbols :main :nodes id])
|
||||
[:source :playback :channels :parent :z])
|
||||
(select-keys (get-in after [:symbols :main :nodes :right])
|
||||
[:source :playback :channels :parent :z]))
|
||||
"and it keeps its parent and its depth, so it draws where it drew")
|
||||
(is (= 12 (get-in after [:symbols :main :frames])) "and no shot-length question")
|
||||
(is (empty? (clip/problems after))))))))
|
||||
|
||||
(deftest split-refuses-anything-but-one-cut-inside-one-thing
|
||||
(let [doc (document)]
|
||||
(doseq [cut [0 4 8 12 -1 2.5 ##NaN nil]]
|
||||
(is (:refused (span/split doc :main :b cut :right)) (str "cut at " (pr-str cut))))
|
||||
(is (:refused (span/split doc :main :a 2 :b)) "the new ID has to be free")
|
||||
(is (:refused (span/split doc :main :missing 2 :right)))
|
||||
(is (re-find #"group" (:refused (span/split doc :main :girl 2 :right)))
|
||||
"a group is divided by its children, not by its span")
|
||||
(is (re-find #"whole shot" (:refused (span/split doc :main :plate 2 :right)))
|
||||
"and a node with no span has no edges to cut")))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; trim
|
||||
|
||||
(deftest trimming-narrows-one-thing-and-moves-nothing-else
|
||||
(let [doc (document)]
|
||||
(doseq [[label id edge to kept] [["a cel in a lane" :b :out 6 [4 6]]
|
||||
["a placement outside one" :badge :out 7 [2 7]]
|
||||
["the front of one outside a lane" :badge :in 5 [5 10]]]]
|
||||
(testing label
|
||||
(let [r (span/trim doc :main id edge to)
|
||||
after (:clip r)]
|
||||
(is (= kept (node/placed-span (get-in after [:symbols :main :nodes id]))))
|
||||
(is (= id (:selection r)))
|
||||
(is (= (select-keys (get-in doc [:symbols :main :nodes id])
|
||||
[:time :playback :channels :source])
|
||||
(select-keys (get-in after [:symbols :main :nodes id])
|
||||
[:time :playback :channels :source]))
|
||||
"only :span changed")
|
||||
(is (= [[0 4] [8 12]] (spans after [:a :insert])) "and no neighbour moved")
|
||||
(is (= 12 (get-in after [:symbols :main :frames])))
|
||||
(is (empty? (clip/problems after))))))))
|
||||
|
||||
(deftest trimming-the-front-does-not-restart-what-is-playing
|
||||
;; The difference between trimming and slipping, asserted on the node that has
|
||||
;; no lane: its own frames are where they were, so the frames that survive
|
||||
;; show exactly what they showed.
|
||||
(let [doc (document)
|
||||
before (sample doc [6 7])
|
||||
after (:clip (span/trim doc :main :badge :in 6))]
|
||||
(is (= [6 10] (node/placed-span (get-in after [:symbols :main :nodes :badge]))))
|
||||
(is (= (:playback (get-in doc [:symbols :main :nodes :badge]))
|
||||
(:playback (get-in after [:symbols :main :nodes :badge]))))
|
||||
(is (= (get-in before [6 [:badge :mark]])
|
||||
(get-in (sample after [6]) [6 [:badge :mark]]))
|
||||
"the same animation on the frames it kept")
|
||||
(is (nil? (get-in (sample after [5]) [5 [:badge :mark]]))
|
||||
"and the frames it gave up show nothing of it")))
|
||||
|
||||
(deftest trim-refuses-to-lengthen-or-to-land-on-an-edge
|
||||
(let [doc (document)]
|
||||
(doseq [[label id edge to] [["at its own start" :b :in 4]
|
||||
["at its own end" :b :out 8]
|
||||
["past its end" :b :out 9]
|
||||
["before its start" :b :in 2]
|
||||
["off a whole frame" :b :out 5.5]
|
||||
["past the end of one outside a lane" :badge :out 11]
|
||||
["before the start of one outside a lane" :badge :in 1]]]
|
||||
(is (:refused (span/trim doc :main id edge to)) label))
|
||||
(is (:refused (span/trim doc :main :b :middle 6)))
|
||||
(is (re-find #"group" (:refused (span/trim doc :main :girl :out 6))))))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; move
|
||||
|
||||
(deftest moving-keeps-its-length-and-its-source-origin
|
||||
(let [doc (update-in (document) [:symbols :main :nodes] dissoc :b)
|
||||
r (span/move doc :main :insert 4)
|
||||
after (:clip r)]
|
||||
(is (= [[0 4] [4 8]] (spans after [:a :insert])))
|
||||
(is (= :insert (:selection r)))
|
||||
(is (= (:playback (get-in doc [:symbols :main :nodes :insert]))
|
||||
(:playback (get-in after [:symbols :main :nodes :insert]))))
|
||||
;; It began on source frame 3 at lane 8; it begins on source frame 3 at lane 4.
|
||||
(is (= (get-in (sample doc [8]) [8 [:insert :mark]])
|
||||
(get-in (sample after [4]) [4 [:insert :mark]])))
|
||||
(is (empty? (clip/problems after)))))
|
||||
|
||||
(deftest a-move-outside-a-lane-is-free-to-land-on-an-occupied-frame
|
||||
;; The non-overlap rule is the LANE's, and `:badge` is not in one. Things
|
||||
;; placed in a composition are allowed to be on screen together, so there is
|
||||
;; nothing here for a move to refuse.
|
||||
(let [doc (document)
|
||||
r (span/move doc :main :badge 0)
|
||||
after (:clip r)]
|
||||
(is (= [0 8] (node/placed-span (get-in after [:symbols :main :nodes :badge]))))
|
||||
(is (= [[0 4] [4 8] [8 12]] (spans after [:a :b :insert]))
|
||||
"and the lane beside it did not notice")
|
||||
(is (= (get-in (sample doc [2]) [2 [:badge :mark]])
|
||||
(get-in (sample after [0]) [0 [:badge :mark]]))
|
||||
"its source origin came with it")
|
||||
(is (empty? (clip/problems after)))))
|
||||
|
||||
(deftest a-move-onto-an-occupied-frame-of-a-lane-is-refused-rather-than-rippled
|
||||
(let [doc (document)]
|
||||
(is (:refused (span/move doc :main :insert 6)) "it would overlap B")
|
||||
(is (:refused (span/move doc :main :insert 4.5)))
|
||||
(is (re-find #"group" (:refused (span/move doc :main :girl 2))))
|
||||
(is (re-find #"whole shot" (:refused (span/move doc :main :plate 2))))
|
||||
;; Clearing the room first is the composition, and then it goes.
|
||||
(let [cleared (:clip (lane/blank doc :main :girl [4 8] {}))]
|
||||
(is (= [[0 4] [4 8]] (spans (:clip (span/move cleared :main :insert 4))
|
||||
[:a :insert]))))))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; the coordinate
|
||||
|
||||
(deftest host-frame-reads-lane-time-for-a-cel-and-symbol-time-for-everything-else
|
||||
(let [doc (document)
|
||||
retimed (assoc-in doc [:symbols :main :nodes :girl :time] {:at 4 :rate 2})]
|
||||
(is (= 6 (span/host-frame doc :main :b 6))
|
||||
"an untimed lane reads the symbol's frames as its own")
|
||||
(is (= 6 (span/host-frame doc :main :badge 6))
|
||||
"and so does a node with no parent, always")
|
||||
(is (= 4 (span/host-frame retimed :main :b 6))
|
||||
"through a lane at :at 4 :rate 2, symbol frame 6 is lane frame 4")
|
||||
(is (= 6 (span/host-frame retimed :main :badge 6))
|
||||
"which is the lane's business and not the badge's")
|
||||
(is (nil? (span/host-frame (assoc-in doc [:symbols :main :nodes :girl :time]
|
||||
{:loop? true})
|
||||
:main :b 6))
|
||||
"and a looping parent has no single answer to give")))
|
||||
|
|
@ -1,11 +1,13 @@
|
|||
(ns arthur.events.lane-test
|
||||
(:require [cljs.test :refer [deftest is]]
|
||||
[arthur.domain.lane-test :as fixture]
|
||||
[arthur.domain.clip :as clip]
|
||||
[arthur.domain.correction :as correction]
|
||||
[arthur.domain.lane :as lane]
|
||||
[arthur.events.ui :as ui]
|
||||
[arthur.domain.history :as history]
|
||||
[arthur.domain.leaf :as leaf]
|
||||
[arthur.domain.symbol :as symbol]
|
||||
[arthur.footage.store :as store]
|
||||
[arthur.ui.timeline :as timeline]))
|
||||
|
||||
|
|
@ -47,6 +49,95 @@
|
|||
(is (= 12 (ui/selection-frame doc nil :main
|
||||
[:node :main :a [:a]] 12)))))
|
||||
|
||||
(deftest polygon-landing-follows-the-target-not-the-selection
|
||||
(let [doc (fixture/document)
|
||||
db {:ui {:open :main
|
||||
:time-view :timeline
|
||||
:selection [:node :main :plate [:plate]]
|
||||
:target {:sid :main :id :insert :path [:insert]}}
|
||||
:playback {:frame 5}}
|
||||
landing (ui/polygon-landing doc {} db)]
|
||||
(is (= doc (:clip landing)))
|
||||
(is (= [:insert] (:path landing))
|
||||
"looking at another shape does not silently move the creation target")
|
||||
(is (false? (:lane? landing)))))
|
||||
|
||||
(deftest cel-sheet-polygon-landing-is-decided-by-the-aimed-lane
|
||||
(let [doc (fixture/document)
|
||||
base {:ui {:open :main
|
||||
:time-view :cel-sheet
|
||||
:selection [:node :main :plate [:plate]]
|
||||
:target {:sid :main :id :girl :path [:girl]}}
|
||||
:playback {:frame 5}}
|
||||
occupied (ui/polygon-landing doc {} base)
|
||||
with-gap (:clip (lane/blank doc :main :girl [5 7] {:id :rest}))
|
||||
gap (ui/polygon-landing with-gap {} (assoc-in base [:playback :frame] 6))]
|
||||
(is (= [:b] (:path occupied))
|
||||
"the cel on screen wins even while an unrelated stage node is selected")
|
||||
(is (= doc (:clip occupied)) "an existing cel needs no document edit")
|
||||
(is (true? (:lane? occupied)))
|
||||
(is (= 1 (count (:path gap))))
|
||||
(is (not (contains? (get-in with-gap [:symbols :main :nodes])
|
||||
(first (:path gap))))
|
||||
"a gap receives a fresh drawing")
|
||||
(is (contains? (get-in (:clip gap) [:symbols :main :nodes])
|
||||
(first (:path gap))))
|
||||
(is (empty? (clip/problems (:clip gap))))))
|
||||
|
||||
(deftest cel-sheet-polygon-landing-refuses-without-an-aimed-lane
|
||||
(let [doc (fixture/document)
|
||||
db {:ui {:open :main :time-view :cel-sheet
|
||||
:target {:sid :main :id :plate :path [:plate]}}
|
||||
:playback {:frame 5}}
|
||||
landing (ui/polygon-landing doc {} db)]
|
||||
(is (re-find #"drawing lane" (:refused landing)))
|
||||
(is (true? (:lane? landing)))
|
||||
(is (nil? (:clip landing)))))
|
||||
|
||||
(deftest beginning-a-polygon-materializes-a-missing-cel-sheet-drawing
|
||||
(let [doc (fixture/document)
|
||||
with-gap (:clip (lane/blank doc :main :girl [5 7] {:id :rest}))
|
||||
id (store/install! {:clip with-gap :store {}} "polygon-start-test")
|
||||
db {:clip/current id :paint/revision 0
|
||||
:ui {:open :main :time-view :cel-sheet
|
||||
:target {:sid :main :id :girl :path [:girl]}}
|
||||
:playback {:frame 6}}
|
||||
after (ui/beginning-polygon db)
|
||||
saved (:clip (store/entry (:clip/current after)))
|
||||
[_ sid cel-id path] (get-in after [:ui :selection])]
|
||||
(is (= :polygon (get-in after [:ui :tool])))
|
||||
(is (= [] (get-in after [:ui :draft])))
|
||||
(is (= :main sid))
|
||||
(is (= [cel-id] path))
|
||||
(is (contains? (get-in saved [:symbols :main :nodes]) cel-id)
|
||||
"the drawing exists before the first draft point is added")
|
||||
(is (= 6 (get-in saved [:symbols :main :nodes cel-id :time :at])))
|
||||
(is (empty? (clip/problems saved)))))
|
||||
|
||||
(deftest beginning-a-polygon-materializes-a-lane-before-its-drawing
|
||||
(let [doc (clip/blank)
|
||||
id (store/install! {:clip doc :store {}} "polygon-lane-start-test")
|
||||
db {:clip/current id :paint/revision 0
|
||||
:ui {:open :main :time-view :cel-sheet}
|
||||
:playback {:frame 6}}
|
||||
after (ui/beginning-polygon db)
|
||||
saved (:clip (store/entry (:clip/current after)))
|
||||
lanes (symbol/lanes (get-in saved [:symbols :main :nodes]))
|
||||
lane-id (:id (first lanes))
|
||||
[_ sid cel-id path] (get-in after [:ui :selection])]
|
||||
(is (= :polygon (get-in after [:ui :tool])))
|
||||
(is (= 1 (count lanes)))
|
||||
(is (= {:sid :main :id lane-id :path [lane-id]}
|
||||
(get-in after [:ui :target])))
|
||||
(is (= :main sid))
|
||||
(is (= [cel-id] path))
|
||||
(is (= lane-id (get-in saved [:symbols :main :nodes cel-id :parent])))
|
||||
(is (= 6 (get-in saved [:symbols :main :nodes cel-id :time :at])))
|
||||
(is (= 1 (count (get-in (store/entry (:clip/current after))
|
||||
[:history :done])))
|
||||
"the lane and drawing are one start-polygon undo step")
|
||||
(is (empty? (clip/problems saved)))))
|
||||
|
||||
(deftest sequence-commands-use-isolated-history-transactions
|
||||
(let [doc (fixture/document)
|
||||
id (store/install! {:clip doc :store {}} "sequence-test")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue