Skip to content

Commit

Permalink
implement test-app for instrumentation testing
Browse files Browse the repository at this point in the history
  • Loading branch information
karthyks committed Jan 18, 2023
1 parent 06b2fa4 commit bf3007c
Show file tree
Hide file tree
Showing 50 changed files with 760 additions and 202 deletions.
2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,10 @@ dependencies {
implementation 'androidx.compose.material:material-icons-extended'
implementation 'androidx.compose.material3:material3-window-size-class'

// implementation(project(":composed"))
implementation "io.github.karthyks:composed:0.2.0"
implementation project(":samples")

implementation "androidx.compose.ui:ui-tooling-preview"
implementation 'androidx.compose.material3:material3'
debugImplementation "androidx.compose.ui:ui-tooling"
debugImplementation "androidx.compose.ui:ui-test-manifest"

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4"
}

This file was deleted.

16 changes: 1 addition & 15 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">

<application
android:name=".ComposedApp"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand All @@ -12,21 +13,6 @@
android:supportsRtl="true"
android:theme="@style/Theme.Composed"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Composed">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
</application>

</manifest>
5 changes: 5 additions & 0 deletions app/src/main/java/com/karthyks/composed/ComposedApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.karthyks.composed

import android.app.Application

class ComposedApp : Application()
44 changes: 0 additions & 44 deletions app/src/main/java/com/karthyks/composed/MainActivity.kt

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions app/src/main/java/com/karthyks/composed/usecase/ToastMessage.kt

This file was deleted.

60 changes: 0 additions & 60 deletions app/src/main/java/com/karthyks/composed/views/FullScreenDialog.kt

This file was deleted.

17 changes: 0 additions & 17 deletions app/src/test/java/com/karthyks/composed/ExampleUnitTest.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package io.github.karthyks.composed
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import kotlin.reflect.KProperty

internal class ComposeDelegate(
Expand All @@ -11,7 +13,7 @@ internal class ComposeDelegate(
lateinit var viewHolder: ViewHolder
private val composeWrapper: @Composable () -> Unit = {
// Do animations or other stuffs here.
Box {
Box(modifier = Modifier.testTag(OVERLAY_TEST_TAG)) {
val provider = LocalOverlayProvider.current
val disposable = remember {
DisposableViewHolder { provider.remove(viewHolder) }
Expand All @@ -25,3 +27,5 @@ internal class ComposeDelegate(
return composeWrapper
}
}

const val OVERLAY_TEST_TAG = "composed-overlay"
1 change: 1 addition & 0 deletions samples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
64 changes: 64 additions & 0 deletions samples/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'com.karthyks.composed.samples'
compileSdk 33

defaultConfig {
minSdk 21
targetSdk 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.3.2'
}
}

dependencies {

def composeBom = platform("androidx.compose:compose-bom:$compose_bom_version")
implementation composeBom
androidTestImplementation composeBom

implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.activity:activity-compose:1.6.1'

implementation "androidx.compose.ui:ui"
implementation "androidx.compose.foundation:foundation"
implementation 'androidx.compose.material:material-icons-core'
implementation 'androidx.compose.material:material-icons-extended'
implementation 'androidx.compose.material3:material3-window-size-class'

implementation "androidx.compose.ui:ui-tooling-preview"
implementation 'androidx.compose.material3:material3'
debugImplementation "androidx.compose.ui:ui-tooling"
debugImplementation "androidx.compose.ui:ui-test-manifest"

implementation(project(":composed"))

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
21 changes: 21 additions & 0 deletions samples/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
19 changes: 19 additions & 0 deletions samples/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<activity
android:name=".SampleActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
</application>
</manifest>
Loading

0 comments on commit bf3007c

Please sign in to comment.