Skip to content

Commit

Permalink
Merge pull request #168 from natura-cosmeticos/shortcut-label-limit
Browse files Browse the repository at this point in the history
[DSY-1590] Adjusting shortcut label
  • Loading branch information
mlcsouza authored Nov 3, 2020
2 parents 3dee624 + aa4cdd7 commit f46320e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Shortcut @JvmOverloads constructor(
private var iconAttribute: String? = null
private var shortcutAttributesArray: TypedArray

private val labelContainer by lazy { findViewById<TextView>(R.id.shortCutLabel) }
val labelContainer by lazy { findViewById<TextView>(R.id.shortCutLabel) }
private val backgroundContainer by lazy { findViewById<LinearLayout>(R.id.shortcutBackground) }
private val iconContainer by lazy { findViewById<ImageView>(R.id.shortCutIcon) }

Expand Down
3 changes: 2 additions & 1 deletion designsystem/src/main/res/layout/shortcut.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ShortcutActivity>

@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()
}
}
}

0 comments on commit f46320e

Please sign in to comment.