1 /* 2 * Copyright (C) 2024 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 package com.android.launcher3.model.data 18 19 import androidx.test.ext.junit.runners.AndroidJUnit4 20 import androidx.test.filters.SmallTest 21 import com.android.launcher3.pm.PackageInstallInfo 22 import com.android.launcher3.util.LauncherModelHelper 23 import com.google.common.truth.Truth 24 import org.junit.After 25 import org.junit.Before 26 import org.junit.Test 27 import org.junit.runner.RunWith 28 29 @SmallTest 30 @RunWith(AndroidJUnit4::class) 31 class ItemInfoWithIconTest { 32 33 private var context = LauncherModelHelper.SandboxModelContext() 34 private lateinit var itemInfoWithIcon: ItemInfoWithIcon 35 36 @Before setupnull37 fun setup() { 38 itemInfoWithIcon = 39 object : ItemInfoWithIcon() { 40 override fun clone(): ItemInfoWithIcon? { 41 return null 42 } 43 } 44 } 45 46 @After tearDownnull47 fun tearDown() { 48 context.destroy() 49 } 50 51 @Test itemInfoWithIconDefaultParamsTestnull52 fun itemInfoWithIconDefaultParamsTest() { 53 Truth.assertThat(itemInfoWithIcon.isDisabled).isFalse() 54 Truth.assertThat(itemInfoWithIcon.isPendingDownload).isFalse() 55 Truth.assertThat(itemInfoWithIcon.isArchived).isFalse() 56 } 57 58 @Test isDisabledOrPendingTestnull59 fun isDisabledOrPendingTest() { 60 itemInfoWithIcon.setProgressLevel(0, PackageInstallInfo.STATUS_INSTALLING) 61 Truth.assertThat(itemInfoWithIcon.isDisabled).isFalse() 62 Truth.assertThat(itemInfoWithIcon.isPendingDownload).isTrue() 63 64 itemInfoWithIcon.setProgressLevel(1, PackageInstallInfo.STATUS_INSTALLING) 65 Truth.assertThat(itemInfoWithIcon.isDisabled).isFalse() 66 Truth.assertThat(itemInfoWithIcon.isPendingDownload).isFalse() 67 } 68 } 69