-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: provide integration test projects
- Loading branch information
Showing
32 changed files
with
591 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
*.iml | ||
.gradle | ||
.idea | ||
local.properties | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
plugins { | ||
id 'version-catalog' | ||
} | ||
|
||
catalog.versionCatalog { | ||
it.version 'astring', version | ||
} | ||
|
||
final module = project | ||
rootProject.allprojects { | ||
if (project != module) pluginManager.withPlugin('maven-publish') { | ||
module.catalog.versionCatalog { | ||
final name = project.name | ||
final alias = name == 'astring' ? name : "astring-$name" | ||
it.library(alias, group, name).versionRef 'astring' | ||
} | ||
} | ||
} | ||
|
||
tasks.register('updateCatalog', Copy) { | ||
into projectDir | ||
include 'libs.versions.toml' | ||
from tasks.named('generateCatalogAsToml') | ||
rename 'libs.versions.toml', 'versions.toml' | ||
filter { it.startsWith('#') ? null : it } | ||
outputs.upToDateWhen { false } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[metadata] | ||
format.version = "1.1" | ||
|
||
[versions] | ||
astring = "unspecified" | ||
|
||
[libraries] | ||
astring = {group = "xyz.tynn.astring", name = "astring", version.ref = "astring" } | ||
astring-appcompat = {group = "xyz.tynn.astring", name = "appcompat", version.ref = "astring" } | ||
astring-binding = {group = "xyz.tynn.astring", name = "binding", version.ref = "astring" } | ||
astring-bom = {group = "xyz.tynn.astring", name = "bom", version.ref = "astring" } | ||
astring-compose = {group = "xyz.tynn.astring", name = "compose", version.ref = "astring" } | ||
astring-core = {group = "xyz.tynn.astring", name = "core", version.ref = "astring" } | ||
astring-material = {group = "xyz.tynn.astring", name = "material", version.ref = "astring" } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
plugins { | ||
alias libs.plugins.android | ||
id 'integration-test' | ||
id 'nexus-publish' | ||
} | ||
|
||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
['check', 'connectedCheck'].each { | ||
tasks.named(it) { task -> | ||
final path = ":${project.name}:${task.name}" | ||
dependsOn gradle.includedBuild('integration').task(path) | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
plugins { | ||
alias libs.plugins.android.app | ||
} | ||
|
||
android { | ||
buildFeatures { | ||
dataBinding true | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation buildLibs.astring.core | ||
implementation buildLibs.astring.binding | ||
|
||
androidTestImplementation libs.bundles.testing.android | ||
} |
47 changes: 47 additions & 0 deletions
47
...inding/src/androidTest/java/xyz/tynn/astring/integration/binding/BindingActivityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2024 Christian Schmitz | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package xyz.tynn.astring.integration.binding; | ||
|
||
import static androidx.test.espresso.Espresso.onView; | ||
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; | ||
import static androidx.test.espresso.action.ViewActions.replaceText; | ||
import static androidx.test.espresso.assertion.ViewAssertions.matches; | ||
import static androidx.test.espresso.matcher.ViewMatchers.withId; | ||
import static androidx.test.espresso.matcher.ViewMatchers.withText; | ||
|
||
import androidx.test.ext.junit.rules.ActivityScenarioRule; | ||
import androidx.test.filters.SmallTest; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
@SmallTest | ||
public class BindingActivityTest { | ||
|
||
@Rule | ||
public final ActivityScenarioRule<BindingActivity> activityRule = | ||
new ActivityScenarioRule<>(BindingActivity.class); | ||
|
||
@Test | ||
public void bindingActivityTest() { | ||
onView(withId(R.id.astring_binding_converter)) | ||
.perform(replaceText("AString"), | ||
closeSoftKeyboard()); | ||
|
||
onView(withId(R.id.astring_binding_string)) | ||
.check(matches(withText("AString"))); | ||
|
||
onView(withId(R.id.astring_binding_adapter)) | ||
.check(matches(withText("AString"))); | ||
|
||
onView(withId(R.id.astring_binding_converter)) | ||
.perform(replaceText("")); | ||
|
||
onView(withId(R.id.astring_binding_string)) | ||
.check(matches(withText(""))); | ||
|
||
onView(withId(R.id.astring_binding_adapter)) | ||
.check(matches(withText(""))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<application | ||
android:label="AString Binding" | ||
tools:ignore="MissingApplicationIcon"> | ||
|
||
<activity | ||
android:name=".BindingActivity" | ||
android:exported="true"> | ||
|
||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
</manifest> |
43 changes: 43 additions & 0 deletions
43
integration/binding/src/main/java/xyz/tynn/astring/integration/binding/BindingActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2024 Christian Schmitz | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package xyz.tynn.astring.integration.binding; | ||
|
||
import static android.util.Log.d; | ||
import static xyz.tynn.astring.AStringKt.invokeWithContext; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
|
||
import androidx.annotation.Nullable; | ||
import androidx.databinding.DataBindingUtil; | ||
import androidx.databinding.Observable; | ||
import androidx.databinding.Observable.OnPropertyChangedCallback; | ||
import androidx.databinding.ObservableField; | ||
|
||
import java.util.Objects; | ||
|
||
import xyz.tynn.astring.AString; | ||
import xyz.tynn.astring.integration.binding.databinding.ActivityBindingBinding; | ||
|
||
public class BindingActivity extends Activity { | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
ActivityBindingBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_binding); | ||
ObservableField<AString> field = new ObservableField<>(AString.Null); | ||
field.addOnPropertyChangedCallback(new OnPropertyChangedCallback() { | ||
@Override | ||
public void onPropertyChanged(Observable sender, int propertyId) { | ||
log(field.get()); | ||
} | ||
}); | ||
binding.setData(new BindingData(field)); | ||
} | ||
|
||
private void log(AString aString) { | ||
CharSequence string = invokeWithContext(this, aString); | ||
d("BindingActivity", Objects.toString(string)); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
integration/binding/src/main/java/xyz/tynn/astring/integration/binding/BindingData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2024 Christian Schmitz | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package xyz.tynn.astring.integration.binding; | ||
|
||
import androidx.databinding.ObservableField; | ||
|
||
import xyz.tynn.astring.AString; | ||
|
||
public class BindingData { | ||
|
||
private final ObservableField<AString> aString; | ||
|
||
BindingData(ObservableField<AString> aString) { | ||
this.aString = aString; | ||
} | ||
|
||
public ObservableField<AString> getAString() { | ||
return aString; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
integration/binding/src/main/res/layout/activity_binding.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<data> | ||
|
||
<import type="xyz.tynn.astring.binding.AStringBinding" /> | ||
|
||
<variable | ||
name="data" | ||
type="xyz.tynn.astring.integration.binding.BindingData" /> | ||
</data> | ||
|
||
<LinearLayout xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
tools:context=".BindingActivity"> | ||
|
||
<TextView | ||
android:id="@+id/astring_binding_string" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@{data.aString.invoke(context)}" /> | ||
|
||
<TextView | ||
android:id="@+id/astring_binding_adapter" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@{data.aString}" /> | ||
|
||
<EditText | ||
android:id="@+id/astring_binding_converter" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:importantForAutofill="no" | ||
android:inputType="text" | ||
android:text="@={AStringBinding.load(context, data.aString)}" | ||
tools:ignore="LabelFor" /> | ||
</LinearLayout> | ||
</layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
plugins { | ||
alias libs.plugins.android.app apply false | ||
alias libs.plugins.kotlin apply false | ||
alias libs.plugins.paparazzi apply false | ||
alias libs.plugins.conventions | ||
} | ||
|
||
allprojects { | ||
group = 'xyz.tynn.astring.integration' | ||
} | ||
|
||
subprojects { | ||
pluginManager.withPlugin(libs.plugins.android.app.get().pluginId) { | ||
java.toolchain.languageVersion.set JavaLanguageVersion.of(17) | ||
dependencies { api platform(libs.kotlin.bom) } | ||
android.defaultConfig.minSdk 21 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
plugins { | ||
alias libs.plugins.android.app | ||
alias libs.plugins.kotlin | ||
alias libs.plugins.paparazzi | ||
} | ||
|
||
android { | ||
buildFeatures { | ||
compose true | ||
} | ||
|
||
composeOptions { | ||
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get() | ||
} | ||
|
||
kotlinOptions { | ||
freeCompilerArgs += [ | ||
'-P', 'plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=' + | ||
libs.versions.kotlin.get() | ||
] | ||
} | ||
} | ||
|
||
tasks.named('check') { | ||
dependsOn tasks.named('verifyPaparazzi') | ||
} | ||
|
||
dependencies { | ||
implementation buildLibs.astring.core | ||
implementation buildLibs.astring.compose | ||
implementation libs.androidx.appcompat | ||
|
||
implementation libs.bundles.compose | ||
debugImplementation libs.androidx.compose.ui.tooling | ||
|
||
androidTestImplementation platform(libs.androidx.compose.bom) | ||
androidTestImplementation libs.androidx.compose.ui.test | ||
androidTestImplementation libs.bundles.testing.android | ||
} |
Oops, something went wrong.