-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
741 additions
and
60 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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
60 changes: 60 additions & 0 deletions
60
app-shared-tests/src/main/java/com/appunite/loudius/UniversalWalkThroughAppTest.kt
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,60 @@ | ||
/* | ||
* Copyright 2023 AppUnite S.A. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.appunite.loudius | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import com.appunite.loudius.util.IntegrationTestRule | ||
import com.appunite.loudius.util.waitUntilLoadingDoesNotExist | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
abstract class UniversalWalkThroughAppTest { | ||
|
||
@get:Rule(order = 0) | ||
val integrationTestRule by lazy { IntegrationTestRule(this, MainActivity::class.java) } | ||
|
||
@Before | ||
fun setUp() { | ||
integrationTestRule.setUp() | ||
} | ||
|
||
@Test | ||
fun whenLoginScreenIsVisible_LoginButtonOpensGithubAuth(): Unit = with(integrationTestRule) { | ||
composeTestRule.onNodeWithText("Log in").performClick() | ||
|
||
performGitHubLogin() | ||
|
||
composeTestRule.waitUntilLoadingDoesNotExist() | ||
|
||
composeTestRule.onNodeWithText("First Pull-Request title").performClick() | ||
|
||
composeTestRule.waitUntilLoadingDoesNotExist() | ||
|
||
composeTestRule.onNodeWithText("Notify").performClick() | ||
|
||
composeTestRule.waitUntilLoadingDoesNotExist() | ||
|
||
composeTestRule | ||
.onNodeWithText("Awesome! Your collaborator have been pinged for some serious code review action! \uD83C\uDF89") | ||
.assertIsDisplayed() | ||
} | ||
|
||
abstract fun performGitHubLogin() | ||
} |
57 changes: 57 additions & 0 deletions
57
app-shared-tests/src/main/java/com/appunite/loudius/util/Described.kt
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,57 @@ | ||
/* | ||
* Copyright 2023 AppUnite S.A. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.appunite.loudius.util | ||
|
||
/** | ||
* Adds description to a test, so failures are better recorded | ||
* | ||
* Example usage: | ||
* ```kt | ||
* description("Log-in") { | ||
* description("Fill e-mail and password") { | ||
* onView(withHint("E-mail")).perform(type("[email protected]")) | ||
* onView(withHint("Password")).perform(type("password")) | ||
* } | ||
* description("Submit") { | ||
* onView(withId(R.id.login_button)).perform(click()) | ||
* } | ||
* } | ||
* description("Ensure home screen is displayed") { | ||
* onView(withClass("com.example.com.LoginScreen")).check(isDisplayed()) | ||
* } | ||
* ``` | ||
* | ||
* In case of failure, you'll see: | ||
* | ||
* ``` | ||
* Exception thrown DescriptionAssertionError("Error in step: Log-in -> Fill e-mail and password") | ||
* ``` | ||
* | ||
* The exception is always thrown with the root cause attached. | ||
*/ | ||
fun <T> description(description: String, lambda: () -> T): T { | ||
try { | ||
return lambda() | ||
} catch (error: DescriptionAssertionError) { | ||
throw DescriptionAssertionError("$description -> ${error.step}", error.cause!!) | ||
} catch (error: AssertionError) { | ||
throw DescriptionAssertionError(description, error) | ||
} | ||
} | ||
|
||
class DescriptionAssertionError(val step: String, cause: Throwable) : | ||
AssertionError("Error in step: \"$step\"", cause) |
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
50 changes: 50 additions & 0 deletions
50
app-shared-tests/src/main/java/com/appunite/loudius/util/KeyGrouping.kt
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,50 @@ | ||
/* | ||
* Copyright 2023 AppUnite S.A. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
@file:Suppress("ktlint:filename") | ||
|
||
package com.appunite.loudius.util | ||
|
||
import android.view.KeyEvent | ||
|
||
/** | ||
* Optimize typing by grouping characters with the same metaState | ||
* | ||
* UiDevice has UiDevice.pressKeyCode and UiDevice.pressKeyCodes methods. | ||
* Using UiDevice.pressKeyCodes is much faster for typing multiple characters, but | ||
* it couldn't be used for characters with a different metaState (e.g. Alt/Shift/Ctr). | ||
* i.e. to write "Jacek Marchwicki" we need to use: | ||
* * pressKeyCodes "j" with Shift | ||
* * pressKeyCodes "acek " without metaState | ||
* * pressKeyCodes "m" with Shift | ||
* * pressKeyCodes "archwicki " without metaState | ||
* | ||
* so instead of calling "pressKeyCode" 16 times, we call "pressKeyCodes" 4 times - this is | ||
* significantly faster. | ||
* | ||
* This method groups those calls, so we can type faster. | ||
*/ | ||
fun groupKeys(list: List<KeyEvent>): List<KeyTypeEvent> = list | ||
.filter { it.action == KeyEvent.ACTION_UP } | ||
.fold(listOf()) { acc, event -> | ||
val last = acc.lastOrNull() | ||
if (last != null && last.metaState == event.metaState) { | ||
acc.dropLast(1).plus(KeyTypeEvent(last.keyCodes.plus(event.keyCode), event.metaState)) | ||
} else { | ||
acc.plus(KeyTypeEvent(listOf(event.keyCode), event.metaState)) | ||
} | ||
} | ||
|
||
data class KeyTypeEvent(val keyCodes: List<Int>, val metaState: Int) |
Oops, something went wrong.