Skip to content

Commit 8cee8cb

Browse files
authored
Added compose tests
Fixes #601 PR #640
1 parent e03bc8c commit 8cee8cb

File tree

29 files changed

+593
-0
lines changed

29 files changed

+593
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package kotlinx.kover.gradle.plugin.test.functional.cases
6+
7+
import kotlinx.kover.gradle.plugin.test.functional.framework.checker.CheckerContext
8+
import kotlinx.kover.gradle.plugin.test.functional.framework.starter.TemplateTest
9+
10+
internal class ComposeTests {
11+
@TemplateTest("android-compose", [":app:koverXmlReportDebug", ":app:koverHtmlReportDebug"])
12+
fun CheckerContext.testCompose() {
13+
subproject("app") {
14+
xmlReport("debug") {
15+
methodCounter("org.jetbrains.composetests.ComposeFunctionsKt", "Simple").assertFullyCovered()
16+
methodCounter("org.jetbrains.composetests.ComposeFunctionsKt", "Simple", "BRANCH").assertFullyCovered()
17+
18+
methodCounter("org.jetbrains.composetests.ComposeFunctionsKt", "WithParam").assertFullyCovered()
19+
methodCounter("org.jetbrains.composetests.ComposeFunctionsKt", "WithParam", "BRANCH").assertFullyCovered()
20+
21+
methodCounter("org.jetbrains.composetests.ComposeFunctionsKt", "WithDefParam").assertFullyCovered()
22+
methodCounter("org.jetbrains.composetests.ComposeFunctionsKt", "WithDefParam", "BRANCH").assertFullyCovered()
23+
}
24+
}
25+
}
26+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
plugins {
6+
alias(libs.plugins.android.application)
7+
alias(libs.plugins.jetbrains.kotlin.android)
8+
id("org.jetbrains.kotlinx.kover")
9+
}
10+
11+
android {
12+
namespace = "org.jetbrains.composetests"
13+
compileSdk = 34
14+
15+
defaultConfig {
16+
applicationId = "org.jetbrains.composetests"
17+
minSdk = 29
18+
targetSdk = 34
19+
versionCode = 1
20+
versionName = "1.0"
21+
22+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
23+
vectorDrawables {
24+
useSupportLibrary = true
25+
}
26+
}
27+
28+
buildTypes {
29+
release {
30+
isMinifyEnabled = false
31+
}
32+
}
33+
compileOptions {
34+
sourceCompatibility = JavaVersion.VERSION_1_8
35+
targetCompatibility = JavaVersion.VERSION_1_8
36+
}
37+
kotlinOptions {
38+
jvmTarget = "1.8"
39+
}
40+
buildFeatures {
41+
compose = true
42+
}
43+
composeOptions {
44+
kotlinCompilerExtensionVersion = "1.5.1"
45+
}
46+
packaging {
47+
resources {
48+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
49+
}
50+
}
51+
52+
testOptions {
53+
unitTests {
54+
isIncludeAndroidResources = true
55+
}
56+
}
57+
}
58+
59+
dependencies {
60+
implementation(libs.androidx.core.ktx)
61+
implementation(libs.androidx.lifecycle.runtime.ktx)
62+
implementation(libs.androidx.activity.compose)
63+
implementation(platform(libs.androidx.compose.bom))
64+
implementation(libs.androidx.ui)
65+
implementation(libs.androidx.ui.graphics)
66+
implementation(libs.androidx.ui.tooling.preview)
67+
implementation(libs.androidx.material3)
68+
testImplementation(libs.junit)
69+
androidTestImplementation(libs.androidx.junit)
70+
androidTestImplementation(libs.androidx.espresso.core)
71+
androidTestImplementation(platform(libs.androidx.compose.bom))
72+
androidTestImplementation(libs.androidx.ui.test.junit4)
73+
debugImplementation(libs.androidx.ui.tooling)
74+
debugImplementation(libs.androidx.ui.test.manifest)
75+
76+
testImplementation(libs.androidx.ui.test.junit4)
77+
testImplementation("org.robolectric:robolectric:4.12.2")
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
4+
-->
5+
6+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
7+
xmlns:tools="http://schemas.android.com/tools">
8+
9+
<application
10+
android:allowBackup="true"
11+
android:dataExtractionRules="@xml/data_extraction_rules"
12+
android:fullBackupContent="@xml/backup_rules"
13+
android:icon="@mipmap/ic_launcher"
14+
android:label="@string/app_name"
15+
android:roundIcon="@mipmap/ic_launcher_round"
16+
android:supportsRtl="true"
17+
android:theme="@style/Theme.ComposeTests"
18+
tools:targetApi="31">
19+
20+
<activity
21+
android:name=".MainActivity"
22+
android:exported="true"
23+
android:label="@string/app_name"
24+
android:theme="@style/Theme.ComposeTests">
25+
<intent-filter>
26+
<action android:name="android.intent.action.MAIN" />
27+
28+
<category android:name="android.intent.category.LAUNCHER" />
29+
</intent-filter>
30+
</activity>
31+
</application>
32+
33+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
package org.jetbrains.composetests
5+
6+
import androidx.compose.runtime.Composable
7+
8+
@Composable
9+
fun Simple() {
10+
println("Hello")
11+
}
12+
13+
@Composable
14+
fun WithParam(name: String) {
15+
println("Hello, " + name)
16+
}
17+
18+
@Composable
19+
fun WithDefParam(name: String = "") {
20+
println("Hello, def " + name)
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package org.jetbrains.composetests
6+
7+
import android.os.Bundle
8+
import androidx.activity.ComponentActivity
9+
10+
class MainActivity : ComponentActivity() {
11+
override fun onCreate(savedInstanceState: Bundle?) {
12+
super.onCreate(savedInstanceState)
13+
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
4+
-->
5+
6+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
7+
android:width="108dp"
8+
android:height="108dp"
9+
android:viewportWidth="108"
10+
android:viewportHeight="108">
11+
<path
12+
android:fillColor="#3DDC84"
13+
android:pathData="M0,0h108v108h-108z" />
14+
<path
15+
android:fillColor="#00000000"
16+
android:pathData="M9,0L9,108"
17+
android:strokeWidth="0.8"
18+
android:strokeColor="#33FFFFFF" />
19+
<path
20+
android:fillColor="#00000000"
21+
android:pathData="M19,0L19,108"
22+
android:strokeWidth="0.8"
23+
android:strokeColor="#33FFFFFF" />
24+
<path
25+
android:fillColor="#00000000"
26+
android:pathData="M29,0L29,108"
27+
android:strokeWidth="0.8"
28+
android:strokeColor="#33FFFFFF" />
29+
<path
30+
android:fillColor="#00000000"
31+
android:pathData="M39,0L39,108"
32+
android:strokeWidth="0.8"
33+
android:strokeColor="#33FFFFFF" />
34+
<path
35+
android:fillColor="#00000000"
36+
android:pathData="M49,0L49,108"
37+
android:strokeWidth="0.8"
38+
android:strokeColor="#33FFFFFF" />
39+
<path
40+
android:fillColor="#00000000"
41+
android:pathData="M59,0L59,108"
42+
android:strokeWidth="0.8"
43+
android:strokeColor="#33FFFFFF" />
44+
<path
45+
android:fillColor="#00000000"
46+
android:pathData="M69,0L69,108"
47+
android:strokeWidth="0.8"
48+
android:strokeColor="#33FFFFFF" />
49+
<path
50+
android:fillColor="#00000000"
51+
android:pathData="M79,0L79,108"
52+
android:strokeWidth="0.8"
53+
android:strokeColor="#33FFFFFF" />
54+
<path
55+
android:fillColor="#00000000"
56+
android:pathData="M89,0L89,108"
57+
android:strokeWidth="0.8"
58+
android:strokeColor="#33FFFFFF" />
59+
<path
60+
android:fillColor="#00000000"
61+
android:pathData="M99,0L99,108"
62+
android:strokeWidth="0.8"
63+
android:strokeColor="#33FFFFFF" />
64+
<path
65+
android:fillColor="#00000000"
66+
android:pathData="M0,9L108,9"
67+
android:strokeWidth="0.8"
68+
android:strokeColor="#33FFFFFF" />
69+
<path
70+
android:fillColor="#00000000"
71+
android:pathData="M0,19L108,19"
72+
android:strokeWidth="0.8"
73+
android:strokeColor="#33FFFFFF" />
74+
<path
75+
android:fillColor="#00000000"
76+
android:pathData="M0,29L108,29"
77+
android:strokeWidth="0.8"
78+
android:strokeColor="#33FFFFFF" />
79+
<path
80+
android:fillColor="#00000000"
81+
android:pathData="M0,39L108,39"
82+
android:strokeWidth="0.8"
83+
android:strokeColor="#33FFFFFF" />
84+
<path
85+
android:fillColor="#00000000"
86+
android:pathData="M0,49L108,49"
87+
android:strokeWidth="0.8"
88+
android:strokeColor="#33FFFFFF" />
89+
<path
90+
android:fillColor="#00000000"
91+
android:pathData="M0,59L108,59"
92+
android:strokeWidth="0.8"
93+
android:strokeColor="#33FFFFFF" />
94+
<path
95+
android:fillColor="#00000000"
96+
android:pathData="M0,69L108,69"
97+
android:strokeWidth="0.8"
98+
android:strokeColor="#33FFFFFF" />
99+
<path
100+
android:fillColor="#00000000"
101+
android:pathData="M0,79L108,79"
102+
android:strokeWidth="0.8"
103+
android:strokeColor="#33FFFFFF" />
104+
<path
105+
android:fillColor="#00000000"
106+
android:pathData="M0,89L108,89"
107+
android:strokeWidth="0.8"
108+
android:strokeColor="#33FFFFFF" />
109+
<path
110+
android:fillColor="#00000000"
111+
android:pathData="M0,99L108,99"
112+
android:strokeWidth="0.8"
113+
android:strokeColor="#33FFFFFF" />
114+
<path
115+
android:fillColor="#00000000"
116+
android:pathData="M19,29L89,29"
117+
android:strokeWidth="0.8"
118+
android:strokeColor="#33FFFFFF" />
119+
<path
120+
android:fillColor="#00000000"
121+
android:pathData="M19,39L89,39"
122+
android:strokeWidth="0.8"
123+
android:strokeColor="#33FFFFFF" />
124+
<path
125+
android:fillColor="#00000000"
126+
android:pathData="M19,49L89,49"
127+
android:strokeWidth="0.8"
128+
android:strokeColor="#33FFFFFF" />
129+
<path
130+
android:fillColor="#00000000"
131+
android:pathData="M19,59L89,59"
132+
android:strokeWidth="0.8"
133+
android:strokeColor="#33FFFFFF" />
134+
<path
135+
android:fillColor="#00000000"
136+
android:pathData="M19,69L89,69"
137+
android:strokeWidth="0.8"
138+
android:strokeColor="#33FFFFFF" />
139+
<path
140+
android:fillColor="#00000000"
141+
android:pathData="M19,79L89,79"
142+
android:strokeWidth="0.8"
143+
android:strokeColor="#33FFFFFF" />
144+
<path
145+
android:fillColor="#00000000"
146+
android:pathData="M29,19L29,89"
147+
android:strokeWidth="0.8"
148+
android:strokeColor="#33FFFFFF" />
149+
<path
150+
android:fillColor="#00000000"
151+
android:pathData="M39,19L39,89"
152+
android:strokeWidth="0.8"
153+
android:strokeColor="#33FFFFFF" />
154+
<path
155+
android:fillColor="#00000000"
156+
android:pathData="M49,19L49,89"
157+
android:strokeWidth="0.8"
158+
android:strokeColor="#33FFFFFF" />
159+
<path
160+
android:fillColor="#00000000"
161+
android:pathData="M59,19L59,89"
162+
android:strokeWidth="0.8"
163+
android:strokeColor="#33FFFFFF" />
164+
<path
165+
android:fillColor="#00000000"
166+
android:pathData="M69,19L69,89"
167+
android:strokeWidth="0.8"
168+
android:strokeColor="#33FFFFFF" />
169+
<path
170+
android:fillColor="#00000000"
171+
android:pathData="M79,19L79,89"
172+
android:strokeWidth="0.8"
173+
android:strokeColor="#33FFFFFF" />
174+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!--
2+
~ Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
-->
4+
5+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
6+
xmlns:aapt="http://schemas.android.com/aapt"
7+
android:width="108dp"
8+
android:height="108dp"
9+
android:viewportWidth="108"
10+
android:viewportHeight="108">
11+
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
12+
<aapt:attr name="android:fillColor">
13+
<gradient
14+
android:endX="85.84757"
15+
android:endY="92.4963"
16+
android:startX="42.9492"
17+
android:startY="49.59793"
18+
android:type="linear">
19+
<item
20+
android:color="#44000000"
21+
android:offset="0.0" />
22+
<item
23+
android:color="#00000000"
24+
android:offset="1.0" />
25+
</gradient>
26+
</aapt:attr>
27+
</path>
28+
<path
29+
android:fillColor="#FFFFFF"
30+
android:fillType="nonZero"
31+
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
32+
android:strokeWidth="1"
33+
android:strokeColor="#00000000" />
34+
</vector>

0 commit comments

Comments
 (0)