Skip to content

Conversation

@AndriiFilippov
Copy link
Collaborator

@AndriiFilippov AndriiFilippov commented Sep 25, 2025

Description

Some SWT tests were constantly failing due to incorrect main shell size.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

  • Tests
    • UI automation now initializes the app window in a maximized/fullscreen state before running UI steps.
    • This initialization runs across Windows, macOS, and Linux to improve stability and consistency of UI tests.
    • Fullscreen attempts are non-blocking and failures are handled gracefully so tests continue.
    • Change is limited to test setup and has no impact on application behavior for end-users.

@coderabbitai
Copy link

coderabbitai bot commented Sep 25, 2025

Walkthrough

Adds a SWT UI-thread init that obtains the active workbench shell, maximizes it, and attempts to set fullscreen (exceptions ignored) before proceeding with existing Welcome view and UI automation steps. No changes to method signatures or return values.

Changes

Cohort / File(s) Summary
UI test env setup initialization
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/EnvSetupOperations.java
Added Display.syncExec block to fetch the active workbench shell, call setMaximized(true) and attempt setFullScreen(true) inside a try/catch; added SWT/Eclipse imports; preserved existing Welcome-view opening and subsequent UI steps.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant TestRunner as Test Runner
  participant SWT as SWT UI Thread
  participant WB as Workbench
  participant Shell as Shell

  TestRunner->>SWT: Display.syncExec(init)
  SWT->>WB: PlatformUI.getWorkbench().getActiveWorkbenchWindow()
  WB-->>SWT: ActiveWorkbenchWindow
  SWT->>Shell: getShell()
  SWT->>Shell: setMaximized(true)
  alt fullscreen supported
    SWT->>Shell: try setFullScreen(true)
  else unsupported/error
    Note right of Shell: exception caught and ignored
  end
  SWT-->>TestRunner: UI initialized
  TestRunner->>WB: continue to open Welcome view and run UI automation
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • alirana01
  • sigmaaa

Poem

I hop onto the workspace, stretch and gleam,
Maximize the shell to chase the beam.
Fullscreen tried — if it fails, no scream,
Welcome opens next, a tester's dream. 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly conveys the primary change of enabling full screen on the test runner’s main shell, matching the detailed modifications to the EnvSetupOperations UI initialization block without irrelevant details.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_runners_set_FullScreen_test_shell

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 233d6b3 and c465cdc.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/EnvSetupOperations.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build_windows
  • GitHub Check: build_macos
  • GitHub Check: build
🔇 Additional comments (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/EnvSetupOperations.java (1)

29-36: Guard against missing workbench window before toggling fullscreen

PlatformUI.getWorkbench().getActiveWorkbenchWindow() can return null (and window.getShell() can be null/disposed) during startup, so this block will NPE and kill the test run. Bail out when the display/window/shell isn’t ready before calling setMaximized/setFullScreen.

-		Display.getDefault().syncExec(() -> {
-			Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+		Display display = Display.getDefault();
+		if (display == null)
+			return;
+		display.syncExec(() -> {
+			IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+			if (window == null)
+				return;
+			Shell shell = window.getShell();
+			if (shell == null || shell.isDisposed())
+				return;
 			// Maximize (Windows/Linux/macOS windowed)
 			shell.setMaximized(true);
 			try
 			{
 				shell.setFullScreen(true);

Remember to add import org.eclipse.ui.IWorkbenchWindow;.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba30dd4 and 233d6b3.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/EnvSetupOperations.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_macos

Comment on lines 30 to 37
Display.getDefault().syncExec(() -> {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
// Maximize (Windows/Linux/macOS windowed)
shell.setMaximized(true);
if (Platform.OS_WIN32.equals(Platform.getOS()) || Platform.OS_LINUX.equals(Platform.getOS()) || Platform.OS_MACOSX.equals(Platform.getOS())) {
try { shell.setFullScreen(true); } catch (Throwable ignore) {}
}
});
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Guard against missing workbench window before toggling fullscreen

PlatformUI.getWorkbench().getActiveWorkbenchWindow() can be null during startup (or if the window is closing), which will crash this setup with an NPE before the tests even get a chance to run. Please bail out gracefully when the display/window/shell aren’t ready yet.

Apply this diff to harden the block:

-		Display.getDefault().syncExec(() -> {
-		      Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
-		      // Maximize (Windows/Linux/macOS windowed)
-		      shell.setMaximized(true);
-		      if (Platform.OS_WIN32.equals(Platform.getOS()) || Platform.OS_LINUX.equals(Platform.getOS()) || Platform.OS_MACOSX.equals(Platform.getOS())) {
-		        try { shell.setFullScreen(true); } catch (Throwable ignore) {}
-		      }
-		    });
+		Display display = Display.getDefault();
+		if (display == null)
+			return;
+		display.syncExec(() -> {
+			IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+			if (window == null)
+				return;
+			Shell shell = window.getShell();
+			if (shell == null || shell.isDisposed())
+				return;
+			// Maximize (Windows/Linux/macOS windowed)
+			shell.setMaximized(true);
+			if (Platform.OS_WIN32.equals(Platform.getOS()) || Platform.OS_LINUX.equals(Platform.getOS())
+					|| Platform.OS_MACOSX.equals(Platform.getOS())) {
+				try {
+					shell.setFullScreen(true);
+				}
+				catch (Throwable ignore) {
+				}
+			}
+		});

Add the missing import alongside the other Eclipse UI imports:

 import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;

Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
// Maximize (Windows/Linux/macOS windowed)
shell.setMaximized(true);
if (Platform.OS_WIN32.equals(Platform.getOS()) || Platform.OS_LINUX.equals(Platform.getOS()) || Platform.OS_MACOSX.equals(Platform.getOS())) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can avoid this since there are all OS from the Platform mentioned in the condition

Copy link
Collaborator

@sigmaaa sigmaaa left a comment

Choose a reason for hiding this comment

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

LGTM!

@AndriiFilippov AndriiFilippov merged commit 410f4d5 into master Sep 26, 2025
6 checks passed
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.

3 participants