Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.google.jetpackcamera

import android.os.Build
import androidx.compose.ui.test.isDisplayed
import androidx.compose.ui.test.junit4.createEmptyComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
Expand All @@ -28,7 +27,6 @@ import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.TruthJUnit.assume
import com.google.jetpackcamera.ui.components.capture.CAPTURE_BUTTON
import com.google.jetpackcamera.ui.components.capture.QUICK_SETTINGS_DROP_DOWN
import com.google.jetpackcamera.ui.components.capture.QUICK_SETTINGS_FLIP_CAMERA_BUTTON
import com.google.jetpackcamera.ui.components.capture.QUICK_SETTINGS_RATIO_1_1_BUTTON
Expand All @@ -37,6 +35,7 @@ import com.google.jetpackcamera.ui.components.capture.QUICK_SETTINGS_STREAM_CONF
import com.google.jetpackcamera.utils.APP_START_TIMEOUT_MILLIS
import com.google.jetpackcamera.utils.TEST_REQUIRED_PERMISSIONS
import com.google.jetpackcamera.utils.runMainActivityScenarioTest
import com.google.jetpackcamera.utils.waitForCaptureButton
import org.junit.Before
import org.junit.Rule
import org.junit.Test
Expand Down Expand Up @@ -74,19 +73,15 @@ class BackgroundDeviceTest {
@Test
fun background_foreground() = runMainActivityScenarioTest {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

backgroundThenForegroundApp()
}

@Test
fun flipCamera_then_background_foreground() = runMainActivityScenarioTest {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

// Navigate to quick settings
composeTestRule.onNodeWithTag(QUICK_SETTINGS_DROP_DOWN)
Expand All @@ -109,9 +104,7 @@ class BackgroundDeviceTest {
@Test
fun setAspectRatio_then_background_foreground() = runMainActivityScenarioTest {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

// Navigate to quick settings
composeTestRule.onNodeWithTag(QUICK_SETTINGS_DROP_DOWN)
Expand Down Expand Up @@ -147,9 +140,7 @@ class BackgroundDeviceTest {
assumeSupportsSingleStream()

// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

// Navigate to quick settings
composeTestRule.onNodeWithTag(QUICK_SETTINGS_DROP_DOWN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package com.google.jetpackcamera

import android.os.Build
import android.provider.MediaStore
import androidx.compose.ui.test.isDisplayed
import androidx.compose.ui.test.isEnabled
import androidx.compose.ui.test.junit4.createEmptyComposeRule
import androidx.compose.ui.test.onNodeWithTag
Expand All @@ -35,7 +34,6 @@ import com.google.jetpackcamera.ui.components.capture.FLIP_CAMERA_BUTTON
import com.google.jetpackcamera.ui.components.capture.IMAGE_CAPTURE_SUCCESS_TAG
import com.google.jetpackcamera.ui.components.capture.SCREEN_FLASH_OVERLAY
import com.google.jetpackcamera.ui.components.capture.VIDEO_CAPTURE_SUCCESS_TAG
import com.google.jetpackcamera.utils.APP_START_TIMEOUT_MILLIS
import com.google.jetpackcamera.utils.IMAGE_CAPTURE_TIMEOUT_MILLIS
import com.google.jetpackcamera.utils.SCREEN_FLASH_OVERLAY_TIMEOUT_MILLIS
import com.google.jetpackcamera.utils.TEST_REQUIRED_PERMISSIONS
Expand All @@ -46,6 +44,7 @@ import com.google.jetpackcamera.utils.longClickForVideoRecordingCheckingElapsedT
import com.google.jetpackcamera.utils.runMainActivityMediaStoreAutoDeleteScenarioTest
import com.google.jetpackcamera.utils.runMainActivityScenarioTest
import com.google.jetpackcamera.utils.setFlashMode
import com.google.jetpackcamera.utils.waitForCaptureButton
import com.google.jetpackcamera.utils.waitForNodeWithTag
import org.junit.Before
import org.junit.Rule
Expand All @@ -72,39 +71,31 @@ internal class FlashDeviceTest {
@Test
fun set_flash_on() = runMainActivityScenarioTest {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

composeTestRule.setFlashMode(FlashMode.ON)
}

@Test
fun set_flash_auto() = runMainActivityScenarioTest {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

composeTestRule.setFlashMode(FlashMode.AUTO)
}

@Test
fun set_flash_off() = runMainActivityScenarioTest {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

composeTestRule.setFlashMode(FlashMode.OFF)
}

@Test
fun set_flash_low_light_boost() = runMainActivityScenarioTest {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

composeTestRule.setFlashMode(FlashMode.LOW_LIGHT_BOOST)
}
Expand All @@ -124,9 +115,7 @@ internal class FlashDeviceTest {
assumeHalStableOnImageCapture()

// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

// Ensure camera has a back camera and flip to it
val lensFacing = composeTestRule.getCurrentLensFacing()
Expand All @@ -152,9 +141,7 @@ internal class FlashDeviceTest {
filePrefix = "JCA"
) {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

// Ensure camera has a front camera and flip to it
val lensFacing = composeTestRule.getCurrentLensFacing()
Expand Down Expand Up @@ -195,9 +182,7 @@ internal class FlashDeviceTest {
mediaUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI
) {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

// Ensure camera has the target lens facing camera and flip to it
val lensFacing = composeTestRule.getCurrentLensFacing()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import com.google.jetpackcamera.ui.components.capture.CAPTURE_BUTTON
import com.google.jetpackcamera.ui.components.capture.IMAGE_CAPTURE_FAILURE_TAG
import com.google.jetpackcamera.ui.components.capture.IMAGE_CAPTURE_SUCCESS_TAG
import com.google.jetpackcamera.ui.components.capture.VIDEO_CAPTURE_EXTERNAL_UNSUPPORTED_TAG
import com.google.jetpackcamera.utils.APP_START_TIMEOUT_MILLIS
import com.google.jetpackcamera.utils.CacheParam
import com.google.jetpackcamera.utils.FILE_PREFIX
import com.google.jetpackcamera.utils.IMAGE_CAPTURE_TIMEOUT_MILLIS
Expand All @@ -55,6 +54,7 @@ import com.google.jetpackcamera.utils.getTestUri
import com.google.jetpackcamera.utils.longClickForVideoRecording
import com.google.jetpackcamera.utils.runMainActivityMediaStoreAutoDeleteScenarioTest
import com.google.jetpackcamera.utils.runMainActivityScenarioTestForResult
import com.google.jetpackcamera.utils.waitForCaptureButton
import com.google.jetpackcamera.utils.waitForNodeWithTag
import com.google.testing.junit.testparameterinjector.TestParameter
import com.google.testing.junit.testparameterinjector.TestParameterInjector
Expand Down Expand Up @@ -87,9 +87,7 @@ internal class ImageCaptureDeviceTest {
extras = cacheParam.extras
) {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

composeTestRule.onNodeWithTag(CAPTURE_BUTTON)
.assertExists()
Expand All @@ -107,9 +105,7 @@ internal class ImageCaptureDeviceTest {

) {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

uiDevice.pressKeyCode(KeyEvent.KEYCODE_VOLUME_UP)

Expand All @@ -125,9 +121,7 @@ internal class ImageCaptureDeviceTest {

) {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()
uiDevice.pressKeyCode(KeyEvent.KEYCODE_VOLUME_DOWN)

verifyImageCaptureSuccess()
Expand All @@ -143,9 +137,7 @@ internal class ImageCaptureDeviceTest {
extras = cacheParam.extras
) {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

composeTestRule.onNodeWithTag(CAPTURE_BUTTON)
.assertExists()
Expand All @@ -170,9 +162,7 @@ internal class ImageCaptureDeviceTest {

) {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

composeTestRule.onNodeWithTag(CAPTURE_BUTTON)
.assertExists()
Expand All @@ -199,9 +189,7 @@ internal class ImageCaptureDeviceTest {

) {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

composeTestRule.longClickForVideoRecording()

Expand Down Expand Up @@ -233,9 +221,7 @@ internal class ImageCaptureDeviceTest {
extras = cacheParam.extras
) {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()
repeat(2) {
clickCaptureAndWaitUntilMessageDisappears(
IMAGE_CAPTURE_TIMEOUT_MILLIS,
Expand Down Expand Up @@ -263,9 +249,7 @@ internal class ImageCaptureDeviceTest {

) {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()
repeat(2) {
clickCaptureAndWaitUntilMessageDisappears(
IMAGE_CAPTURE_TIMEOUT_MILLIS,
Expand All @@ -289,9 +273,7 @@ internal class ImageCaptureDeviceTest {

) {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()
uiDevice.pressBack()
}
Truth.assertThat(result.resultCode).isEqualTo(Activity.RESULT_CANCELED)
Expand All @@ -313,9 +295,7 @@ internal class ImageCaptureDeviceTest {

) {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()
clickCaptureAndWaitUntilMessageDisappears(
IMAGE_CAPTURE_TIMEOUT_MILLIS,
IMAGE_CAPTURE_FAILURE_TAG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.google.jetpackcamera

import androidx.compose.ui.test.isDisplayed
import androidx.compose.ui.test.isEnabled
import androidx.compose.ui.test.junit4.createEmptyComposeRule
import androidx.compose.ui.test.onNodeWithTag
Expand All @@ -33,13 +32,13 @@ import com.google.jetpackcamera.ui.components.capture.QUICK_SETTINGS_DROP_DOWN
import com.google.jetpackcamera.ui.components.capture.QUICK_SETTINGS_RATIO_1_1_BUTTON
import com.google.jetpackcamera.ui.components.capture.QUICK_SETTINGS_RATIO_BUTTON
import com.google.jetpackcamera.ui.components.capture.SETTINGS_BUTTON
import com.google.jetpackcamera.utils.APP_START_TIMEOUT_MILLIS
import com.google.jetpackcamera.utils.DEFAULT_TIMEOUT_MILLIS
import com.google.jetpackcamera.utils.TEST_REQUIRED_PERMISSIONS
import com.google.jetpackcamera.utils.assume
import com.google.jetpackcamera.utils.onNodeWithText
import com.google.jetpackcamera.utils.runMainActivityScenarioTest
import com.google.jetpackcamera.utils.searchForQuickSetting
import com.google.jetpackcamera.utils.waitForCaptureButton
import com.google.jetpackcamera.utils.waitForNodeWithTag
import com.google.jetpackcamera.utils.waitForNodeWithTagToDisappear
import org.junit.Rule
Expand All @@ -61,9 +60,7 @@ class NavigationTest {
@Test
fun backAfterReturnFromSettings_doesNotReturnToSettings() = runMainActivityScenarioTest {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

// open quick settings
composeTestRule.onNodeWithTag(QUICK_SETTINGS_DROP_DOWN).assertExists().performClick()
Expand Down Expand Up @@ -97,9 +94,7 @@ class NavigationTest {
@Test
fun returnFromSettings_afterFlipCamera_returnsToPreview() = runMainActivityScenarioTest {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

// If flipping the camera is available, flip it. Otherwise skip test.
composeTestRule.onNodeWithTag(FLIP_CAMERA_BUTTON)
Expand Down Expand Up @@ -132,9 +127,7 @@ class NavigationTest {
@Test
fun backFromQuickSettings_returnToPreview() = runMainActivityScenarioTest {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

// Navigate to the quick settings screen
composeTestRule.onNodeWithTag(QUICK_SETTINGS_DROP_DOWN)
Expand All @@ -154,9 +147,7 @@ class NavigationTest {
@Test
fun backFromQuickSettingsExpended_returnToQuickSettings() = runMainActivityScenarioTest {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

// Navigate to the quick settings screen
composeTestRule.onNodeWithTag(QUICK_SETTINGS_DROP_DOWN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ class PermissionsTest {
@Test
fun allPermissions_alreadyGranted_screenNotShown() {
runMainActivityScenarioTest {
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,13 @@ import com.google.jetpackcamera.settings.ui.BTN_OPEN_DIALOG_SETTING_STREAM_CONFI
import com.google.jetpackcamera.settings.ui.BTN_OPEN_DIALOG_SETTING_VIDEO_DURATION_TAG
import com.google.jetpackcamera.settings.ui.BTN_OPEN_DIALOG_SETTING_VIDEO_QUALITY_TAG
import com.google.jetpackcamera.settings.ui.BTN_OPEN_DIALOG_SETTING_VIDEO_STABILIZATION_TAG
import com.google.jetpackcamera.ui.components.capture.CAPTURE_BUTTON
import com.google.jetpackcamera.utils.APP_START_TIMEOUT_MILLIS
import com.google.jetpackcamera.utils.DEFAULT_TIMEOUT_MILLIS
import com.google.jetpackcamera.utils.TEST_REQUIRED_PERMISSIONS
import com.google.jetpackcamera.utils.runMainActivityScenarioTest
import com.google.jetpackcamera.utils.selectLensFacing
import com.google.jetpackcamera.utils.visitSettingDialog
import com.google.jetpackcamera.utils.visitSettingsScreen
import com.google.jetpackcamera.utils.waitForCaptureButton
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -105,9 +104,7 @@ class SettingsDeviceTest(private val lensFacing: LensFacing) {
action: ComposeTestRule.() -> Unit
): Unit = runMainActivityScenarioTest {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()

composeTestRule.visitSettingsScreen {
// Ensure appropriate lens facing is selected
Expand Down
Loading
Loading