Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgraham committed Jan 21, 2019
1 parent e1bbea5 commit c62c122
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 41 deletions.
5 changes: 3 additions & 2 deletions espresso-server/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
ext.kotlin_version = '1.3.11'
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
Expand All @@ -16,7 +15,9 @@ android {

buildTypes {
release {
minifyEnabled true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
package io.appium.espressoserver.test.model

import androidx.test.espresso.action.GeneralLocation
import androidx.test.espresso.action.GeneralLocation.TOP_RIGHT
import androidx.test.espresso.action.GeneralLocation.VISIBLE_CENTER
import androidx.test.espresso.action.Press
import androidx.test.espresso.action.Press.*
import androidx.test.espresso.action.Tap
import androidx.test.espresso.action.Tap.DOUBLE
import androidx.test.espresso.action.Tap.SINGLE
import com.google.gson.JsonObject
import com.google.gson.JsonPrimitive
import io.appium.espressoserver.lib.model.MobileClickActionParams
import io.appium.espressoserver.lib.model.MobileSwipeParams
import org.junit.Test
import kotlin.test.assertEquals

class MobileClickTest {
class `mobile clickAction test` {

@Test
fun shouldParseMobileClickParamsAndSetDefaults () {
fun `should parse "MobileClickParams" and set defaults if some params not provided` () {
val jsonElement = JsonObject()
val clickActionParams = MobileClickActionParams.MobileClickActionParamsDeserializer()
.deserialize(jsonElement, null, null)
Expand All @@ -29,7 +26,7 @@ class MobileClickTest {
}

@Test
fun shouldParseMobileClickParams () {
fun `should parse "MobileClickParams" and set values if all params provided` () {
val jsonElement = JsonObject()
jsonElement.add("inputDevice", JsonPrimitive(2))
jsonElement.add("buttonState", JsonPrimitive("3"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
package io.appium.espressoserver.test.model

import androidx.test.espresso.action.GeneralLocation
import androidx.test.espresso.action.GeneralLocation.*
import androidx.test.espresso.action.Press
import androidx.test.espresso.action.Press.PINPOINT
import androidx.test.espresso.action.Press.THUMB
import androidx.test.espresso.action.Swipe
import androidx.test.espresso.action.Swipe.FAST
import com.google.gson.JsonElement
import com.google.gson.JsonObject
import com.google.gson.JsonParseException
import com.google.gson.JsonPrimitive
import io.appium.espressoserver.lib.model.MobileSwipeParams
import io.appium.espressoserver.lib.model.MobileSwipeParams.Direction.DOWN
import io.appium.espressoserver.lib.model.MobileSwipeParams.MobileSwipeActionParamsDeserializer
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue

class MobileSwipeTest {
class `mobile swipe test` {

@Test
fun shouldParseMobileSwipeParamsWithDirection () {
fun `should parse "MobileSwipeActionParams" with 'direction' property` () {
val jsonElement = JsonObject()
jsonElement.add("direction", JsonPrimitive("DOWN"))
val mobileSwipeActionParams = MobileSwipeActionParamsDeserializer()
Expand All @@ -30,7 +24,7 @@ class MobileSwipeTest {
}

@Test
fun shouldParseMobileSwipeParamsWithSwiper () {
fun `should parse "MobileSwipeActionParams" with 'swiper' property and use default parameters` () {
val jsonElement = JsonObject()
jsonElement.add("swiper", JsonPrimitive("FAST"))
val mobileSwipeActionParams = MobileSwipeActionParamsDeserializer()
Expand All @@ -42,7 +36,7 @@ class MobileSwipeTest {
}

@Test
fun shouldParseMobileSwipeParamsWithSwiperAndSetParams () {
fun `should parse "MobileSwipeActionParams" with 'swiper' property plus other parameters` () {
val jsonElement = JsonObject()
jsonElement.add("swiper", JsonPrimitive("FAST"))
jsonElement.add("startCoordinates", JsonPrimitive("TOP_LEFT"))
Expand All @@ -56,29 +50,19 @@ class MobileSwipeTest {
assertEquals(mobileSwipeActionParams.precisionDescriber, PINPOINT);
}

@Test
fun shouldRejectIfDirectionAndSwiperProvided () {
try {
val jsonElement = JsonObject()
jsonElement.add("swiper", JsonPrimitive("FAST"))
jsonElement.add("direction", JsonPrimitive("DOWN"))
MobileSwipeActionParamsDeserializer()
.deserialize(jsonElement, null, null)
} catch (jpe:JsonParseException) {
return assertTrue(true);
}
assertTrue(false);
@Test(expected = JsonParseException::class)
fun `should reject if both 'direction' and 'swiper' provided`() {
val jsonElement = JsonObject()
jsonElement.add("swiper", JsonPrimitive("FAST"))
jsonElement.add("direction", JsonPrimitive("DOWN"))
MobileSwipeActionParamsDeserializer()
.deserialize(jsonElement, null, null)
}

@Test
fun shouldRejectIfNotDirectionOrSwiperProvided () {
try {
val jsonElement = JsonObject()
MobileSwipeActionParamsDeserializer()
.deserialize(jsonElement, null, null)
} catch (jpe:JsonParseException) {
return assertTrue(true);
}
assertTrue(false);
@Test(expected = JsonParseException::class)
fun `should reject if do not provided 'direction' or 'swiper` () {
val jsonElement = JsonObject()
MobileSwipeActionParamsDeserializer()
.deserialize(jsonElement, null, null)
}
}

0 comments on commit c62c122

Please sign in to comment.