-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable custom content description for the bottom sheet title (#2033)
* Add support for custom content description to be set for BpkModalBottomSheetHeader title * Add story for testing bottom sheet with custom content description for title * Add BpkModalBottomSheetTest * Add licence header to BpkModalBottomSheetTest * Update titleContentDescription to default to null * Update BpkModalBottomSheetTest to check for SemanticsProperties.Heading also * Update BottomSheet/README.md * Update BottomSheet/README.md * Address PR feedback
- Loading branch information
1 parent
ac495c2
commit 8793d9a
Showing
6 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...androidTest/kotlin/net/skyscanner/backpack/compose/bottomsheet/BpkModalBottomSheetTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Backpack for Android - Skyscanner's Design System | ||
* | ||
* Copyright 2018 Skyscanner Ltd | ||
* | ||
* 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 net.skyscanner.backpack.compose.bottomsheet | ||
|
||
import androidx.compose.ui.semantics.SemanticsProperties | ||
import androidx.compose.ui.test.SemanticsMatcher | ||
import androidx.compose.ui.test.assertTextEquals | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithContentDescription | ||
import net.skyscanner.backpack.compose.theme.BpkTheme | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class BpkModalBottomSheetTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
private val title = "Title" | ||
private val customTitleContentDesc = "Custom content desc" | ||
|
||
@Test | ||
fun givenTitleContentDescriptionNotNull_whenBpkModalBottomSheet_thenSemanticsSet() { | ||
composeTestRule.setContent { | ||
BpkTheme { | ||
BpkModalBottomSheet( | ||
onDismissRequest = { }, | ||
title = title, | ||
titleContentDescription = customTitleContentDesc, | ||
content = {}, | ||
) | ||
} | ||
} | ||
|
||
composeTestRule | ||
.onNode(SemanticsMatcher.expectValue(key = SemanticsProperties.Heading, expectedValue = Unit)) | ||
.assertTextEquals(title) | ||
|
||
composeTestRule | ||
.onNodeWithContentDescription(customTitleContentDesc) | ||
.assertExists() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters