Skip to content

Commit

Permalink
ISSUE-405: create one more test
Browse files Browse the repository at this point in the history
  • Loading branch information
OvsyannikovMaksim committed Mar 4, 2024
1 parent 72989bc commit 308e731
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 9 deletions.
Binary file modified artifacts/page-object-code-gen.jar
Binary file not shown.
Binary file not shown.
6 changes: 0 additions & 6 deletions page-object-code-gen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,4 @@ tasks.withType<Jar>() {
}
exclude("NOTICE.txt")
exclude("LICENSE.txt")
doLast {
copy {
from("build/libs/page-object-code-gen.jar")
into("Kaspresso/artifacts")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ enum class ViewType(val androidName: String) {
},
RecyclerView("androidx.recyclerview.widget.RecyclerView") {
override fun getClass(): List<String> {
return listOf("import ${KRecyclerItem::class.qualifiedName}", "import i${KRecyclerView::class.qualifiedName}")
return listOf("import ${KRecyclerItem::class.qualifiedName}", "import ${KRecyclerView::class.qualifiedName}")
}
}, ;
abstract fun getClass(): List<String>
companion object {
val collectableElements = ViewType.values().map { it.androidName }.filter { it !in elementsWithChild }
val elementsWithChild = listOf(RecyclerView.androidName)
val collectableElements = ViewType.values().map { it.androidName }.filter { it !in elementsWithChild }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CodeGenTest(

@Test
fun checkCodeGen() {
val jarFile = File("/Users/ovsyannikov_m/AndroidStudioProjects/Kaspresso/artifacts/page-object-code-gen.jar")
val jarFile = File("build/libs/page-object-code-gen.jar")
val inputFile = File("src/test/resources/$inputPath")
Runtime.getRuntime().exec("java -jar $jarFile $inputFile $className $outputDirectory")
Thread.sleep(15000)
Expand All @@ -33,6 +33,7 @@ class CodeGenTest(
arrayOf("source1.xml", "build/generated/res/com/kaspresso/components/pageobjectcodegen", "TestClass1", "Result1"),
arrayOf("source_recycler_view.xml", "build/generated/res/com/kaspresso/components/pageobjectcodegen", "RecyclerView", "ResultRecyclerView"),
arrayOf("source2.xml", "build/generated/res/com/kaspresso/components/pageobjectcodegen", "TestClass2", "Result2"),
arrayOf("source3.xml", "build/generated/res/com/kaspresso/components/pageobjectcodegen", "TestClass3", "Result3"),
)
}
}
Expand Down
23 changes: 23 additions & 0 deletions page-object-code-gen/src/test/resources/Result3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.kaspresso.components.pageobjectcodegen

import com.kms.free.R
import com.screens.common.KScreen
import io.github.kakaocup.kakao.edit.KEditText
import io.github.kakaocup.kakao.text.KButton
import io.github.kakaocup.kakao.text.KTextView

object TestClass3 : KScreen<TestClass3>() {

override val layoutId: Int? = TODO("Need To Implement")
override val viewClass: Class<*>? = TODO("Need To Implement")

val title = KTextView { withId(R.id.title) }
val subtitle = KTextView { withId(R.id.subtitle) }
val addFromContacts = KTextView { withId(R.id.add_from_contacts) }
val phoneNumberEditText = KEditText { withId(R.id.phone_number_edit_text) }
val checkForLeaks = KButton { withId(R.id.check_for_leaks) }

override fun BaseTestContext.waitForScreen() {
TODO("Need To Implement")
}
}
39 changes: 39 additions & 0 deletions page-object-code-gen/src/test/resources/source3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<hierarchy rotation="0">
<node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1080,2103]">
<node index="0" text="" resource-id="" class="android.widget.LinearLayout" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1080,2103]">
<node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,112][1080,2103]">
<node index="0" text="" resource-id="com.kms.free:id/action_bar_root" class="android.widget.LinearLayout" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,112][1080,2103]">
<node index="0" text="" resource-id="android:id/content" class="android.widget.FrameLayout" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,112][1080,2103]">
<node index="0" text="" resource-id="com.kms.free:id/fragment_container_view" class="android.widget.FrameLayout" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,112][1080,2103]">
<node index="0" text="" resource-id="com.kms.free:id/fragment_container_view" class="android.widget.FrameLayout" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,112][1080,2103]">
<node index="0" text="" resource-id="com.kms.free:id/root" class="android.view.ViewGroup" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,112][1080,2103]">
<node index="0" text="" resource-id="com.kms.free:id/toolbar" class="android.view.ViewGroup" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,112][1080,259]">
<node NAF="true" index="0" text="" resource-id="" class="android.widget.ImageButton" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,112][147,259]" /></node>
<node index="1" text="" resource-id="com.kms.free:id/scroll" class="android.widget.ScrollView" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,259][1080,2103]">
<node index="0" text="" resource-id="" class="android.view.ViewGroup" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,259][1080,2103]">
<node index="0" text="Add a number to check" resource-id="com.kms.free:id/title" class="android.widget.TextView" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[63,322][1017,427]" />
<node index="1" text="Make sure your number starts with a country code and includes at least 6 digits.&#10;We will automatically check all your accounts for leaks." resource-id="com.kms.free:id/subtitle" class="android.widget.TextView" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[63,448][1017,717]" />
<node index="2" text="" resource-id="com.kms.free:id/input_layout" class="android.widget.LinearLayout" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[63,1121][1017,1581]">
<node index="0" text="Choose from Contacts" resource-id="com.kms.free:id/add_from_contacts" class="android.widget.TextView" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[267,1121][812,1267]" />
<node index="1" text="" resource-id="" class="android.widget.LinearLayout" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[63,1309][1017,1371]">
<node index="0" text="" resource-id="" class="android.view.View" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[63,1338][455,1341]" />
<node index="1" text="or" resource-id="" class="android.widget.TextView" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[487,1309][593,1371]" />
<node index="2" text="" resource-id="" class="android.view.View" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[625,1338][1017,1341]" /></node>
<node index="2" text="" resource-id="com.kms.free:id/phone_number_input" class="android.widget.LinearLayout" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[63,1413][1017,1581]">
<node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[63,1429][1017,1581]">
<node index="0" text="Enter phone number" resource-id="com.kms.free:id/phone_number_edit_text" class="android.widget.EditText" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="true" password="false" selected="false" bounds="[63,1429][1017,1581]" /></node>
</node>
</node>
<node index="3" text="Add number" resource-id="com.kms.free:id/check_for_leaks" class="android.widget.Button" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="true" enabled="false" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[63,1985][1017,2103]" /></node>
</node>
</node>
</node>
</node>
</node>
</node>
</node>
</node>
<node index="1" text="" resource-id="android:id/statusBarBackground" class="android.view.View" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1080,112]" />
<node index="2" text="" resource-id="android:id/navigationBarBackground" class="android.view.View" package="com.kms.free" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][0,0]" /></node>
</hierarchy>

0 comments on commit 308e731

Please sign in to comment.