diff --git a/packages/SettingsLib/Spa/tests/src/com/android/settingslib/spa/widget/button/ActionButtonsTest.kt b/packages/SettingsLib/Spa/tests/src/com/android/settingslib/spa/widget/button/ActionButtonsTest.kt index 8101a94a9461a..f59b0decf1e55 100644 --- a/packages/SettingsLib/Spa/tests/src/com/android/settingslib/spa/widget/button/ActionButtonsTest.kt +++ b/packages/SettingsLib/Spa/tests/src/com/android/settingslib/spa/widget/button/ActionButtonsTest.kt @@ -17,11 +17,13 @@ package com.android.settingslib.spa.widget.button import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.Close import androidx.compose.material.icons.outlined.Launch import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.getBoundsInRoot import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick @@ -66,4 +68,19 @@ class ActionButtonsTest { assertThat(clicked).isTrue() } + + @Test + fun twoButtons_positionIsAligned() { + composeTestRule.setContent { + ActionButtons( + listOf( + ActionButton(text = "Open", imageVector = Icons.Outlined.Launch) {}, + ActionButton(text = "Close", imageVector = Icons.Outlined.Close) {}, + ) + ) + } + + assertThat(composeTestRule.onNodeWithText("Open").getBoundsInRoot().top) + .isEqualTo(composeTestRule.onNodeWithText("Close").getBoundsInRoot().top) + } } diff --git a/packages/SettingsLib/Spa/tests/src/com/android/settingslib/spa/widget/ui/FooterTest.kt b/packages/SettingsLib/Spa/tests/src/com/android/settingslib/spa/widget/ui/FooterTest.kt new file mode 100644 index 0000000000000..9d0501f029b1b --- /dev/null +++ b/packages/SettingsLib/Spa/tests/src/com/android/settingslib/spa/widget/ui/FooterTest.kt @@ -0,0 +1,55 @@ +/* + * 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.ui + +import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.assertIsNotDisplayed +import androidx.compose.ui.test.junit4.createComposeRule +import androidx.compose.ui.test.onNodeWithText +import androidx.compose.ui.test.onRoot +import androidx.test.ext.junit.runners.AndroidJUnit4 +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class FooterTest { + @get:Rule + val composeTestRule = createComposeRule() + + @Test + fun footer_isEmpty() { + composeTestRule.setContent { + Footer(footerText = "") + } + + composeTestRule.onRoot().assertIsNotDisplayed() + } + + @Test + fun footer_notEmpty_displayed() { + composeTestRule.setContent { + Footer(footerText = FOOTER_TEXT) + } + + composeTestRule.onNodeWithText(FOOTER_TEXT).assertIsDisplayed() + } + + private companion object { + const val FOOTER_TEXT = "Footer text" + } +}