-
Notifications
You must be signed in to change notification settings - Fork 66
fix debug screen zoom control bug #538
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
838050a
Follow API kdocs to address issue where the zoom entry dialog and oth…
Kimblebee 0f6d951
Merge branch 'main' into kim/clickable-interactionsource-bug
Kimblebee 1585213
address pr comments in ExternalAutomationCompatibilityTest.kt
Kimblebee 8c8cc96
Merge branch 'main' into kim/clickable-interactionsource-bug
Kimblebee a3dd173
address PR comments
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
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
132 changes: 132 additions & 0 deletions
132
app/src/androidTest/java/com/google/jetpackcamera/ExternalAutomationCompatibilityTest.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,132 @@ | ||
| /* | ||
| * 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 | ||
|
|
||
| import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
| import androidx.test.platform.app.InstrumentationRegistry | ||
| import androidx.test.rule.GrantPermissionRule | ||
| import androidx.test.uiautomator.By | ||
| import androidx.test.uiautomator.UiDevice | ||
| import androidx.test.uiautomator.Until | ||
| import com.google.common.truth.Truth.assertWithMessage | ||
| import com.google.jetpackcamera.ui.components.capture.CAPTURE_BUTTON | ||
| import com.google.jetpackcamera.ui.components.capture.FLIP_CAMERA_BUTTON | ||
| import com.google.jetpackcamera.ui.debug.DEBUG_OVERLAY_BUTTON | ||
| import com.google.jetpackcamera.ui.debug.DEBUG_OVERLAY_SET_ZOOM_RATIO_BUTTON | ||
| import com.google.jetpackcamera.ui.debug.DEBUG_OVERLAY_SET_ZOOM_RATIO_SET_BUTTON | ||
| import com.google.jetpackcamera.ui.debug.DEBUG_OVERLAY_SET_ZOOM_RATIO_TEXT_FIELD | ||
| 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.debugExtra | ||
| import com.google.jetpackcamera.utils.runMainActivityScenarioTest | ||
| import org.junit.After | ||
| import org.junit.Before | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
| import org.junit.runner.RunWith | ||
|
|
||
| @RunWith(AndroidJUnit4::class) | ||
| class ExternalAutomationCompatibilityTest { | ||
|
|
||
| @get:Rule | ||
| val permissionsRule: GrantPermissionRule = | ||
| GrantPermissionRule.grant(*(TEST_REQUIRED_PERMISSIONS).toTypedArray()) | ||
|
|
||
| private lateinit var device: UiDevice | ||
|
|
||
| @Before | ||
| fun setUp() { | ||
| device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | ||
| } | ||
|
|
||
| @After | ||
| fun tearDown() { | ||
| device.pressBack() | ||
| device.pressHome() | ||
| } | ||
|
|
||
| @Test | ||
| fun verifyUiAutomator_canFindCaptureControls() { | ||
| runMainActivityScenarioTest { | ||
| // Wait for the capture button to be visible to UI Automator via Resource ID | ||
| val captureButton = | ||
| device.wait( | ||
| Until.findObject(By.res(CAPTURE_BUTTON)), | ||
| APP_START_TIMEOUT_MILLIS | ||
| ) | ||
| assertWithMessage("Capture button not found by UI Automator via Resource ID") | ||
| .that(captureButton) | ||
| .isNotNull() | ||
|
|
||
| // Verify flip camera button is visible via Resource ID | ||
| val flipButton = device.findObject(By.res(FLIP_CAMERA_BUTTON)) | ||
| assertWithMessage("Flip camera button not found by UI Automator via Resource ID") | ||
| .that(flipButton) | ||
| .isNotNull() | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| fun verifyUiAutomator_canFindDebugOverlayControls() { | ||
| runMainActivityScenarioTest(debugExtra) { | ||
| // Verify debug overlay button is visible via Resource ID | ||
| val debugButton = device.wait( | ||
| Until.findObject(By.res(DEBUG_OVERLAY_BUTTON)), | ||
| APP_START_TIMEOUT_MILLIS | ||
| ) | ||
| assertWithMessage("Debug overlay button not found by UI Automator via Resource ID") | ||
| .that(debugButton) | ||
| .isNotNull() | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| fun verifyUiAutomator_canFindDebugZoomDialogControls() { | ||
| runMainActivityScenarioTest(debugExtra) { | ||
| // Open debug menu using UI Automator | ||
| val debugButton = device.wait( | ||
| Until.findObject(By.res(DEBUG_OVERLAY_BUTTON)), | ||
| APP_START_TIMEOUT_MILLIS | ||
| ) | ||
| assertWithMessage("Debug overlay button not found").that(debugButton).isNotNull() | ||
| debugButton.click() | ||
|
|
||
| // Click "Set Zoom Ratio" button using UI Automator | ||
| val setZoomButton = device.wait( | ||
| Until.findObject(By.res(DEBUG_OVERLAY_SET_ZOOM_RATIO_BUTTON)), | ||
| DEFAULT_TIMEOUT_MILLIS | ||
| ) | ||
| assertWithMessage("Set Zoom Ratio button not found").that(setZoomButton).isNotNull() | ||
| setZoomButton.click() | ||
|
|
||
| // Verify the zoom dialog text field is visible to UI Automator | ||
| val textField = device.wait( | ||
| Until.findObject(By.res(DEBUG_OVERLAY_SET_ZOOM_RATIO_TEXT_FIELD)), | ||
| DEFAULT_TIMEOUT_MILLIS | ||
| ) | ||
| assertWithMessage( | ||
| "Zoom text field not found by UI Automator" | ||
| ).that(textField).isNotNull() | ||
|
|
||
| // Verify the confirm button is visible to UI Automator | ||
| val confirmButton = device.findObject(By.res(DEBUG_OVERLAY_SET_ZOOM_RATIO_SET_BUTTON)) | ||
| assertWithMessage( | ||
| "Confirm button not found by UI Automator" | ||
| ).that(confirmButton).isNotNull() | ||
| } | ||
| } | ||
| } | ||
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.
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.