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
package io.reactivex.android.schedulers; | |
public class HandlerScheduler extends Scheduler { | |
//... | |
private static final class HandlerWorker extends Worker { | |
public Disposable schedule(Runnable run, long delay, TimeUnit unit) { |
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 `WHEN local holding is missing in Portfolio THEN it is removed from memory and DB`() { | |
//code stubbing this particular case is omitted due to complexity here | |
repository.observePortfolio(forceReload = true).test() | |
ioScheduler.triggerActions() | |
verify(holdingsDao).deleteHoldingById(eq("4")) | |
verify(memoryCache).remove(eq("${HOLDING}_4")) |
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 `NOT FORCE observing data WHEN memory cache IS NOT EMPTY`() { | |
whenever(fromMemory.invoke(eq(key), eq(params))).thenReturn(cachedDomain) | |
whenever(paramsKey.invoke(eq(params))).thenReturn(key) | |
val testObserver = dataObservableDelegate.observe(params = params, forceReload = false).test() | |
testObserver.assertValueCount(1) | |
testObserver.assertValueAt(0) { | |
it.content == cachedDomain && it.error == null && !it.loading |
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
private val observePortfolioDod: DataObservableDelegate<Any, String, Portfolio> = DataObservableDelegate( | |
//other dod params | |
toMemory = { key, _, portfolio -> | |
memoryCache[key] = portfolio | |
//Update holdingsDod with holdings present in Portfolio | |
portfolio.holdings.forEach { holding -> | |
holdingsDod.updateAll(holding.id, holding) | |
} | |
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
./gradlew startSwarm ./gradlew executeScreenshotTests -Pandroid.testInstrumentationRunnerArguments.package=com.revolut.espresso.tests.screenshots stopSwarm |
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
apply plugin: 'keith.thompson.swarmer' | |
swarmer { | |
virtualDevices { | |
Pixel_XL { | |
packages = "system-images;android-26;google_apis;x86" | |
androidAbi = "google_apis/x86" | |
pathToConfigIni = "emulator_config.ini" |
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 StockRateDelegateTest { | |
private lateinit var delegate: StockRateDelegate | |
private lateinit var vh: StockRateDelegate.ViewHolder | |
private fun stubStockDelegateModel( | |
title: String, | |
ticker: String, | |
price: String | |
) = StockRateDelegate.Model( |
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 <T, VH : RecyclerView.ViewHolder> BaseRecyclerViewDelegate<T, VH>.bind(vh: VH, model: T) = | |
InstrumentationRegistry.getInstrumentation().runOnMainSync { | |
onBindViewHolder(vh, model, 0, null) | |
} | |
fun RecyclerView.ViewHolder.setUpAndSnap() { | |
ViewHelpers.setupView(itemView).setExactWidthDp(DELEGATE_TEST_WIDTH_DP).layout() | |
Screenshot.snap(itemView).record() | |
} |
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 TestRunner : AndroidJUnitRunner() { | |
override fun onCreate(arguments: Bundle?) { | |
ScreenshotRunner.onCreate(this, arguments); | |
super.onCreate(arguments) | |
} | |
override fun finish(resultCode: Int, results: Bundle?) { | |
ScreenshotRunner.onDestroy(); | |
super.finish(resultCode, results) |
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
apply plugin: 'com.facebook.testing.screenshot' | |
apply plugin: 'shot' | |
shot { | |
appId = 'com.revolut.revolut.test' | |
instrumentationTestTask = 'connectedQaInstrumentationDebugAndroidTest' | |
packageTestApkTask = 'packageQaInstrumentationDebugAndroidTest' | |
} | |
android { |
NewerOlder