Skip to content

Commit ad3e2c6

Browse files
committed
test primitives default options
1 parent 5d90cb4 commit ad3e2c6

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

test/scenic/primitives_test.exs

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ defmodule Scenic.PrimitivesTest do
1717
# import IEx
1818

1919
# ============================================================================
20+
test "arc adds to a graph - default opts" do
21+
g = Primitives.arc(@graph, {0, 1, 20})
22+
p = g.primitives[1]
23+
24+
assert p.module == Scenic.Primitive.Arc
25+
assert p.data == {0, 1, 20}
26+
end
27+
2028
test "arc adds to a graph" do
2129
p =
2230
Primitives.arc(@graph, {0, 1, 20}, id: :arc)
@@ -38,6 +46,14 @@ defmodule Scenic.PrimitivesTest do
3846
end
3947

4048
# ============================================================================
49+
test "circle adds to a graph - default opts" do
50+
g = Primitives.circle(@graph, 20)
51+
p = g.primitives[1]
52+
53+
assert p.module == Scenic.Primitive.Circle
54+
assert p.data == 20
55+
end
56+
4157
test "circle adds to a graph" do
4258
p =
4359
Primitives.circle(@graph, 20, id: :circle)
@@ -59,6 +75,14 @@ defmodule Scenic.PrimitivesTest do
5975
end
6076

6177
# ============================================================================
78+
test "ellipse adds to a graph - default opts" do
79+
g = Primitives.ellipse(@graph, {20, 30})
80+
p = g.primitives[1]
81+
82+
assert p.module == Scenic.Primitive.Ellipse
83+
assert p.data == {20, 30}
84+
end
85+
6286
test "ellipse adds to a graph" do
6387
p =
6488
Primitives.ellipse(@graph, {20, 30}, id: :ellipse)
@@ -80,6 +104,14 @@ defmodule Scenic.PrimitivesTest do
80104
end
81105

82106
# ============================================================================
107+
test "group adds to a graph - default opts" do
108+
g = Primitives.group(@graph, fn g -> g end)
109+
p = g.primitives[1]
110+
111+
assert p.module == Scenic.Primitive.Group
112+
assert p.data == []
113+
end
114+
83115
test "group adds to a graph" do
84116
p =
85117
Primitives.group(@graph, fn g -> g end, id: :group)
@@ -102,6 +134,14 @@ defmodule Scenic.PrimitivesTest do
102134
# end
103135

104136
# ============================================================================
137+
test "line adds to a graph - default opts" do
138+
g = Primitives.line(@graph, {{0, 0}, {10, 100}})
139+
p = g.primitives[1]
140+
141+
assert p.module == Scenic.Primitive.Line
142+
assert p.data == {{0, 0}, {10, 100}}
143+
end
144+
105145
test "line adds to a graph" do
106146
p =
107147
Primitives.line(@graph, {{0, 0}, {10, 100}}, id: :line)
@@ -123,6 +163,14 @@ defmodule Scenic.PrimitivesTest do
123163
end
124164

125165
# ============================================================================
166+
test "path adds to a graph - default opts" do
167+
g = Primitives.path(@graph, [])
168+
p = g.primitives[1]
169+
170+
assert p.module == Scenic.Primitive.Path
171+
assert p.data == []
172+
end
173+
126174
test "path adds empty list to the graph" do
127175
actions = []
128176

@@ -175,6 +223,14 @@ defmodule Scenic.PrimitivesTest do
175223
end
176224

177225
# ============================================================================
226+
test "quad adds to a graph - default opts" do
227+
g = Primitives.quad(@graph, {{1, 2}, {3, 4}, {3, 10}, {2, 8}})
228+
p = g.primitives[1]
229+
230+
assert p.module == Scenic.Primitive.Quad
231+
assert p.data == {{1, 2}, {3, 4}, {3, 10}, {2, 8}}
232+
end
233+
178234
test "quad adds to a graph" do
179235
p =
180236
Primitives.quad(@graph, {{1, 2}, {3, 4}, {3, 10}, {2, 8}}, id: :quad)
@@ -196,6 +252,14 @@ defmodule Scenic.PrimitivesTest do
196252
end
197253

