59 lines
3.1 KiB
Clojure
59 lines
3.1 KiB
Clojure
(ns arthur.domain.bring-test
|
|
(:require [cljs.test :refer [deftest is]]
|
|
[arthur.domain.bring :as bring]
|
|
[arthur.domain.clip :as clip]
|
|
[arthur.domain.node :as node]))
|
|
|
|
(defn- nested
|
|
"Three symbols: :outer places :inner, and :loose is placed by nothing."
|
|
[]
|
|
(-> (clip/blank)
|
|
(assoc-in [:symbols :outer] {:id :outer :frames 200 :nodes {}})
|
|
(assoc-in [:symbols :inner] {:id :inner :frames 10 :nodes {}})
|
|
(assoc-in [:symbols :loose] {:id :loose :frames 30 :nodes {}})
|
|
(clip/place-symbol nil :outer :inner 5 (random-uuid) nil)))
|
|
|
|
(deftest adopting-symbols-renames-what-collides
|
|
(let [here (nested)
|
|
there (-> (clip/blank)
|
|
(assoc-in [:symbols :inner] {:id :inner :frames 4 :nodes {}})
|
|
(clip/place-symbol nil :main :inner 0 #uuid "00000000-0000-4000-8000-0000000000aa" nil))
|
|
{:keys [clip ids]} (bring/symbols here there [:main] {:main :take})]
|
|
(is (= {:main :take :inner :inner-2} ids)
|
|
"the root gets the name asked for; a taken id gets the next free one")
|
|
(is (= 10 (clip/frames clip :inner)) "what was already here is untouched")
|
|
(is (= #{:inner-2} (node/sources (first (filter #(= :instance (:kind %))
|
|
(vals (get-in clip [:symbols :take :nodes]))))))
|
|
"and the copy's instance follows its renamed symbol")
|
|
(is (empty? (clip/problems clip)))))
|
|
|
|
(defn- tracked-take [analysis-id]
|
|
{:analyses {analysis-id {:id analysis-id :detector "test" :version "1"}}
|
|
:subjects {:face-1 {:id :face-1 :analysis analysis-id
|
|
:source-subject :face-1 :params {}}}
|
|
:features {:face-1/mouth {:id :face-1/mouth :subject :face-1
|
|
:symbol :face-1 :area :mouth :nodes [:mouth] :params {}}}
|
|
:groups {}
|
|
:symbols {:main {:id :main :fps 30 :frames 10
|
|
:nodes {:face-1 {:id :face-1 :kind :instance :z "a1"
|
|
:source {:symbol :face-1}}}}
|
|
:face-1 {:id :face-1 :fps 30 :frames 10
|
|
:nodes {:head {:id :head :kind :group :z "a1"
|
|
:measured {[:xform :pos]
|
|
{:animated? false :value [0 0]}}}
|
|
:mouth {:id :mouth :kind :poly :z "a2"}}}}})
|
|
|
|
(deftest every-import-is-tracked-under-its-unique-symbol-scope
|
|
(let [first (bring/take (clip/blank) (tracked-take "analysis-a")
|
|
"close up" "footage-a" [0 10])
|
|
second (bring/take (:clip first) (tracked-take "analysis-b")
|
|
"close up" "footage-b" [0 10])
|
|
c (:clip second)]
|
|
(is (= #{:close-up.face-1 :close-up-2.face-1} (set (keys (:subjects c)))))
|
|
(is (= #{"analysis-a" "analysis-b"} (set (keys (:analyses c)))))
|
|
(is (= "analysis-a" (get-in c [:subjects :close-up.face-1 :analysis])))
|
|
(is (= "analysis-b" (get-in c [:subjects :close-up-2.face-1 :analysis])))
|
|
(is (= :face-1 (get-in c [:subjects :close-up-2.face-1 :source-subject])))
|
|
(is (= #{:close-up.face-1/mouth :close-up-2.face-1/mouth}
|
|
(set (keys (:features c)))))
|
|
(is (empty? (clip/problems c)))))
|