-
Notifications
You must be signed in to change notification settings - Fork 69
modernize elapsed time composable #539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Kimblebee
wants to merge
14
commits into
main
Choose a base branch
from
kim/refactor/elapsed-time-component
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b4f400c
modernize elapsed time composable & include previews
Kimblebee f274b24
address PR comment
Kimblebee efdbe9e
spotless
Kimblebee 3cba311
Merge branch 'main' into kim/refactor/elapsed-time-component
Kimblebee 5512d31
tidy up components and previe
Kimblebee 7b7dd89
adjust according to design
Kimblebee 4e9d519
Refactor ElapsedTimeText to support paused video recording state
Kimblebee 2c6c138
Add TalkBack support and accessibility checks to ElapsedTimeText
Kimblebee f6db89a
Merge branch 'main' into kim/refactor/elapsed-time-component
Kimblebee 1a4e752
Merge branch 'main' into kim/refactor/elapsed-time-component
Kimblebee 3afd692
Merge branch 'main' into kim/refactor/elapsed-time-component
Kimblebee f98bc27
spotless
Kimblebee 37d1f64
reformat comments
Kimblebee 0ac6c14
Merge branch 'main' into kim/refactor/elapsed-time-component
Kimblebee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
104 changes: 104 additions & 0 deletions
104
...idTest/java/com/google/jetpackcamera/ui/components/capture/CaptureScreenComponentsTest.kt
This file contains hidden or 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,104 @@ | ||
| /* | ||
| * Copyright (C) 2026 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.google.jetpackcamera.ui.components.capture | ||
|
|
||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.platform.testTag | ||
| import androidx.compose.ui.test.assertContentDescriptionEquals | ||
| import androidx.compose.ui.test.assertTextEquals | ||
| import androidx.compose.ui.test.junit4.createComposeRule | ||
| import androidx.compose.ui.test.onNodeWithTag | ||
| import androidx.compose.ui.test.onRoot | ||
| import androidx.compose.ui.test.tryPerformAccessibilityChecks | ||
| import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
| import com.google.jetpackcamera.ui.uistate.capture.ElapsedTimeUiState | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
| import org.junit.runner.RunWith | ||
|
|
||
| @RunWith(AndroidJUnit4::class) | ||
| class CaptureScreenComponentsTest { | ||
| @get:Rule | ||
| val composeTestRule = createComposeRule() | ||
|
|
||
| @Test | ||
| fun elapsedTimeText_unavailableState_doesNotRender() { | ||
| composeTestRule.setContent { | ||
| ElapsedTimeText( | ||
| modifier = Modifier.testTag(ELAPSED_TIME_TAG), | ||
| elapsedTimeUiStateProvider = { ElapsedTimeUiState.Unavailable } | ||
| ) | ||
| } | ||
| composeTestRule.onNodeWithTag(ELAPSED_TIME_TAG).assertDoesNotExist() | ||
| composeTestRule.onRoot().tryPerformAccessibilityChecks() | ||
| } | ||
|
|
||
| @Test | ||
| fun elapsedTimeText_enabledActive_displaysFormattedTime() { | ||
| composeTestRule.setContent { | ||
| ElapsedTimeText( | ||
| modifier = Modifier.testTag(ELAPSED_TIME_TAG), | ||
| // 0:30 | ||
| elapsedTimeUiStateProvider = { ElapsedTimeUiState.Enabled(30_000_000_000L) } | ||
| ) | ||
| } | ||
| composeTestRule.onNodeWithTag(ELAPSED_TIME_TAG).assertTextEquals("0:30") | ||
| composeTestRule.onRoot().tryPerformAccessibilityChecks() | ||
| } | ||
|
|
||
| @Test | ||
| fun elapsedTimeText_enabledActive_setsContentDescription() { | ||
| composeTestRule.setContent { | ||
| ElapsedTimeText( | ||
| modifier = Modifier.testTag(ELAPSED_TIME_TAG), | ||
| // 1:05 | ||
| elapsedTimeUiStateProvider = { ElapsedTimeUiState.Enabled(65_000_000_000L) } | ||
| ) | ||
| } | ||
| composeTestRule.onNodeWithTag(ELAPSED_TIME_TAG) | ||
| .assertContentDescriptionEquals("Recording time: 1 minutes and 5 seconds") | ||
| } | ||
|
|
||
| @Test | ||
| fun elapsedTimeText_enabledPaused_displaysPausedFormattedTime() { | ||
| composeTestRule.setContent { | ||
| ElapsedTimeText( | ||
| modifier = Modifier.testTag(ELAPSED_TIME_TAG), | ||
| elapsedTimeUiStateProvider = { | ||
| // PAUSED 0:30 | ||
| ElapsedTimeUiState.Enabled(30_000_000_000L, isPaused = true) | ||
| } | ||
| ) | ||
| } | ||
| composeTestRule.onNodeWithTag(ELAPSED_TIME_TAG).assertTextEquals("PAUSED 0:30") | ||
| composeTestRule.onRoot().tryPerformAccessibilityChecks() | ||
| } | ||
|
|
||
| @Test | ||
| fun elapsedTimeText_enabledPaused_setsContentDescription() { | ||
| composeTestRule.setContent { | ||
| ElapsedTimeText( | ||
| modifier = Modifier.testTag(ELAPSED_TIME_TAG), | ||
| elapsedTimeUiStateProvider = { | ||
| // PAUSED 1:05 | ||
| ElapsedTimeUiState.Enabled(65_000_000_000L, isPaused = true) | ||
| } | ||
| ) | ||
| } | ||
| composeTestRule.onNodeWithTag(ELAPSED_TIME_TAG) | ||
| .assertContentDescriptionEquals("Recording paused: 1 minutes and 5 seconds") | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.