add android properties box tests

This commit is contained in:
Mikhail Mutcianko
2014-08-27 15:45:29 +04:00
committed by Yan Zhulanow
parent f2ab424c41
commit 08245ffe1c
17 changed files with 326 additions and 82 deletions
@@ -0,0 +1,8 @@
package android.app
import android.view.View
import android.content.Context
abstract class Activity: Context {
abstract fun findViewById(id: Int): View?
}
@@ -0,0 +1,3 @@
package android.content
trait Context
@@ -0,0 +1,5 @@
package android.view
import android.content.Context
open class View(ctx: Context)
@@ -0,0 +1,11 @@
package android.widget
import android.view.View
import android.content.Context
open class Button(ctx: Context): View(ctx) {override fun toString() = "Button"}
open class EditText(ctx: Context): View(ctx) {override fun toString() = "EditText"}
open class TextView(ctx: Context): View(ctx) {override fun toString() = "TextView"}
open class FrameLayout(ctx: Context): View(ctx) {override fun toString() = "FrameLayout"}
open class RelativeLayout(ctx: Context): View(ctx) {override fun toString() = "RelativeLayout"}
open class ImageView(ctx: Context): View(ctx) {override fun toString() = "ImageView"}
@@ -0,0 +1,33 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
import org.my.cool.MyButton
class R {
class id {
class object {
val login = 5
}
}
}
class MyActivity(): Activity() {
val buttonWidget = MyButton(this)
override fun findViewById(id: Int): View? {
return when (id) {
R.id.login -> buttonWidget
else -> null
}
}
public fun box(): String {
return if (login.toString() == "MyButton") "OK" else ""
}
}
fun box(): String {
return MyActivity().box()
}
@@ -4,5 +4,5 @@ import android.widget.Button
import android.app.Activity
class MyButton(ctx: Activity): Button(ctx) {
override fun toString(): String {return "Button"}
override fun toString(): String {return "MyButton"}
}
@@ -0,0 +1,33 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
import org.my.cool.MyButton
class R {
class id {
class object {
val login = 5
}
}
}
class MyActivity(): Activity() {
val buttonWidget = MyButton(this)
override fun findViewById(id: Int): View? {
return when (id) {
R.id.login -> buttonWidget
else -> null
}
}
public fun box(): String {
return if (login.toString() == "MyButton") "OK" else ""
}
}
fun box(): String {
return MyActivity().box()
}
@@ -14,7 +14,7 @@ class R {
}
class MyActivity(): Activity() {
val buttonWidget = Button(this)
val buttonWidget = MyButton(this)
override fun findViewById(id: Int): View? {
return when (id) {
@@ -4,5 +4,5 @@ import android.widget.Button
import android.content.Context
class MyButton(ctx: Context): Button(ctx) {
override fun toString(): String {return "Button"}
override fun toString(): String {return "MyButton"}
}
@@ -0,0 +1,57 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
class R {
class id {
class object {
val item_detail_container = 0
val textView1 = 1
val password = 2
val textView2 = 3
val passwordConfirmation = 4
val login = 5
val passwordField = 6
val passwordCaption = 7
val loginButton = 8
}
}
}
class MyActivity(): Activity() {
val textViewWidget = TextView(this)
val editTextWidget = EditText(this)
val buttonWidget = Button(this)
val textViewWidget2 = TextView(this)
val editTextWidget2 = EditText(this)
val buttonWidget2 = Button(this)
override fun findViewById(id: Int): View? {
return when (id) {
R.id.textView1 -> textViewWidget
R.id.password -> editTextWidget
R.id.login -> buttonWidget
R.id.passwordField -> textViewWidget2
R.id.passwordCaption -> editTextWidget2
R.id.loginButton -> buttonWidget2
else -> null
}
}
public fun box(): String{
return if (textView1.toString() == "TextView" &&
password.toString() == "EditText" &&
login.toString() == "Button" &&
passwordField.toString() == "TextView" &&
passwordCaption.toString() == "EditText" &&
loginButton.toString() == "Button")
"OK" else ""
}
}
fun box(): String {
return MyActivity().box()
}
@@ -0,0 +1,44 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
class R {
class id {
class object {
val item_detail_container = 0
val textView1 = 1
val password = 2
val textView2 = 3
val passwordConfirmation = 4
val login = 5
}
}
}
class MyActivity(): Activity() {
val textViewWidget = TextView(this)
val editTextWidget = EditText(this)
val buttonWidget = Button(this)
override fun findViewById(id: Int): View? {
return when (id) {
R.id.textView1 -> textViewWidget
R.id.password -> editTextWidget
R.id.login -> buttonWidget
else -> null
}
}
public fun box(): String{
return if (textView1.toString() == "TextView" &&
password.toString() == "EditText" &&
login.toString() == "Button")
"OK" else ""
}
}
fun box(): String {
return MyActivity().box()
}