diff --git a/designsystem/src/main/kotlin/com/natura/android/shortcut/Shortcut.kt b/designsystem/src/main/kotlin/com/natura/android/shortcut/Shortcut.kt index 1bb864408..5d66d26f2 100644 --- a/designsystem/src/main/kotlin/com/natura/android/shortcut/Shortcut.kt +++ b/designsystem/src/main/kotlin/com/natura/android/shortcut/Shortcut.kt @@ -32,7 +32,7 @@ class Shortcut @JvmOverloads constructor( private var iconAttribute: String? = null private var shortcutAttributesArray: TypedArray - private val labelContainer by lazy { findViewById(R.id.shortCutLabel) } + val labelContainer by lazy { findViewById(R.id.shortCutLabel) } private val backgroundContainer by lazy { findViewById(R.id.shortcutBackground) } private val iconContainer by lazy { findViewById(R.id.shortCutIcon) } diff --git a/designsystem/src/main/res/layout/shortcut.xml b/designsystem/src/main/res/layout/shortcut.xml index d5b1f0b9b..ebc0636bb 100644 --- a/designsystem/src/main/res/layout/shortcut.xml +++ b/designsystem/src/main/res/layout/shortcut.xml @@ -50,10 +50,11 @@ android:layout_height="wrap_content" android:layout_marginTop="?spacingTiny" android:textAlignment="center" + android:ellipsize="end" + android:maxLines="1" tools:text="Contained big label to check the behavior" android:autoSizeTextType="uniform" android:textAppearance="?textAppearanceCaption" - android:singleLine="false" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" diff --git a/sample/build.gradle b/sample/build.gradle index 4de4dd13d..a7950bed2 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -61,6 +61,7 @@ dependencies { androidTestImplementation "androidx.test.ext:junit:$rootProject.junitExtVersion" androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.espressoVersion" testImplementation "androidx.test.ext:truth:$rootProject.truthVersion" + androidTestImplementation "androidx.test.ext:truth:$rootProject.truthVersion" androidTestImplementation "androidx.test:rules:$rootProject.androidXTestVersion" androidTestImplementation "androidx.test:runner:$rootProject.androidXTestVersion" androidTestImplementation "androidx.test:core-ktx:$rootProject.testCoreKtxVersion" diff --git a/sample/src/androidTest/kotlin/com/natura/android/sample/components/ShortcutActivityFunctionalTest.kt b/sample/src/androidTest/kotlin/com/natura/android/sample/components/ShortcutActivityFunctionalTest.kt new file mode 100644 index 000000000..3476cb129 --- /dev/null +++ b/sample/src/androidTest/kotlin/com/natura/android/sample/components/ShortcutActivityFunctionalTest.kt @@ -0,0 +1,40 @@ +package com.natura.android.sample.components + +import androidx.test.core.app.ActivityScenario +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.google.common.truth.Truth +import kotlinx.android.synthetic.main.activity_shortcut.* +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class ShortcutActivityFunctionalTest { + + private lateinit var scenario: ActivityScenario + + @Before + fun setUp() { + scenario = ActivityScenario.launch(ShortcutActivity::class.java) + } + + @Test + fun checksEllipsisAtShortcutContainedLabel() { + scenario.onActivity { + val shortcut = it.shortcutContained1 + val ellipsis = shortcut.labelContainer.layout.getEllipsisCount(0) + + Truth.assertThat(ellipsis > 0).isTrue() + } + } + + @Test + fun checksEllipsisAtShortcutOutlinedLabel() { + scenario.onActivity { + val shortcut = it.shortcutOutlined1 + val ellipsis = shortcut.labelContainer.layout.getEllipsisCount(0) + + Truth.assertThat(ellipsis > 0).isTrue() + } + } +}