Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 702b421d authored by Kelly's avatar Kelly
Browse files

Add unit tests for SettingsSlider widget.

Bug: 241857459
Test: unit tests
Change-Id: I80acdeaf08bb1078fc1d0f3dbe09569bd9c96d0b
parent 77689d19
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -30,11 +30,11 @@ import androidx.compose.ui.tooling.preview.Preview
import com.android.settingslib.spa.framework.api.SettingsPageProvider
import com.android.settingslib.spa.framework.compose.navigator
import com.android.settingslib.spa.framework.theme.SettingsTheme
import com.android.settingslib.spa.widget.SettingsSlider
import com.android.settingslib.spa.widget.SettingsSliderModel
import com.android.settingslib.spa.widget.preference.Preference
import com.android.settingslib.spa.widget.preference.PreferenceModel
import com.android.settingslib.spa.widget.scaffold.RegularScaffold
import com.android.settingslib.spa.widget.ui.SettingsSlider
import com.android.settingslib.spa.widget.ui.SettingsSliderModel

private const val TITLE = "Sample Slider"

+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.settingslib.spa.widget.ui
package com.android.settingslib.spa.widget

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.AccessAlarm
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settingslib.spa.widget

import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class SettingsSliderTest {
    @get:Rule
    val composeTestRule = createComposeRule()

    @Test
    fun title_displayed() {
        composeTestRule.setContent {
            SettingsSlider(object : SettingsSliderModel {
                override val title = "Slider"
                override val initValue = 40
            })
        }

        composeTestRule.onNodeWithText("Slider").assertIsDisplayed()
    }

    // TODO: Add more unit tests for SettingsSlider widget.
}