Skip to content

Fix existing integration test#8854

Merged
helin24 merged 2 commits into
flutter:mainfrom
helin24:integration3
Mar 17, 2026
Merged

Fix existing integration test#8854
helin24 merged 2 commits into
flutter:mainfrom
helin24:integration3

Conversation

@helin24
Copy link
Copy Markdown
Member

@helin24 helin24 commented Mar 16, 2026

The isVisible function was not found; I expect maybe it was from a previous version of dependencies or something. I also specified ms between text input because it feels very slow. I don't see an option to just paste with the keyboard but maybe that exists elsewhere.

@helin24 helin24 requested a review from pq March 16, 2026 23:13
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes an integration test by updating a call from isVisible() to present() and speeds up text input by reducing the delay between characters. This is a good improvement for test stability and speed. Regarding your question about pasting text, it is indeed possible and would be faster. You can achieve this by using driver.utility(RobotService::class).copyToClipboard(text) to place text on the clipboard, and then simulating a paste with keyboard.hotKey(...) using the appropriate keyboard shortcut for the OS (e.g., Cmd+V on macOS).

Comment thread testSrc/integration/io/flutter/integrationTest/utils/NewProject.kt Outdated
@helin24 helin24 removed the request for review from pq March 16, 2026 23:14
@helin24
Copy link
Copy Markdown
Member Author

helin24 commented Mar 16, 2026

@gemini-code-assist is there a way to copy and paste without being platform-specific?

@gemini-code-assist
Copy link
Copy Markdown
Contributor

That's a great question, helin24! Achieving truly platform-agnostic copy-paste functionality in UI automation can indeed be challenging due to differences in operating system clipboard mechanisms and UI frameworks.

When dealing with UI automation, especially for desktop applications or IDEs, direct "paste" actions often rely on simulating keyboard shortcuts (like Ctrl+V on Windows/Linux or Cmd+V on macOS) or interacting with a platform-specific clipboard API. The challenge arises because these shortcuts and APIs differ across platforms.

Here are a few common approaches and considerations:

  1. Direct Text Input (as you're doing with typeText): This is often the most reliable method for entering text, as it simulates typing character by character. However, as you noted, it can be slow for large amounts of text. The typeText(testProjectName, 60) change you made is a good step to control the typing speed, which can help with stability in some UI automation scenarios.

  2. Simulating Paste Keyboard Shortcuts:

    • You could try to simulate the platform-specific paste shortcut. For example, in a test framework, this might look like keyboard.press(Modifier.CONTROL).typeText("v").release(Modifier.CONTROL) (or Modifier.META for Cmd on Mac). The downside is that your test code would need to be aware of the operating system it's running on to choose the correct modifier key, making it less platform-agnostic at the test code level.
    • This approach also assumes the target UI element correctly handles the paste event.
  3. Setting Text Directly (if the UI element allows): Some UI automation frameworks or underlying UI component APIs allow you to directly set the text content of an input field without simulating keyboard events. This would be the most robust and fastest method if available. You would typically look for a method like setText() or setValue() on the UI element object provided by your automation driver. This bypasses both typing simulation and clipboard interaction.

  4. Using a Clipboard API (if the testing environment provides one): If your testing environment or the application under test exposes a way to programmatically set the system clipboard content, you could use that in conjunction with a simulated paste command. This is less common for general UI automation but might exist in specialized testing tools.

Given your current setup, continuing to use typeText with a controlled speed is a reasonable and often necessary compromise when a direct setText equivalent isn't readily available or reliable across all target platforms. If the keyboard object in your run.driver.withContext block offers a more direct paste method that handles platform differences internally, that would be ideal. Otherwise, explicitly handling platform-specific paste shortcuts might be the next step if typeText remains too slow or problematic for certain test cases.

…t.kt

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@helin24 helin24 requested a review from pq March 16, 2026 23:21
@pq
Copy link
Copy Markdown
Collaborator

pq commented Mar 16, 2026

(FWIW: I think direct text input will be more robust than copy-paste. It is super slow though!)

@helin24 helin24 merged commit 8882791 into flutter:main Mar 17, 2026
8 checks passed
@helin24 helin24 deleted the integration3 branch March 17, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants