Skip to content

Instantly share code, notes, and snippets.

View lukaszkalnik's full-sized avatar

Lukasz Kalnik lukaszkalnik

View GitHub Profile
@OliverCulleyDeLange
OliverCulleyDeLange / README.md
Last active June 25, 2024 09:21
Test LiveData with KoTest and Mockk

Testing ViewModel / LiveData with KoTest (previously Kotlintest) and Mockk

I went round a few houses trying to figure out how best to test ViewModels containing LiveData using Kotlin based testing tools. My main mistakes were trying to use JUnit 5 annotations with KoTest test classes and expecting them to work. The @ExtendWith() annotation is from the org.junit.jupiter.api.extension package. Jupiter is the module used for writing tests, whereas KoTest runs on the JUnit 5 Platform. Very different thing apparently

I came accross this Mockk issue which pointed me towards this write up on how to test live data with JUnit 5. This gave me the code to delegate the live data executor to a custom one which simply executes immedietely.

I've not tested thi

@ouchadam
ouchadam / gist:876aa29b80752ecaaa08
Created January 25, 2016 15:18
exoplayer x86 hack
private static Pair<String, CodecCapabilities> getMediaCodecInfoInternal(CodecKey key,
MediaCodecListCompat mediaCodecList) {
String mimeType = key.mimeType;
int numberOfCodecs = mediaCodecList.getCodecCount();
boolean secureDecodersExplicit = mediaCodecList.secureDecodersExplicit();
// Note: MediaCodecList is sorted by the framework such that the best decoders come first.
Log.e("!!!", " --------- secure explicit? : " + secureDecodersExplicit);
for (int i = 0; i < numberOfCodecs; i++) {
MediaCodecInfo info = mediaCodecList.getCodecInfoAt(i);