launchFragmentInContainer<MyFragment>() onView(withId(R.id.refresh)).perform(click()) scenario.onFrament { fragment -> // Check that the fragment handled the click correctly. } }
// fragment-ktx val fragmentViewModel : MyViewModel by viewModels() val activityViewModel : MyViewModel by activityViewModels() // navigation-ktx val navGraphViewModel: MyViewModel by navGraphViewModels(R.id.main)
= TestListenableWorkerBuilder<MyWorker>(context).build() val COUNT = 5 // Small iteration count val start = System.nanoTime() // Measuring immediately for (i in 0..COUNT) { worker.doWork() } // Includes outliers! val elapsed = (System.nanoTime() - start) Log.d("Benchmark", "Time taken was $elapsed ns") }
= TestListenableWorkerBuilder<MyWorker>(context).build() val COUNT = 5 // Small iteration count val start = System.nanoTime() // Measuring immediately for (i in 0..COUNT) { worker.doWork() } // Includes outliers! val elapsed = (System.nanoTime() - start) Log.d("Benchmark", "Time taken was $elapsed ns") }
= TestListenableWorkerBuilder<MyWorker>(context).build() val COUNT = 5 // Small iteration count val start = System.nanoTime() // Measuring immediately for (i in 0..COUNT) { worker.doWork() } // Includes outliers! val elapsed = (System.nanoTime() - start) Log.d("Benchmark", "Time taken was $elapsed ns") }
fun myFirstBenchmark() { val worker = TestListenableWorkerBuilder<MyWorker>(context).build() val COUNT = 5 // Small iteration count val start = System.nanoTime() // Measuring immediately for (i in 0..COUNT) { worker.doWork() } // Includes outliers! val elapsed = (System.nanoTime() - start) Log.d("Benchmark", "Time taken was $elapsed ns") }
packages are bundled with the # Android operating system, and which are packaged with your app's APK android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=tru https://developer.android.com/studio/command-line/jetifier