Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
7d7fa80a
Unverified
Commit
7d7fa80a
authored
Oct 27, 2021
by
Shagen Ogandzhanian
Committed by
GitHub
Oct 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce ignore annotations for tests on all target platforms (#312)
parent
5ffb56ca
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
230 additions
and
199 deletions
+230
-199
Shaper.kt
...src/commonMain/kotlin/org/jetbrains/skia/shaper/Shaper.kt
+10
-10
ParagraphTest.kt
...src/commonTest/kotlin/org/jetbrains/skia/ParagraphTest.kt
+8
-5
PathTests.kt
skiko/src/commonTest/kotlin/org/jetbrains/skia/PathTests.kt
+183
-0
TestLineTest.kt
.../src/commonTest/kotlin/org/jetbrains/skia/TestLineTest.kt
+5
-0
TestUtils.kt
.../commonTest/kotlin/org/jetbrains/skiko/tests/TestUtils.kt
+6
-2
TestUtils.js.kt
skiko/src/jsTest/kotlin/TestUtils.js.kt
+6
-3
TestUtils.jvm.kt
skiko/src/jvmTest/kotlin/TestUtils.jvm.kt
+6
-2
PathTest.kt
skiko/src/jvmTest/kotlin/org/jetbrains/skiko/PathTest.kt
+0
-174
TestUtils.native.kt
...Test/kotlin/org/jetbrains/skiko/tests/TestUtils.native.kt
+6
-3
No files found.
skiko/src/commonMain/kotlin/org/jetbrains/skia/shaper/Shaper.kt
View file @
7d7fa80a
...
@@ -226,28 +226,28 @@ class Shaper internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerH
...
@@ -226,28 +226,28 @@ class Shaper internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerH
}
}
@ExternalSymbolName
(
"org_jetbrains_skia_Shaper__1nGetFinalizer"
)
@ExternalSymbolName
(
"org_jetbrains_skia_
shaper_
Shaper__1nGetFinalizer"
)
private
external
fun
Shaper_nGetFinalizer
():
NativePointer
private
external
fun
Shaper_nGetFinalizer
():
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_Shaper__1nMake"
)
@ExternalSymbolName
(
"org_jetbrains_skia_
shaper_
Shaper__1nMake"
)
private
external
fun
Shaper_nMake
(
fontMgrPtr
:
NativePointer
):
NativePointer
private
external
fun
Shaper_nMake
(
fontMgrPtr
:
NativePointer
):
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_Shaper__1nMakePrimitive"
)
@ExternalSymbolName
(
"org_jetbrains_skia_
shaper_
Shaper__1nMakePrimitive"
)
private
external
fun
_nMakePrimitive
():
NativePointer
private
external
fun
_nMakePrimitive
():
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_Shaper__1nMakeShaperDrivenWrapper"
)
@ExternalSymbolName
(
"org_jetbrains_skia_
shaper_
Shaper__1nMakeShaperDrivenWrapper"
)
private
external
fun
_nMakeShaperDrivenWrapper
(
fontMgrPtr
:
NativePointer
):
NativePointer
private
external
fun
_nMakeShaperDrivenWrapper
(
fontMgrPtr
:
NativePointer
):
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_Shaper__1nMakeShapeThenWrap"
)
@ExternalSymbolName
(
"org_jetbrains_skia_
shaper_
Shaper__1nMakeShapeThenWrap"
)
private
external
fun
_nMakeShapeThenWrap
(
fontMgrPtr
:
NativePointer
):
NativePointer
private
external
fun
_nMakeShapeThenWrap
(
fontMgrPtr
:
NativePointer
):
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_Shaper__1nMakeShapeDontWrapOrReorder"
)
@ExternalSymbolName
(
"org_jetbrains_skia_
shaper_
Shaper__1nMakeShapeDontWrapOrReorder"
)
private
external
fun
_nMakeShapeDontWrapOrReorder
(
fontMgrPtr
:
NativePointer
):
NativePointer
private
external
fun
_nMakeShapeDontWrapOrReorder
(
fontMgrPtr
:
NativePointer
):
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_Shaper__1nMakeCoreText"
)
@ExternalSymbolName
(
"org_jetbrains_skia_
shaper_
Shaper__1nMakeCoreText"
)
private
external
fun
_nMakeCoreText
():
NativePointer
private
external
fun
_nMakeCoreText
():
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_Shaper__1nShapeBlob"
)
@ExternalSymbolName
(
"org_jetbrains_skia_
shaper_
Shaper__1nShapeBlob"
)
private
external
fun
_nShapeBlob
(
private
external
fun
_nShapeBlob
(
ptr
:
NativePointer
,
ptr
:
NativePointer
,
text
:
String
?,
text
:
String
?,
...
@@ -259,10 +259,10 @@ private external fun _nShapeBlob(
...
@@ -259,10 +259,10 @@ private external fun _nShapeBlob(
):
NativePointer
):
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_Shaper__1nShapeLine"
)
@ExternalSymbolName
(
"org_jetbrains_skia_
shaper_
Shaper__1nShapeLine"
)
private
external
fun
_nShapeLine
(
ptr
:
NativePointer
,
text
:
String
?,
fontPtr
:
NativePointer
,
opts
:
ShapingOptions
?):
NativePointer
private
external
fun
_nShapeLine
(
ptr
:
NativePointer
,
text
:
String
?,
fontPtr
:
NativePointer
,
opts
:
ShapingOptions
?):
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_Shaper__1nShape"
)
@ExternalSymbolName
(
"org_jetbrains_skia_
shaper_
Shaper__1nShape"
)
private
external
fun
_nShape
(
private
external
fun
_nShape
(
ptr
:
NativePointer
,
ptr
:
NativePointer
,
textPtr
:
NativePointer
,
textPtr
:
NativePointer
,
...
...
skiko/src/
jvmTest/kotlin/org/jetbrains/skiko
/ParagraphTest.kt
→
skiko/src/
commonTest/kotlin/org/jetbrains/skia
/ParagraphTest.kt
View file @
7d7fa80a
package
org.jetbrains.ski
ko
package
org.jetbrains.ski
a
import
org.jetbrains.skia.FontMgr
import
org.jetbrains.skia.impl.use
import
org.jetbrains.skia.FontStyle
import
org.jetbrains.skia.paragraph.FontCollection
import
org.jetbrains.skia.paragraph.FontCollection
import
org.jetbrains.skia.paragraph.LineMetrics
import
org.jetbrains.skia.paragraph.LineMetrics
import
org.jetbrains.skia.paragraph.ParagraphBuilder
import
org.jetbrains.skia.paragraph.ParagraphBuilder
import
org.jetbrains.skia.paragraph.ParagraphStyle
import
org.jetbrains.skia.paragraph.ParagraphStyle
import
org.junit.Assert.assertEquals
import
org.jetbrains.skiko.tests.SkipJsTarget
import
org.junit.Test
import
org.jetbrains.skiko.tests.SkipNativeTarget
import
kotlin.test.Test
import
kotlin.test.assertEquals
@SkipJsTarget
@SkipNativeTarget
class
ParagraphTest
{
class
ParagraphTest
{
private
val
fontCollection
=
FontCollection
().
setDefaultFontManager
(
FontMgr
.
default
)
private
val
fontCollection
=
FontCollection
().
setDefaultFontManager
(
FontMgr
.
default
)
...
...
skiko/src/commonTest/kotlin/org/jetbrains/skia/PathTests.kt
View file @
7d7fa80a
package
org.jetbrains.skia
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.use
import
org.jetbrains.skia.impl.use
import
org.jetbrains.skiko.tests.SkipJsTarget
import
org.jetbrains.skiko.tests.SkipNativeTarget
import
kotlin.test.Test
import
kotlin.test.Test
import
kotlin.test.assertTrue
import
kotlin.test.assertTrue
import
kotlin.test.assertFalse
import
kotlin.test.assertFalse
import
kotlin.test.assertEquals
import
kotlin.test.assertEquals
import
kotlin.test.assertFailsWith
import
kotlin.test.assertFailsWith
import
org.jetbrains.skiko.tests.runTest
import
org.jetbrains.skiko.tests.runTest
import
kotlin.test.assertContentEquals
import
kotlin.test.assertNotEquals
import
kotlin.test.assertNull
class
PathTests
{
class
PathTests
{
...
@@ -63,4 +68,182 @@ class PathTests {
...
@@ -63,4 +68,182 @@ class PathTests {
}
}
@Test
@SkipJsTarget
@SkipNativeTarget
fun
isShapeTest
()
{
for
(
dir
in
PathDirection
.
values
())
{
for
(
start
in
0
..
3
)
{
Path
().
addRect
(
Rect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
),
dir
,
start
).
use
{
p
->
assertEquals
(
Rect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
),
p
.
isRect
)
assertNull
(
p
.
isOval
)
assertNull
(
p
.
isRRect
)
}
}
}
for
(
dir
in
PathDirection
.
values
())
{
for
(
start
in
0
..
3
)
{
Path
().
addOval
(
Rect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
),
dir
,
start
).
use
{
p
->
assertNull
(
p
.
isRect
)
assertEquals
(
Rect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
),
p
.
isOval
)
assertNull
(
p
.
isRRect
)
}
}
}
for
(
dir
in
PathDirection
.
values
())
{
Path
().
addCircle
(
20f
,
20f
,
20f
,
dir
).
use
{
p
->
assertNull
(
p
.
isRect
)
assertEquals
(
Rect
.
makeLTRB
(
0f
,
0f
,
40f
,
40f
),
p
.
isOval
)
assertNull
(
p
.
isRRect
)
}
}
for
(
dir
in
PathDirection
.
values
())
{
for
(
start
in
0
..
7
)
{
Path
().
addRRect
(
RRect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
,
5f
),
dir
,
start
).
use
{
p
->
assertNull
(
p
.
isRect
)
assertNull
(
p
.
isOval
)
assertEquals
(
RRect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
,
5f
),
p
.
isRRect
)
}
Path
().
addRRect
(
RRect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
,
0f
),
dir
,
start
).
use
{
p
->
assertEquals
(
Rect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
),
p
.
isRect
)
assertNull
(
p
.
isOval
)
assertNull
(
p
.
isRRect
)
}
Path
().
addRRect
(
RRect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
,
20f
,
10f
),
dir
,
start
).
use
{
p
->
assertNull
(
p
.
isRect
)
assertEquals
(
Rect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
),
p
.
isOval
)
assertNull
(
p
.
isRRect
)
}
}
}
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
().
use
{
p
->
assertNull
(
p
.
isRect
)
assertNull
(
p
.
isOval
)
assertNull
(
p
.
isRRect
)
}
}
@Test
@SkipJsTarget
@SkipNativeTarget
fun
checksTest
()
{
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
().
use
{
p
->
assertFalse
(
p
.
isEmpty
)
p
.
reset
()
assertTrue
(
p
.
isEmpty
)
}
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
().
use
{
p
->
assertFalse
(
p
.
isEmpty
)
p
.
rewind
()
assertTrue
(
p
.
isEmpty
)
}
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
use
{
p
->
assertFalse
(
p
.
isLastContourClosed
)
p
.
closePath
()
assertTrue
(
p
.
isLastContourClosed
)
p
.
moveTo
(
100f
,
100f
).
lineTo
(
140f
,
140f
).
lineTo
(
140f
,
100f
).
lineTo
(
100f
,
140f
)
assertFalse
(
p
.
isLastContourClosed
)
p
.
closePath
()
assertTrue
(
p
.
isLastContourClosed
)
}
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
use
{
p
->
assertTrue
(
p
.
isFinite
)
}
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
Float
.
POSITIVE_INFINITY
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
().
use
{
p
->
assertEquals
(
false
,
p
.
isFinite
)
}
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
use
{
p
->
assertFalse
(
p
.
isVolatile
)
p
.
setVolatile
(
true
)
assertTrue
(
p
.
isVolatile
)
p
.
setVolatile
(
false
)
assertFalse
(
p
.
isVolatile
)
}
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
().
use
{
p
->
assertNull
(
p
.
asLine
)
}
Path
().
moveTo
(
20f
,
20f
).
lineTo
(
40f
,
40f
).
use
{
p
->
assertContentEquals
(
arrayOf
(
Point
(
20f
,
20f
),
Point
(
40f
,
40f
)
),
p
.
asLine
)
}
}
@Test
@SkipJsTarget
@SkipNativeTarget
fun
swapTest
()
{
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
().
use
{
p1
->
Path
().
lineTo
(
0f
,
0f
).
lineTo
(
20f
,
20f
).
use
{
p2
->
p1
.
swap
(
p2
)
assertEquals
(
Path
().
lineTo
(
0f
,
0f
).
lineTo
(
20f
,
20f
),
p1
)
assertEquals
(
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
(),
p2
)
}
}
}
@Test
@SkipJsTarget
@SkipNativeTarget
fun
containsTest
()
{
Path
().
addRRect
(
RRect
.
makeLTRB
(
10f
,
20f
,
54f
,
120f
,
10f
,
20f
)).
use
{
p
->
assertTrue
(
p
.
conservativelyContainsRect
(
Rect
.
makeLTRB
(
10f
,
40f
,
54f
,
80f
)))
assertTrue
(
p
.
conservativelyContainsRect
(
Rect
.
makeLTRB
(
25f
,
20f
,
39f
,
120f
)))
assertTrue
(
p
.
conservativelyContainsRect
(
Rect
.
makeLTRB
(
15f
,
25f
,
49f
,
115f
)))
assertTrue
(
p
.
conservativelyContainsRect
(
Rect
.
makeLTRB
(
13f
,
27f
,
51f
,
113f
)))
assertFalse
(
p
.
conservativelyContainsRect
(
Rect
.
makeLTRB
(
0f
,
40f
,
60f
,
80f
)))
assertTrue
(
p
.
contains
(
30f
,
70f
))
assertFalse
(
p
.
contains
(
0f
,
0f
))
}
}
@Test
@SkipJsTarget
@SkipNativeTarget
fun
utilsTest
()
{
assertFalse
(
Path
.
isLineDegenerate
(
Point
(
0f
,
0f
),
Point
(
10f
,
0f
),
false
))
assertTrue
(
Path
.
isLineDegenerate
(
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
true
))
assertTrue
(
Path
.
isLineDegenerate
(
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
false
))
assertFalse
(
Path
.
isLineDegenerate
(
Point
(
0f
,
0f
),
Point
(
0f
,
1e-13f
),
true
))
assertFalse
(
Path
.
isQuadDegenerate
(
Point
(
0f
,
0f
),
Point
(
10f
,
0f
),
Point
(
0f
,
0f
),
false
))
assertTrue
(
Path
.
isQuadDegenerate
(
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
false
))
assertFalse
(
Path
.
isCubicDegenerate
(
Point
(
0f
,
0f
),
Point
(
10f
,
0f
),
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
false
))
assertTrue
(
Path
.
isCubicDegenerate
(
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
false
))
assertContentEquals
(
arrayOf
(
Point
(
0f
,
20f
),
Point
(
6.666667f
,
13.333334f
)),
Path
.
convertConicToQuads
(
Point
(
0f
,
20f
),
Point
(
20f
,
0f
),
Point
(
40f
,
20f
),
0.5f
,
1
)
)
assertContentEquals
(
arrayOf
(
Point
(
0f
,
20f
),
Point
(
3.0940108f
,
16.905989f
),
Point
(
8.452994f
,
15.119661f
),
Point
(
13.811978f
,
13.333334f
)
),
Path
.
convertConicToQuads
(
Point
(
0f
,
20f
),
Point
(
20f
,
0f
),
Point
(
40f
,
20f
),
0.5f
,
2
)
)
Path
().
lineTo
(
40f
,
40f
).
use
{
p
->
val
g1
=
p
.
generationId
p
.
lineTo
(
10f
,
40f
)
val
g2
=
p
.
generationId
assertNotEquals
(
g1
,
g2
)
p
.
fillMode
=
PathFillMode
.
EVEN_ODD
val
g3
=
p
.
generationId
assertEquals
(
g2
,
g3
)
}
}
@Test
@SkipJsTarget
@SkipNativeTarget
fun
serializeTest
()
{
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
().
use
{
p
->
val
p2
:
Path
=
Path
.
makeFromBytes
(
p
.
serializeToBytes
())
assertEquals
(
p
,
p2
)
}
}
}
}
\ No newline at end of file
skiko/src/
jvmTest/kotlin/org/jetbrains/skiko
/TestLineTest.kt
→
skiko/src/
commonTest/kotlin/org/jetbrains/skia
/TestLineTest.kt
View file @
7d7fa80a
...
@@ -3,6 +3,9 @@ package org.jetbrains.skiko
...
@@ -3,6 +3,9 @@ package org.jetbrains.skiko
import
org.jetbrains.skia.Font
import
org.jetbrains.skia.Font
import
org.jetbrains.skia.TextLine
import
org.jetbrains.skia.TextLine
import
org.jetbrains.skia.Typeface
import
org.jetbrains.skia.Typeface
import
org.jetbrains.skia.impl.use
import
org.jetbrains.skiko.tests.SkipJsTarget
import
org.jetbrains.skiko.tests.SkipNativeTarget
import
kotlin.test.Test
import
kotlin.test.Test
import
kotlin.test.assertContentEquals
import
kotlin.test.assertContentEquals
import
kotlin.test.assertEquals
import
kotlin.test.assertEquals
...
@@ -11,6 +14,8 @@ import org.jetbrains.skia.tests.makeFromResource
...
@@ -11,6 +14,8 @@ import org.jetbrains.skia.tests.makeFromResource
import
org.jetbrains.skia.tests.assertCloseEnough
import
org.jetbrains.skia.tests.assertCloseEnough
import
org.jetbrains.skiko.tests.runTest
import
org.jetbrains.skiko.tests.runTest
@SkipJsTarget
@SkipNativeTarget
class
TextLineTest
{
class
TextLineTest
{
private
val
inter36
:
suspend
()
->
Font
=
suspend
{
private
val
inter36
:
suspend
()
->
Font
=
suspend
{
Font
(
Typeface
.
makeFromResource
(
"./fonts/Inter-Hinted-Regular.ttf"
),
36f
)
Font
(
Typeface
.
makeFromResource
(
"./fonts/Inter-Hinted-Regular.ttf"
),
36f
)
...
...
skiko/src/commonTest/kotlin/org/jetbrains/skiko/tests/TestUtils.kt
View file @
7d7fa80a
...
@@ -3,8 +3,12 @@ package org.jetbrains.skiko.tests
...
@@ -3,8 +3,12 @@ package org.jetbrains.skiko.tests
import
org.jetbrains.skia.impl.InteropScope
import
org.jetbrains.skia.impl.InteropScope
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.NativePointer
expect
annotation
class
IgnoreTestOnJvm
()
expect
fun
runTest
(
block
:
suspend
()
->
Unit
)
expect
fun
runTest
(
block
:
suspend
()
->
Unit
)
expect
fun
InteropScope
.
allocateBytesForPixels
(
size
:
Int
):
NativePointer
expect
fun
InteropScope
.
allocateBytesForPixels
(
size
:
Int
):
NativePointer
expect
annotation
class
SkipNativeTarget
expect
annotation
class
SkipJsTarget
expect
annotation
class
SkipJvmTarget
skiko/src/jsTest/kotlin/TestUtils.js.kt
View file @
7d7fa80a
...
@@ -7,9 +7,6 @@ import org.jetbrains.skia.impl.NativePointer
...
@@ -7,9 +7,6 @@ import org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skiko.wasm.await
import
org.jetbrains.skiko.wasm.await
import
org.jetbrains.skiko.wasm.wasmSetup
import
org.jetbrains.skiko.wasm.wasmSetup
annotation
class
DoNothing
actual
typealias
IgnoreTestOnJvm
=
DoNothing
actual
fun
runTest
(
block
:
suspend
()
->
Unit
):
dynamic
=
GlobalScope
.
promise
{
actual
fun
runTest
(
block
:
suspend
()
->
Unit
):
dynamic
=
GlobalScope
.
promise
{
wasmSetup
.
await
()
wasmSetup
.
await
()
block
()
block
()
...
@@ -18,3 +15,9 @@ actual fun runTest(block: suspend () -> Unit): dynamic = GlobalScope.promise {
...
@@ -18,3 +15,9 @@ actual fun runTest(block: suspend () -> Unit): dynamic = GlobalScope.promise {
actual
fun
InteropScope
.
allocateBytesForPixels
(
size
:
Int
):
NativePointer
{
actual
fun
InteropScope
.
allocateBytesForPixels
(
size
:
Int
):
NativePointer
{
return
toInterop
(
ByteArray
(
size
))
return
toInterop
(
ByteArray
(
size
))
}
}
actual
typealias
SkipJsTarget
=
kotlin
.
test
.
Ignore
actual
annotation
class
SkipJvmTarget
actual
annotation
class
SkipNativeTarget
\ No newline at end of file
skiko/src/jvmTest/kotlin/TestUtils.jvm.kt
View file @
7d7fa80a
...
@@ -6,8 +6,6 @@ import org.jetbrains.skia.impl.InteropScope
...
@@ -6,8 +6,6 @@ import org.jetbrains.skia.impl.InteropScope
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.NativePointer
import
java.nio.ByteBuffer
import
java.nio.ByteBuffer
actual
typealias
IgnoreTestOnJvm
=
org
.
junit
.
Ignore
actual
fun
runTest
(
block
:
suspend
()
->
Unit
)
{
actual
fun
runTest
(
block
:
suspend
()
->
Unit
)
{
runBlocking
{
block
()
}
runBlocking
{
block
()
}
}
}
...
@@ -15,3 +13,9 @@ actual fun runTest(block: suspend () -> Unit) {
...
@@ -15,3 +13,9 @@ actual fun runTest(block: suspend () -> Unit) {
actual
fun
InteropScope
.
allocateBytesForPixels
(
size
:
Int
):
NativePointer
{
actual
fun
InteropScope
.
allocateBytesForPixels
(
size
:
Int
):
NativePointer
{
return
BufferUtil
.
getPointerFromByteBuffer
(
ByteBuffer
.
allocateDirect
(
size
))
return
BufferUtil
.
getPointerFromByteBuffer
(
ByteBuffer
.
allocateDirect
(
size
))
}
}
actual
annotation
class
SkipJsTarget
actual
typealias
SkipJvmTarget
=
org
.
junit
.
Ignore
actual
annotation
class
SkipNativeTarget
skiko/src/jvmTest/kotlin/org/jetbrains/skiko/PathTest.kt
View file @
7d7fa80a
package
org.jetbrains.skiko
package
org.jetbrains.skiko
import
org.jetbrains.skia.Path
import
org.jetbrains.skia.Path
import
org.jetbrains.skia.PathDirection
import
org.jetbrains.skia.PathFillMode
import
org.jetbrains.skia.PathSegmentMask
import
org.jetbrains.skia.PathSegmentMask
import
org.jetbrains.skia.PathVerb
import
org.jetbrains.skia.PathVerb
import
org.jetbrains.skia.Point
import
org.jetbrains.skia.Point
import
org.jetbrains.skia.RRect
import
org.jetbrains.skia.Rect
import
kotlin.test.Test
import
kotlin.test.Test
import
kotlin.test.assertContentEquals
import
kotlin.test.assertContentEquals
import
kotlin.test.assertEquals
import
kotlin.test.assertEquals
import
kotlin.test.assertFailsWith
import
kotlin.test.assertFalse
import
kotlin.test.assertNotEquals
import
kotlin.test.assertNotEquals
import
kotlin.test.assertNull
import
kotlin.test.assertTrue
class
PathTest
{
class
PathTest
{
@Test
fun
isShapeTest
()
{
for
(
dir
in
PathDirection
.
values
())
{
for
(
start
in
0
..
3
)
{
Path
().
addRect
(
Rect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
),
dir
,
start
).
use
{
p
->
assertEquals
(
Rect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
),
p
.
isRect
)
assertNull
(
p
.
isOval
)
assertNull
(
p
.
isRRect
)
}
}
}
for
(
dir
in
PathDirection
.
values
())
{
for
(
start
in
0
..
3
)
{
Path
().
addOval
(
Rect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
),
dir
,
start
).
use
{
p
->
assertNull
(
p
.
isRect
)
assertEquals
(
Rect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
),
p
.
isOval
)
assertNull
(
p
.
isRRect
)
}
}
}
for
(
dir
in
PathDirection
.
values
())
{
Path
().
addCircle
(
20f
,
20f
,
20f
,
dir
).
use
{
p
->
assertNull
(
p
.
isRect
)
assertEquals
(
Rect
.
makeLTRB
(
0f
,
0f
,
40f
,
40f
),
p
.
isOval
)
assertNull
(
p
.
isRRect
)
}
}
for
(
dir
in
PathDirection
.
values
())
{
for
(
start
in
0
..
7
)
{
Path
().
addRRect
(
RRect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
,
5f
),
dir
,
start
).
use
{
p
->
assertNull
(
p
.
isRect
)
assertNull
(
p
.
isOval
)
assertEquals
(
RRect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
,
5f
),
p
.
isRRect
)
}
Path
().
addRRect
(
RRect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
,
0f
),
dir
,
start
).
use
{
p
->
assertEquals
(
Rect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
),
p
.
isRect
)
assertNull
(
p
.
isOval
)
assertNull
(
p
.
isRRect
)
}
Path
().
addRRect
(
RRect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
,
20f
,
10f
),
dir
,
start
).
use
{
p
->
assertNull
(
p
.
isRect
)
assertEquals
(
Rect
.
makeLTRB
(
0f
,
0f
,
40f
,
20f
),
p
.
isOval
)
assertNull
(
p
.
isRRect
)
}
}
}
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
().
use
{
p
->
assertNull
(
p
.
isRect
)
assertNull
(
p
.
isOval
)
assertNull
(
p
.
isRRect
)
}
}
@Test
fun
checksTest
()
{
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
().
use
{
p
->
assertFalse
(
p
.
isEmpty
)
p
.
reset
()
assertTrue
(
p
.
isEmpty
)
}
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
().
use
{
p
->
assertFalse
(
p
.
isEmpty
)
p
.
rewind
()
assertTrue
(
p
.
isEmpty
)
}
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
use
{
p
->
assertFalse
(
p
.
isLastContourClosed
)
p
.
closePath
()
assertTrue
(
p
.
isLastContourClosed
)
p
.
moveTo
(
100f
,
100f
).
lineTo
(
140f
,
140f
).
lineTo
(
140f
,
100f
).
lineTo
(
100f
,
140f
)
assertFalse
(
p
.
isLastContourClosed
)
p
.
closePath
()
assertTrue
(
p
.
isLastContourClosed
)
}
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
use
{
p
->
assertTrue
(
p
.
isFinite
)
}
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
Float
.
POSITIVE_INFINITY
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
().
use
{
p
->
assertEquals
(
false
,
p
.
isFinite
)
}
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
use
{
p
->
assertFalse
(
p
.
isVolatile
)
p
.
setVolatile
(
true
)
assertTrue
(
p
.
isVolatile
)
p
.
setVolatile
(
false
)
assertFalse
(
p
.
isVolatile
)
}
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
().
use
{
p
->
assertNull
(
p
.
asLine
)
}
Path
().
moveTo
(
20f
,
20f
).
lineTo
(
40f
,
40f
).
use
{
p
->
assertContentEquals
(
arrayOf
(
Point
(
20f
,
20f
),
Point
(
40f
,
40f
)
),
p
.
asLine
)
}
}
@Test
@Test
fun
storageTest
()
{
fun
storageTest
()
{
val
subpath
:
Path
=
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
()
val
subpath
:
Path
=
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
()
...
@@ -197,69 +88,4 @@ class PathTest {
...
@@ -197,69 +88,4 @@ class PathTest {
}
}
}
}
@Test
fun
swapTest
()
{
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
().
use
{
p1
->
Path
().
lineTo
(
0f
,
0f
).
lineTo
(
20f
,
20f
).
use
{
p2
->
p1
.
swap
(
p2
)
assertEquals
(
Path
().
lineTo
(
0f
,
0f
).
lineTo
(
20f
,
20f
),
p1
)
assertEquals
(
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
(),
p2
)
}
}
}
@Test
fun
containsTest
()
{
Path
().
addRRect
(
RRect
.
makeLTRB
(
10f
,
20f
,
54f
,
120f
,
10f
,
20f
)).
use
{
p
->
assertTrue
(
p
.
conservativelyContainsRect
(
Rect
.
makeLTRB
(
10f
,
40f
,
54f
,
80f
)))
assertTrue
(
p
.
conservativelyContainsRect
(
Rect
.
makeLTRB
(
25f
,
20f
,
39f
,
120f
)))
assertTrue
(
p
.
conservativelyContainsRect
(
Rect
.
makeLTRB
(
15f
,
25f
,
49f
,
115f
)))
assertTrue
(
p
.
conservativelyContainsRect
(
Rect
.
makeLTRB
(
13f
,
27f
,
51f
,
113f
)))
assertFalse
(
p
.
conservativelyContainsRect
(
Rect
.
makeLTRB
(
0f
,
40f
,
60f
,
80f
)))
assertTrue
(
p
.
contains
(
30f
,
70f
))
assertFalse
(
p
.
contains
(
0f
,
0f
))
}
}
@Test
fun
utilsTest
()
{
assertFalse
(
Path
.
isLineDegenerate
(
Point
(
0f
,
0f
),
Point
(
10f
,
0f
),
false
))
assertTrue
(
Path
.
isLineDegenerate
(
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
true
))
assertTrue
(
Path
.
isLineDegenerate
(
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
false
))
assertFalse
(
Path
.
isLineDegenerate
(
Point
(
0f
,
0f
),
Point
(
0f
,
1e-13f
),
true
))
assertFalse
(
Path
.
isQuadDegenerate
(
Point
(
0f
,
0f
),
Point
(
10f
,
0f
),
Point
(
0f
,
0f
),
false
))
assertTrue
(
Path
.
isQuadDegenerate
(
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
false
))
assertFalse
(
Path
.
isCubicDegenerate
(
Point
(
0f
,
0f
),
Point
(
10f
,
0f
),
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
false
))
assertTrue
(
Path
.
isCubicDegenerate
(
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
Point
(
0f
,
0f
),
false
))
assertContentEquals
(
arrayOf
(
Point
(
0f
,
20f
),
Point
(
6.666667f
,
13.333334f
)),
Path
.
convertConicToQuads
(
Point
(
0f
,
20f
),
Point
(
20f
,
0f
),
Point
(
40f
,
20f
),
0.5f
,
1
)
)
assertContentEquals
(
arrayOf
(
Point
(
0f
,
20f
),
Point
(
3.0940108f
,
16.905989f
),
Point
(
8.452994f
,
15.119661f
),
Point
(
13.811978f
,
13.333334f
)
),
Path
.
convertConicToQuads
(
Point
(
0f
,
20f
),
Point
(
20f
,
0f
),
Point
(
40f
,
20f
),
0.5f
,
2
)
)
Path
().
lineTo
(
40f
,
40f
).
use
{
p
->
val
g1
=
p
.
generationId
p
.
lineTo
(
10f
,
40f
)
val
g2
=
p
.
generationId
assertNotEquals
(
g1
,
g2
)
p
.
fillMode
=
PathFillMode
.
EVEN_ODD
val
g3
=
p
.
generationId
assertEquals
(
g2
,
g3
)
}
}
@Test
fun
serializeTest
()
{
Path
().
lineTo
(
40f
,
40f
).
lineTo
(
40f
,
0f
).
lineTo
(
0f
,
40f
).
lineTo
(
0f
,
0f
).
closePath
().
use
{
p
->
val
p2
:
Path
=
Path
.
makeFromBytes
(
p
.
serializeToBytes
())
assertEquals
(
p
,
p2
)
}
}
}
}
\ No newline at end of file
skiko/src/nativeTest/kotlin/org/jetbrains/skiko/tests/TestUtils.native.kt
View file @
7d7fa80a
...
@@ -4,9 +4,6 @@ import kotlinx.coroutines.runBlocking
...
@@ -4,9 +4,6 @@ import kotlinx.coroutines.runBlocking
import
org.jetbrains.skia.impl.InteropScope
import
org.jetbrains.skia.impl.InteropScope
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.NativePointer
annotation
class
DoNothing
actual
typealias
IgnoreTestOnJvm
=
DoNothing
actual
fun
runTest
(
block
:
suspend
()
->
Unit
)
{
actual
fun
runTest
(
block
:
suspend
()
->
Unit
)
{
runBlocking
{
block
()
}
runBlocking
{
block
()
}
}
}
...
@@ -14,3 +11,9 @@ actual fun runTest(block: suspend () -> Unit) {
...
@@ -14,3 +11,9 @@ actual fun runTest(block: suspend () -> Unit) {
actual
fun
InteropScope
.
allocateBytesForPixels
(
size
:
Int
):
NativePointer
{
actual
fun
InteropScope
.
allocateBytesForPixels
(
size
:
Int
):
NativePointer
{
return
toInterop
(
ByteArray
(
size
))
return
toInterop
(
ByteArray
(
size
))
}
}
actual
annotation
class
SkipJsTarget
actual
annotation
class
SkipJvmTarget
actual
typealias
SkipNativeTarget
=
kotlin
.
test
.
Ignore
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment