1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 package com.android.customization.model.picker.quickaffordance.data.repository 19 20 import androidx.test.filters.SmallTest 21 import com.android.customization.picker.quickaffordance.data.repository.KeyguardQuickAffordancePickerRepository 22 import com.android.systemui.shared.customization.data.content.FakeCustomizationProviderClient 23 import com.google.common.truth.Truth.assertThat 24 import kotlinx.coroutines.Dispatchers 25 import kotlinx.coroutines.ExperimentalCoroutinesApi 26 import kotlinx.coroutines.test.TestScope 27 import kotlinx.coroutines.test.UnconfinedTestDispatcher 28 import kotlinx.coroutines.test.resetMain 29 import kotlinx.coroutines.test.setMain 30 import org.junit.After 31 import org.junit.Before 32 import org.junit.Test 33 import org.junit.runner.RunWith 34 import org.robolectric.RobolectricTestRunner 35 36 @OptIn(ExperimentalCoroutinesApi::class) 37 @SmallTest 38 @RunWith(RobolectricTestRunner::class) 39 class KeyguardQuickAffordancePickerRepositoryTest { 40 41 private lateinit var underTest: KeyguardQuickAffordancePickerRepository 42 43 private lateinit var testScope: TestScope 44 private lateinit var client: FakeCustomizationProviderClient 45 46 @Before setUpnull47 fun setUp() { 48 client = FakeCustomizationProviderClient() 49 val coroutineDispatcher = UnconfinedTestDispatcher() 50 testScope = TestScope(coroutineDispatcher) 51 Dispatchers.setMain(coroutineDispatcher) 52 53 underTest = 54 KeyguardQuickAffordancePickerRepository( 55 client = client, 56 mainScope = testScope.backgroundScope, 57 ) 58 } 59 60 // We need at least one test to prevent Studio errors 61 @Test creationSucceedsnull62 fun creationSucceeds() { 63 assertThat(underTest).isNotNull() 64 } 65 66 @After tearDownnull67 fun tearDown() { 68 Dispatchers.resetMain() 69 } 70 } 71