Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit caea4468 authored by Saho Kobayashi's avatar Saho Kobayashi Committed by Yuexi Ma
Browse files

[AI TestGen]

Test: Add tests for containsClosingTaskInDesktop

Add unit tests for the negative paths of the `containsClosingTaskInDesktop`
method. This method is called from `onTransitionReady` to determine if a
pending mixed transition for a closing task should be added.

The new tests cover scenarios where:
- The display exits desktop mode after closing task.
- A closing task is not in freeform windowing mode.
- The transition does not involve a closing task.

In all these cases, a pending transition should not be added. This
improves test coverage for the specified logic.


This change adds additional test coverage for ag/ based on change: 34451170
Target source file: libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt.
Estimated delta line test coverage for source file: before=0.8, after=0.917

Flag: TEST_ONLY
Test: atest libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserverTest.kt (passed locally)
Bug: 431235865

*****************************************************
The following part will be removed before submitting.
*****************************************************

**Caution:** This CL is generated by AI.
Submit only after human reviewing.
Please help us improve by commenting on the CL.

Test logic explanation:
-----------------------

The user wants to add tests for the `containsClosingTaskInDesktop` method and its usage within `onTransitionReady`.

The existing test `onTransitionReady_noTransitionInHandler_addPendingMixedTransition` already covers the positive case where `containsClosingTaskInDesktop` returns `true`, leading to a call to `desktopMixedTransitionHandler.addPendingMixedTransition`.

However, there are no tests for the negative cases, where `containsClosingTaskInDesktop` returns `false` and `addPendingMixedTransition` should *not* be called.

To address this, I've added three new tests to cover the main conditions within `containsClosingTaskInDesktop` that would cause it to return `false`:

1.  `onTransitionReady_closingTaskNotInDesktop_notAddPendingMixedTransition`: This test simulates a scenario where a freeform task is closing, but `taskRepository.isAnyDeskActive()` returns `false`. This causes `containsClosingTaskInDesktop` to return `false`.
2.  `onTransitionReady_closingTaskNotFreeform_notAddPendingMixedTransition`: This test covers the case where a task is closing on an active desktop, but its windowing mode is not `WINDOWING_MODE_FREEFORM`. This also causes the method to return `false`.
3.  `onTransitionReady_notClosingTask_notAddPendingMixedTransition`: This test handles the situation where a transition occurs for a freeform task on an active desktop, but the transition mode is not `TRANSIT_CLOSE` (e.g., `TRANSIT_OPEN`).

For each of these new tests, the assertion verifies that `addPendingMixedTransition` is `never()` called, confirming the correct behavior for the negative paths. These additions provide more complete and meaningful test coverage for the specified code.

----

Corrected typo in the unit test name.

The test checks closing task **and** exit desktop case. Updated to the correct name.

Change-Id: I8293a4b971b069f93fadc85dd08497215ced59d7
parent f1bbd3a6
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment