-
Notifications
You must be signed in to change notification settings - Fork 47
/
PathConverterTest.kt
81 lines (63 loc) · 2.6 KB
/
PathConverterTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Copyright (c) 2023. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
package org.jetbrains.letsPlot.core.plot.livemap
import org.jetbrains.letsPlot.core.plot.base.aes.AestheticsBuilder.Companion.constant
import org.jetbrains.letsPlot.core.plot.base.geom.PathGeom
import org.jetbrains.letsPlot.core.plot.base.render.linetype.NamedLineType
import org.jetbrains.letsPlot.core.plot.livemap.ConverterDataHelper.AestheticsDataHelper
import org.jetbrains.letsPlot.core.plot.livemap.ConverterDataHelper.GENERIC_POINTS
import org.jetbrains.letsPlot.core.plot.livemap.ConverterDataHelper.PATH
import org.jetbrains.letsPlot.core.plot.livemap.ConverterDataHelper.createDefaultMatcher
import org.jetbrains.letsPlot.core.plot.livemap.MapObjectMatcher.Companion.eq
import org.jetbrains.letsPlot.core.plot.livemap.MapObjectMatcher.Companion.geometryEq
import org.jetbrains.letsPlot.core.plot.livemap.MapObjectMatcher.Companion.sizeEq
import org.jetbrains.letsPlot.core.plot.livemap.MapObjectMatcher.Companion.vectorEq
import org.jetbrains.letsPlot.gis.geoprotocol.Boundary
import kotlin.test.BeforeTest
import kotlin.test.Test
class PathConverterTest {
private var aesData: AestheticsDataHelper? = null
private var matcher: MapObjectMatcher? = null
@BeforeTest
fun setUp() {
aesData = AestheticsDataHelper.create()
aesData!!.addGroup(GENERIC_POINTS)
matcher = createDefaultMatcher()
.geometry(geometryEq(Boundary.create(PATH)))
}
@Test
fun blankLineShouldNotHaveDashPattern() {
aesData!!.builder().lineType(constant(NamedLineType.BLANK))
matcher!!.lineDash(vectorEq(emptyList()))
assertMapObject()
}
@Test
fun dashedLineWithoutSizeShouldBeInitializedProperly() {
aesData!!.builder().lineType(constant(NamedLineType.DASHED))
matcher!!
.strokeWidth(eq(1.1))
.lineDash(vectorEq(listOf(4.4, 4.4)))
assertMapObject()
}
@Test
fun dashedLineWithSizeShouldBeInitializedProperly() {
aesData!!.builder()
.lineType(constant(NamedLineType.DASHED))
.size(constant(2.0))
matcher!!
.strokeWidth(eq(4.4))
.lineDash(vectorEq(listOf(17.6, 17.6)))
assertMapObject()
}
@Test
fun path_ShouldContainOneBoundingBoxes() {
matcher!!.locationBoundingBoxes(sizeEq(1))
assertMapObject()
}
private fun assertMapObject() {
val mapObjectList = aesData!!.buildConverter().toPath(PathGeom())
matcher!!.match(mapObjectList[0])
}
}