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
// The tools below can be used to easily start fragments and activities across module boundaries. | |
// Example usage - a "directory" is declared like this object. | |
// Then you can use it to: | |
// Create a new fragment: Search.results().newInstance(fragmentArguments) | |
// Create an intent for the Fragment: Search.results().newIntent(context, fragmentArguments) | |
// Start an intent for the Fragment: Search.results().startActivity(context, fragmentArguments) | |
object Search : Fragments("com.example.android.search") { | |
fun results() = create<SearchArguments>("SearchResultsFragment") |
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
// The tools below can be used to easily start fragments and activities across module boundaries. | |
// Example usage - a "directory" is declared like this object. | |
// Then you can use it to: | |
// Create a new fragment: Search.results().newInstance(fragmentArguments) | |
// Create an intent for the Fragment: Search.results().newIntent(context, fragmentArguments) | |
// Start an intent for the Fragment: Search.results().startActivity(context, fragmentArguments) | |
object Search : Fragments("com.example.android.search") { | |
fun results() = create<SearchArguments>("SearchResultsFragment") |
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
import java.io.BufferedReader | |
import java.io.File | |
import java.util.concurrent.TimeUnit | |
import kotlin.system.exitProcess | |
/** | |
* This script takes the name of another kts script as an argument, builds that script with gradle, and runs | |
* its tests via "gradle clean test". | |
*/ |
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
override fun provideMocks() = combineMocks( | |
"Marketplace" to marketplaceMocks(), | |
"Plus" to plusMocks(), | |
"Plus ProHost" to plusProHostMocks() | |
) |
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
@LargeTest | |
class MvrxIntegrationTests : MvRxIntegrationTestBase() { | |
@Test | |
fun booking_fragments_BookingFragment_Screenshots() { | |
runScreenshots("com.airbnb.android.booking.fragments.BookingFragment") | |
} | |
@Test | |
fun booking_fragments_BookingFragment_Interactions() { | |
runInteractionTest("com.airbnb.android.booking.fragments.BookingFragment") |
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
AppCompatDrawableManager.get().onConfigurationChanged(view.context) | |
val resources = view.resources | |
val currentConfig = resources.configuration | |
val currentDisplayMetrics = resources.displayMetrics | |
resources.updateConfiguration(null, currentDisplayMetrics) | |
resources.updateConfiguration(currentConfig, currentDisplayMetrics) |
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
val testContextMessage = "Error while testing 'Default State' mock for BookingFragment -> Clicking 'book_button' view on thread 'AsyncTask #1'" | |
throw IllegalStateException(testContextMessage, originalException) |
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
fun waitForLoopers(loopers: List<Looper>) { | |
val idleDetectors = loopers.map { HandlerIdleDetector(Handler(it)) } | |
while (idleDetectors.any { !it.isIdle }) { | |
} | |
} | |
class HandlerIdleDetector(val handler: Handler) { | |
var isIdle = false | |
init { |
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
@Test | |
fun screenshotBookingFragment() = runScreenshots("com.airbnb.booking.BookingFragment") | |
@Test | |
fun screenshotSearchFragment() = runScreenshots("com.airbnb.search.SearchFragment") | |
fun runScreenshots(fragmentName: String) { | |
val intent = IntegrationTestActivity.intent<HappoTestActivity>( | |
context = InstrumentationRegistry.getInstrumentation().targetContext, | |
fragmentName = fragmentName |
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
class InteractionTestActivity : IntegrationTestActivity() { | |
override fun testCurrentScreen( | |
mockProvider: MockedFragmentProvider, | |
fragment: MvRxFragment, | |
resetView: (onViewReset: (MvRxFragment) -> Unit) -> Unit, | |
finishedTestingFragment: () -> Unit | |
) { | |
ActivityInteractionTester( | |
activity = this, | |
resetViewCallback = resetView, |
NewerOlder