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 @@ -34,7 +34,6 @@ import com.google.jetpackcamera.feature.postcapture.ui.VIEWER_POST_CAPTURE_IMAGE
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.utils.APP_START_TIMEOUT_MILLIS
import com.google.jetpackcamera.utils.IMAGE_CAPTURE_TIMEOUT_MILLIS
import com.google.jetpackcamera.utils.IMAGE_PREFIX
import com.google.jetpackcamera.utils.MESSAGE_DISAPPEAR_TIMEOUT_MILLIS
Expand Down Expand Up @@ -101,9 +100,7 @@ class CachedImageCaptureDeviceTest {
cacheExtra
) {
// 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 @@ -127,9 +124,7 @@ class CachedImageCaptureDeviceTest {
cacheExtra
) {
// 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 Down Expand Up @@ -162,9 +157,7 @@ class CachedImageCaptureDeviceTest {
cacheExtra
) {
// 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 @@ -191,9 +184,7 @@ class CachedImageCaptureDeviceTest {
cacheExtra
) {
// 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 @@ -219,9 +210,7 @@ class CachedImageCaptureDeviceTest {
cacheExtra
) {
// 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 @@ -242,9 +231,7 @@ class CachedImageCaptureDeviceTest {
cacheExtra
) {
// 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 @@ -18,7 +18,6 @@ package com.google.jetpackcamera
import android.app.Activity
import android.net.Uri
import android.provider.MediaStore
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 @@ -29,9 +28,7 @@ import androidx.test.uiautomator.UiDevice
import com.google.common.truth.Truth
import com.google.jetpackcamera.feature.postcapture.ui.BUTTON_POST_CAPTURE_EXIT
import com.google.jetpackcamera.feature.postcapture.ui.VIEWER_POST_CAPTURE_VIDEO
import com.google.jetpackcamera.ui.components.capture.CAPTURE_BUTTON
import com.google.jetpackcamera.ui.components.capture.VIDEO_CAPTURE_FAILURE_TAG
import com.google.jetpackcamera.utils.APP_START_TIMEOUT_MILLIS
import com.google.jetpackcamera.utils.MOVIES_DIR_PATH
import com.google.jetpackcamera.utils.TEST_REQUIRED_PERMISSIONS
import com.google.jetpackcamera.utils.VIDEO_CAPTURE_TIMEOUT_MILLIS
Expand Down Expand Up @@ -92,9 +89,7 @@ class CachedVideoRecordingDeviceTest {
cacheExtra
) {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()
composeTestRule.longClickForVideoRecordingCheckingElapsedTime()
}
Truth.assertThat(result.resultCode).isEqualTo(Activity.RESULT_OK)
Expand All @@ -110,9 +105,7 @@ class CachedVideoRecordingDeviceTest {
getSingleImageCaptureIntent(uri, MediaStore.ACTION_VIDEO_CAPTURE)
) {
// Wait for the capture button to be displayed
composeTestRule.waitUntil(timeoutMillis = APP_START_TIMEOUT_MILLIS) {
composeTestRule.onNodeWithTag(CAPTURE_BUTTON).isDisplayed()
}
composeTestRule.waitForCaptureButton()
composeTestRule.longClickForVideoRecording()
composeTestRule.waitForNodeWithTag(
VIDEO_CAPTURE_FAILURE_TAG,
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
Loading
Loading