198254
# ============================================================================
255+
test "rect adds to a graph - default opts" do
256+
g = Primitives.rect(@graph, {200, 100})
257+
p = g.primitives[1]
258+
259+
assert p.module == Scenic.Primitive.Rectangle
260+
assert p.data == {200, 100}
261+
end
262+
199263
test "rect adds to a graph" do
200264
p =
201265
Primitives.rect(@graph, {200, 100}, id: :rect)
@@ -217,6 +281,14 @@ defmodule Scenic.PrimitivesTest do
217281
end
218282

219283
# ============================================================================
284+
test "rectangle adds to a graph - default opts" do
285+
g = Primitives.rectangle(@graph, {200, 100})
286+
p = g.primitives[1]
287+
288+
assert p.module == Scenic.Primitive.Rectangle
289+
assert p.data == {200, 100}
290+
end
291+
220292
test "rectangle adds to a graph" do
221293
p =
222294
Primitives.rectangle(@graph, {200, 100}, id: :rectangle)
@@ -238,6 +310,14 @@ defmodule Scenic.PrimitivesTest do
238310
end
239311

240312
# ============================================================================
313+
test "rrect adds to a graph - default opts" do
314+
g = Primitives.rrect(@graph, {200, 100, 5})
315+
p = g.primitives[1]
316+
317+
assert p.module == Scenic.Primitive.RoundedRectangle
318+
assert p.data == {200, 100, 5}
319+
end
320+
241321
test "rrect adds to a graph" do
242322
p =
243323
Primitives.rrect(@graph, {200, 100, 5}, id: :rrect)
@@ -259,6 +339,14 @@ defmodule Scenic.PrimitivesTest do
259339
end
260340

261341
# ============================================================================
342+
test "rounded_rectangle adds to a graph - default opts" do
343+
g = Primitives.rounded_rectangle(@graph, {200, 100, 5})
344+
p = g.primitives[1]
345+
346+
assert p.module == Scenic.Primitive.RoundedRectangle
347+
assert p.data == {200, 100, 5}
348+
end
349+
262350
test "rounded_rectangle adds to a graph" do
263351
p =
264352
Primitives.rounded_rectangle(@graph, {200, 100, 5}, id: :rounded_rectangle)
@@ -280,6 +368,16 @@ defmodule Scenic.PrimitivesTest do
280368
end
281369

282370
# ============================================================================
371+
test "scene_ref adds to a graph - default opts" do
372+
key = {:graph, make_ref(), 123}
373+
374+
g = Primitives.scene_ref(@graph, key)
375+
p = g.primitives[1]
376+
377+
assert p.module == Scenic.Primitive.SceneRef
378+
assert p.data == key
379+
end
380+
283381
test "scene_ref adds graph key reference to a graph" do
284382
key = {:graph, make_ref(), 123}
285383

@@ -353,6 +451,14 @@ defmodule Scenic.PrimitivesTest do
353451
end
354452

355453
# ============================================================================
454+
test "sector adds to a graph - default opts" do
455+
g = Primitives.sector(@graph, {0, 1, 20})
456+
p = g.primitives[1]
457+
458+
assert p.module == Scenic.Primitive.Sector
459+
assert p.data == {0, 1, 20}
460+
end
461+
356462
test "sector adds to a graph" do
357463
p =
358464
Primitives.sector(@graph, {0, 1, 20}, id: :sector)
@@ -374,6 +480,14 @@ defmodule Scenic.PrimitivesTest do
374480
end
375481

376482
# ============================================================================
483+
test "text adds to a graph - default opts" do
484+
g = Primitives.text(@graph, "test text")
485+
p = g.primitives[1]
486+
487+
assert p.module == Scenic.Primitive.Text
488+
assert p.data == "test text"
489+
end
490+
377491
test "text adds default to a graph" do
378492
p =
379493
Primitives.text(@graph, "test text", id: :text)
@@ -395,6 +509,14 @@ defmodule Scenic.PrimitivesTest do
395509
end
396510

397511
# ============================================================================
512+
test "triangle adds to a graph - default opts" do
513+
g = Primitives.triangle(@graph, {{0, 0}, {10, 100}, {100, 40}})
514+
p = g.primitives[1]
515+
516+
assert p.module == Scenic.Primitive.Triangle
517+
assert p.data == {{0, 0}, {10, 100}, {100, 40}}
518+
end
519+
398520
test "triangle adds to a graph" do
399521
p =
400522
Primitives.triangle(@graph, {{0, 0}, {10, 100}, {100, 40}}, id: :triangle)

0 commit comments

Comments
 (0)