-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
102 changed files
with
560 additions
and
4 deletions.
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
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
53 changes: 53 additions & 0 deletions
53
sample/src/test/kotlin/com/google/android/horologist/dialog/NonScrollableAlertContent.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,53 @@ | ||
/* | ||
* Copyright 2024 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 | ||
* | ||
* https://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.google.android.horologist.dialog | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.wear.compose.foundation.lazy.ScalingLazyListScope | ||
import com.google.android.horologist.annotations.ExperimentalHorologistApi | ||
import com.google.android.horologist.compose.material.AlertContent | ||
import com.google.android.horologist.compose.material.centeredDialogColumnState | ||
|
||
@ExperimentalHorologistApi | ||
@Composable | ||
public fun NonScrollableAlertContent( | ||
onCancel: (() -> Unit)? = null, | ||
onOk: (() -> Unit)? = null, | ||
icon: @Composable (() -> Unit)? = null, | ||
title: String? = null, | ||
message: String? = null, | ||
okButtonContentDescription: String = stringResource(android.R.string.ok), | ||
cancelButtonContentDescription: String = stringResource(android.R.string.cancel), | ||
showPositionIndicator: Boolean = true, | ||
content: (ScalingLazyListScope.() -> Unit)? = null, | ||
) { | ||
val columnState = centeredDialogColumnState() | ||
|
||
AlertContent( | ||
onCancel, | ||
onOk, | ||
icon, | ||
title, | ||
message, | ||
okButtonContentDescription, | ||
cancelButtonContentDescription, | ||
columnState, | ||
showPositionIndicator, | ||
content, | ||
) | ||
} |
102 changes: 102 additions & 0 deletions
102
sample/src/test/kotlin/com/google/android/horologist/dialog/NonScrollableAlertDialogTest.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,102 @@ | ||
/* | ||
* Copyright 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 | ||
* | ||
* https://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.google.android.horologist.dialog | ||
|
||
import androidx.compose.ui.res.stringResource | ||
import com.google.android.horologist.audio.ui.R.string.horologist_volume_screen_change_audio_output | ||
import com.google.android.horologist.compose.material.AlertContent | ||
import com.google.android.horologist.screenshots.rng.WearDevice | ||
import com.google.android.horologist.screenshots.rng.WearDeviceScreenshotTest | ||
import org.junit.Test | ||
import org.robolectric.annotation.Config | ||
|
||
class NonScrollableAlertDialogTest(device: WearDevice) : WearDeviceScreenshotTest(device = device) { | ||
public override val tolerance: Float = 0.01f | ||
|
||
override fun testName(suffix: String): String = | ||
"src/test/screenshots/${this.javaClass.simpleName}_${testInfo.methodName.substringBefore('[')}_${device.id}$suffix.png" | ||
|
||
// Not actually non scrolling - but should only be used when developer is confident that | ||
// content won't scroll | ||
|
||
@Test | ||
fun turnOnBluetoothScrollable() = runTest { | ||
AlertContent( | ||
title = "Turn on Bluetooth?", | ||
onOk = {}, | ||
onCancel = {}, | ||
) | ||
} | ||
|
||
@Test | ||
fun turnOnBluetooth() = runTest { | ||
NonScrollableAlertContent( | ||
title = "Turn on Bluetooth?", | ||
onOk = {}, | ||
onCancel = {}, | ||
) | ||
} | ||
|
||
@Test | ||
fun changeAudioOutputEn() = runTest { | ||
NonScrollableAlertContent( | ||
title = stringResource(horologist_volume_screen_change_audio_output), | ||
onOk = {}, | ||
onCancel = {}, | ||
) | ||
} | ||
|
||
@Test | ||
@Config(qualifiers = "+ka") | ||
fun changeAudioOutputKa() = runTest { | ||
NonScrollableAlertContent( | ||
title = stringResource(horologist_volume_screen_change_audio_output), | ||
onOk = {}, | ||
onCancel = {}, | ||
) | ||
} | ||
|
||
@Test | ||
@Config(qualifiers = "+ta") | ||
fun changeAudioOutputTa() = runTest { | ||
NonScrollableAlertContent( | ||
title = stringResource(horologist_volume_screen_change_audio_output), | ||
onOk = {}, | ||
onCancel = {}, | ||
) | ||
} | ||
|
||
@Test | ||
@Config(qualifiers = "+ru") | ||
fun changeAudioOutputRu() = runTest { | ||
NonScrollableAlertContent( | ||
title = stringResource(horologist_volume_screen_change_audio_output), | ||
onOk = {}, | ||
onCancel = {}, | ||
) | ||
} | ||
|
||
@Test | ||
fun tooLong() = runTest { | ||
NonScrollableAlertContent( | ||
title = "Phone app is required", | ||
onCancel = {}, | ||
onOk = {}, | ||
message = "Tap the button below to install it on your phone.", | ||
) | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
sample/src/test/kotlin/com/google/android/horologist/dialog/NonScrollableConfirmationTest.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,82 @@ | ||
/* | ||
* Copyright 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 | ||
* | ||
* https://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.google.android.horologist.dialog | ||
|
||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Error | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.wear.compose.material.Icon | ||
import com.google.android.horologist.auth.composables.R.string.horologist_auth_error_message | ||
import com.google.android.horologist.compose.material.ConfirmationContent | ||
import com.google.android.horologist.compose.material.util.DECORATIVE_ELEMENT_CONTENT_DESCRIPTION | ||
import com.google.android.horologist.screenshots.rng.WearDevice | ||
import com.google.android.horologist.screenshots.rng.WearDeviceScreenshotTest | ||
import org.junit.Test | ||
import org.robolectric.annotation.Config | ||
|
||
class NonScrollableConfirmationTest(device: WearDevice) : WearDeviceScreenshotTest(device = device) { | ||
public override val tolerance: Float = 0.01f | ||
|
||
override fun testName(suffix: String): String = | ||
"src/test/screenshots/${this.javaClass.simpleName}_${testInfo.methodName.substringBefore('[')}_${device.id}$suffix.png" | ||
|
||
// Not actually non scrolling - but demonstrating content that won't scroll | ||
|
||
@Test | ||
fun confirmationContentEn() = runTest { | ||
ConfirmationContent( | ||
title = stringResource(horologist_auth_error_message), | ||
) | ||
} | ||
|
||
@Test | ||
@Config(qualifiers = "+ka") | ||
fun confirmationContentKa() = runTest { | ||
ConfirmationContent( | ||
title = stringResource(horologist_auth_error_message), | ||
) | ||
} | ||
|
||
@Test | ||
@Config(qualifiers = "+ta") | ||
fun confirmationContentTa() = runTest { | ||
ConfirmationContent( | ||
title = stringResource(horologist_auth_error_message), | ||
) | ||
} | ||
|
||
@Test | ||
@Config(qualifiers = "+ru") | ||
fun confirmationContentRu() = runTest { | ||
ConfirmationContent( | ||
title = stringResource(horologist_auth_error_message), | ||
) | ||
} | ||
|
||
@Test | ||
fun confirmationContentWithIcon() = runTest { | ||
ConfirmationContent( | ||
title = stringResource(horologist_auth_error_message), | ||
icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Error, | ||
contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, | ||
) | ||
}, | ||
) | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...screenshots/NonScrollableAlertDialogTest_changeAudioOutputEn_galaxy_watch_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...screenshots/NonScrollableAlertDialogTest_changeAudioOutputEn_galaxy_watch_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
.../NonScrollableAlertDialogTest_changeAudioOutputEn_galaxy_watch_6_small_font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...st/screenshots/NonScrollableAlertDialogTest_changeAudioOutputEn_large_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...st/screenshots/NonScrollableAlertDialogTest_changeAudioOutputEn_pixel_watch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ots/NonScrollableAlertDialogTest_changeAudioOutputEn_pixel_watch_large_font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...st/screenshots/NonScrollableAlertDialogTest_changeAudioOutputEn_small_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...screenshots/NonScrollableAlertDialogTest_changeAudioOutputEn_ticwatch_pro_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...screenshots/NonScrollableAlertDialogTest_changeAudioOutputKa_galaxy_watch_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...screenshots/NonScrollableAlertDialogTest_changeAudioOutputKa_galaxy_watch_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
.../NonScrollableAlertDialogTest_changeAudioOutputKa_galaxy_watch_6_small_font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.