1
+ /*
2
+ * FXGL - JavaFX Game Library. The MIT License (MIT).
3
+ * Copyright (c) AlmasB ([email protected] ).
4
+ * See LICENSE for details.
5
+ */
6
+ @file:Suppress(" JAVA_MODULE_DOES_NOT_DEPEND_ON_MODULE" )
7
+ package com.almasb.fxgl.particle
8
+
9
+ import com.almasb.fxgl.entity.Entity
10
+ import com.almasb.fxgl.entity.GameWorld
11
+ import com.almasb.fxgl.entity.component.ComponentHelper
12
+ import org.hamcrest.CoreMatchers.`is`
13
+ import org.hamcrest.MatcherAssert.assertThat
14
+ import org.junit.jupiter.api.Assertions.assertNotNull
15
+ import org.junit.jupiter.api.Assertions.assertNull
16
+ import org.junit.jupiter.api.BeforeEach
17
+ import org.junit.jupiter.api.Test
18
+
19
+ /* *
20
+ *
21
+ * @author Jean-Rene Lavoie ([email protected] )
22
+ */
23
+ class ParticleComponentTest {
24
+
25
+ private lateinit var world: GameWorld
26
+ private lateinit var particle: ParticleComponent
27
+
28
+ @BeforeEach
29
+ fun setUp () {
30
+ world = GameWorld ()
31
+ particle = ParticleComponent (ParticleEmitter ())
32
+ }
33
+
34
+ @Test
35
+ fun `Create ParticleComponent with zIndex` () {
36
+ assertNull(particle.entity)
37
+ assertNotNull(particle.parent)
38
+ assertThat(particle.parent.zIndex, `is `(0 ))
39
+
40
+ val e = Entity ()
41
+ e.zIndex = 100
42
+
43
+ ComponentHelper .setEntity(particle, e)
44
+ world.addEntity(e)
45
+ particle.onAdded()
46
+ particle.onUpdate(1.0 )
47
+
48
+ assertThat(particle.parent.zIndex, `is `(100 ))
49
+
50
+ e.zIndex = 200
51
+ particle.onUpdate(1.0 )
52
+
53
+ assertThat(particle.parent.zIndex, `is `(100 ))
54
+ }
55
+
56
+ }
0 commit comments