Skip to content

Commit 0dbc423

Browse files
committed
tests: use a buildable sample project to test configuration cache support
1 parent 2fef427 commit 0dbc423

40 files changed

Lines changed: 927 additions & 6 deletions

File tree

shared/src/main/java/com/itsaky/androidide/utils/FileProvider.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,16 @@ class FileProvider {
6565
private fun testingDir() = projectRoot().resolve("testing")
6666

6767
@JvmStatic
68-
private fun testReourcessDir(): Path = testingDir().resolve("resources")
68+
private fun testResourcesDir(): Path = testingDir().resolve("resources")
6969

7070
@JvmStatic
71-
fun testHomeDir(): Path = testReourcessDir().resolve("test-home")
71+
fun testHomeDir(): Path = testResourcesDir().resolve("test-home")
7272

7373
@JvmStatic
74-
fun testProjectRoot(): Path = testReourcessDir().resolve("test-project")
74+
fun testProjectRoot(): Path = testResourcesDir().resolve("test-project")
75+
76+
@JvmStatic
77+
fun sampleProjectRoot(): Path = testResourcesDir().resolve("sample-project")
7578

7679
/**
7780
* Get the path to the 'resources' directory.

subprojects/tooling-api-impl/src/main/java/com/itsaky/androidide/tooling/impl/ToolingApiServerImpl.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ import java.util.concurrent.CompletableFuture
6464
import java.util.concurrent.CompletionException
6565
import java.util.concurrent.locks.ReentrantLock
6666
import kotlin.concurrent.withLock
67-
import kotlin.system.exitProcess
6867

6968
/**
7069
* Implementation for the Gradle Tooling API server.

subprojects/tooling-api-impl/src/test/java/com/itsaky/androidide/tooling/impl/MultiModuleAndroidProjectTest.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ class MultiModuleAndroidProjectTest {
9393
}
9494
}
9595

96-
ToolingApiTestLauncher.launchServer(client = client) {
96+
ToolingApiTestLauncher.launchServer(
97+
projectDir = FileProvider.sampleProjectRoot(),
98+
client = client
99+
) {
97100
assertThat(server).isNotNull()
98101
assertThat(project).isNotNull()
99102
assertThat(result?.isSuccessful).isTrue()
@@ -103,7 +106,8 @@ class MultiModuleAndroidProjectTest {
103106
taskPaths.clear()
104107

105108
val (isSuccessful, failure) = server.executeTasks(
106-
TaskExecutionMessage(tasks = listOf("assembleDebug"))).get()
109+
TaskExecutionMessage(tasks = listOf("assembleDebug"))
110+
).get()
107111

108112
if (failure != null) {
109113
println("Failure: $failure")

testing/resources/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Test resources
2+
3+
This directory contains resources for unit tests related to the tooling API server, the projects API and LSP modules.
4+
5+
- `test-project`: A basic project used for testing almost everything related to the tooling API
6+
(multi-module support, build cancellations, dependency & task resolutions, model builders, etc.).
7+
This project is not buildable i.e. running `assembleDebug` in this project will fail.
8+
- `sample-project`: A basic project which can be built, used in some rare cases (like testing configuration cache support).
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Built application files
2+
*.apk
3+
*.aar
4+
*.ap_
5+
*.aab
6+
7+
# Files for the ART/Dalvik VM
8+
*.dex
9+
10+
# Java class files
11+
*.class
12+
13+
# Generated files
14+
/bin/
15+
/gen/
16+
/out/
17+
# Uncomment the following line in case you need and you don't have the release build type files in your app
18+
# Gradle files
19+
.gradle/
20+
/build/
21+
22+
# Local configuration file (sdk path, etc)
23+
local.properties
24+
25+
# Proguard folder generated by Eclipse
26+
proguard/
27+
28+
# Log Files
29+
*.log
30+
31+
# Android Studio Navigation editor temp files
32+
.navigation/
33+
34+
# Android Studio captures folder
35+
captures/
36+
37+
# IntelliJ
38+
*.iml
39+
.idea/workspace.xml
40+
.idea/tasks.xml
41+
.idea/gradle.xml
42+
.idea/assetWizardSettings.xml
43+
.idea/dictionaries
44+
.idea/libraries
45+
# Android Studio 3 in .gitignore file.
46+
.idea/caches
47+
.idea/modules.xml
48+
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
49+
.idea/navEditor.xml
50+
51+
# Keystore files
52+
# Uncomment the following lines if you do not want to check your keystore files in.
53+
#*.jks
54+
#*.keystore
55+
56+
# External native build folder generated in Android Studio 2.2 and later
57+
.externalNativeBuild
58+
.cxx/
59+
60+
# Google Services (e.g. APIs or Firebase)
61+
# google-services.json
62+
63+
# Freeline
64+
freeline.py
65+
freeline/
66+
freeline_project_description.json
67+
68+
# fastlane
69+
fastlane/report.xml
70+
fastlane/Preview.html
71+
fastlane/screenshots
72+
fastlane/test_output
73+
fastlane/readme.md
74+
75+
# Version control
76+
vcs.xml
77+
78+
# lint
79+
lint/intermediates/
80+
lint/generated/
81+
lint/outputs/
82+
lint/tmp/
83+
# lint/reports/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
plugins {
3+
id("com.android.application")
4+
5+
}
6+
7+
android {
8+
namespace = "com.itsaky.androidide.template.Java.kts"
9+
compileSdk = 33
10+
11+
defaultConfig {
12+
applicationId = "com.itsaky.androidide.template.Java.kts"
13+
minSdk = 21
14+
targetSdk = 33
15+
versionCode = 1
16+
versionName = "1.0"
17+
18+
vectorDrawables {
19+
useSupportLibrary = true
20+
}
21+
}
22+
23+
compileOptions {
24+
sourceCompatibility = JavaVersion.VERSION_11
25+
targetCompatibility = JavaVersion.VERSION_11
26+
}
27+
28+
buildTypes {
29+
release {
30+
isMinifyEnabled = true
31+
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
32+
}
33+
}
34+
35+
buildFeatures {
36+
viewBinding = true
37+
38+
}
39+
40+
}
41+
42+
dependencies {
43+
44+
45+
implementation("androidx.appcompat:appcompat:1.6.1")
46+
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
47+
implementation("com.google.android.material:material:1.9.0")
48+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<manifest
4+
xmlns:android="http://schemas.android.com/apk/res/android">
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:roundIcon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme"
12+
android:dataExtractionRules="@xml/data_extraction_rules"
13+
android:fullBackupContent="@xml/backup_rules">
14+
<activity
15+
android:name="MainActivity"
16+
android:exported="true">
17+
<intent-filter>
18+
<action
19+
android:name="android.intent.action.MAIN" />
20+
<category
21+
android:name="android.intent.category.LAUNCHER" />
22+
</intent-filter>
23+
</activity>
24+
</application>
25+
</manifest>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.itsaky.androidide.template.Java.kts;
2+
3+
import android.os.Bundle;
4+
import android.widget.Toast;
5+
import androidx.appcompat.app.AppCompatActivity;
6+
import com.itsaky.androidide.template.Java.kts.databinding.ActivityMainBinding;
7+
8+
public class MainActivity extends AppCompatActivity {
9+
10+
private ActivityMainBinding binding;
11+
12+
@Override
13+
protected void onCreate(Bundle savedInstanceState) {
14+
super.onCreate(savedInstanceState);
15+
binding = ActivityMainBinding.inflate(getLayoutInflater());
16+
setContentView(binding.getRoot());
17+
18+
setSupportActionBar(binding.toolbar);
19+
20+
binding.fab.setOnClickListener(v ->
21+
Toast.makeText(MainActivity.this, "Replace with your action", Toast.LENGTH_SHORT).show()
22+
);
23+
}
24+
25+
@Override
26+
protected void onDestroy() {
27+
super.onDestroy();
28+
this.binding = null;
29+
}
30+
}

0 commit comments

Comments
 (0)