Return future isActive and isVisible info once related func is triggered [chromium/src : main]

0 views
Skip to first unread message

Lijin Shen (Gerrit)

unread,
1:26 PM (6 hours ago) 1:26 PM
to Chromium LUCI CQ, Aishwarya Rajesh, Linyu He, chromium...@chromium.org
Attention needed from Linyu He

Lijin Shen voted and added 17 comments

Votes added by Lijin Shen

Commit-Queue+1

17 comments

Commit Message
Line 7, Patchset 12:Return future isActive info as soon as activate/show is triggered
Linyu He . resolved

`isActive` --> `isActive and isVisible`?

Lijin Shen

Done

Line 12, Patchset 12:This CL makes the isActive temporarily return true when activate/show is
Linyu He . resolved

ditto: update description to be consistent with the code changes.

Lijin Shen

Done

File chrome/browser/ui/browser_window/internal/android/java/src/org/chromium/chrome/browser/ui/browser_window/ChromeAndroidTaskImpl.java
File-level comment, Patchset 12:
Linyu He . unresolved

Can we add unit tests for the new changes?

Lijin Shen

I was thinking the changes in IntergrationsTest have already covered the changes.

Do you mean it would better to add more unit tests in ChromeAndroidTaskImplUnitTest.java?

Line 335, Patchset 12: } else if (mState.get() == State.PENDING_UPDATE
&& mPendingActionManager.isActionRequested(PendingAction.MAXIMIZE)) {
return true;
Linyu He . resolved

Can we move this part to a subsequent CL to focus on `isActivate` and `isVisible` in this CL?

Lijin Shen

Done

Line 353, Patchset 12: } else if (mState.get() == State.PENDING_UPDATE
&& mPendingActionManager.isActionRequested(PendingAction.MINIMIZE)) {
return true;
Linyu He . resolved

ditto: move this part to a separate CL focusing on `isMaximized()`/`isMinimized()`?

Lijin Shen

Done

Line 367, Patchset 12: if (mState.get() == State.PENDING_CREATE || mState.get() == State.PENDING_UPDATE) {
Linyu He . resolved

ditto: move this to a separate CL, too.

Lijin Shen

Done

File chrome/browser/ui/browser_window/internal/android/java/src/org/chromium/chrome/browser/ui/browser_window/ChromeAndroidTaskIntegrationTest.java
File-level comment, Patchset 12:
Linyu He . resolved

Besides integration tests, let's also do some manual testing using the test extension:
(1) `update()` returns the updated state (the future state);
(2) wait for the update operation to complete, then `get()` returns the live state;
(3) change the window state without using the test extension, then `get()` still returns the correct live state.

Lijin Shen
Line 197, Patchset 12: CriteriaHelper.pollUiThread(
assumeNonNull(webPageStation.getActivity().getWindowAndroid())
::isTopResumedActivity);
Linyu He . resolved

I think `ExtensionWindowControllerBridgeIntegrationTest` will need similar fixes.

Lijin Shen

it seems good now. No activate or show operation is involved in that test.

Line 286, Patchset 12: CriteriaHelper.pollUiThread(
Linyu He . resolved

Before `pollUiThread`, we can check `chromeAndroidTask.isActive()` returns true (the future state).

Then after `pollUiThread`, let's check that again (the live state).

Lijin Shen

Done

Line 317, Patchset 12: CriteriaHelper.pollUiThread(
assumeNonNull(webPageStation.getActivity().getWindowAndroid())
::isTopResumedActivity);
Linyu He . resolved

Same here: let's check both the future state and the live state before and after `pollUiThread`.

Lijin Shen

Done

Line 351, Patchset 12: CriteriaHelper.pollUiThread(() -> !secondChromeAndroidTask.isActive());
Linyu He . resolved

Do we need `pollUiThread` at line 351?

Also, ditto: check both the future state and the live state.

Lijin Shen

Done

File chrome/browser/ui/browser_window/internal/android/java/src/org/chromium/chrome/browser/ui/browser_window/PendingActionManager.java
File-level comment, Patchset 12:
Linyu He . resolved

We need unit tests for the new APIs in `PendingActionManager`:

  • `isActive()`
  • `isVisible()`
  • `getAndClearTargetPendingActions()`
Lijin Shen

Done

Line 99, Patchset 12: private @Nullable Boolean mIsActive;
Linyu He . resolved

(1) To clearly indicate it's a predicted state based on pending actions, let's rename `mIsActive` as `mIsActiveFuture`. (Same for other states.)

(2) Each of the future states should be `@GuardedBy("mPendingActionsLock")`.

(3) Document what `null` means. You can remove line 98 and document this in the Java doc of `isActive()` and `isVisible()`, which would be clearer to callers.

Lijin Shen

Done

Line 180, Patchset 12: @Nullable Boolean isActive() {
Linyu He . resolved
* ditto - rename: `isActive()` -> `isActiveFuture()`
* Add Java doc to explain:
* The returned value is a predicted future state based on pending actions;
* What it means when `null` is returned.

(Same for `isVisible()` below.)

Lijin Shen

Done

Line 182, Patchset 12: if (mIsClosed != null) return false;
Linyu He . resolved

Can we set `mIsActive` to `false` when there is `PendingAction.CLOSE`?

This way we can remove the `mIsClosed` state and simplify `isActive()` and `updatePendingStates()` (one fewer state to deal with).

(Same for `isVisible()` below.)

Lijin Shen

My understanding was that the close has a very high priority. Calling close then activate still results in isActive being true. Does this make sense to you?

Linyu He

I see. @aishw...@google.com and I discussed this in a separate CL, and the conclusion is that because "close" has a very high (actually the highest) priority, any subsequent actions should be ignored as we can't revive a destroyed window.

For `close` -> `activate`: `activate` should have no effect and `isActive()` should be `false` (window is destroyed).

If everything were synchronous, calling `activate()` after `close()` would be banned (app crashes).

Lijin Shen

Done

Line 325, Patchset 12: private void updatePendingStates() {
Linyu He . resolved

nit - rename: `updatePendingStates()` -> `updateFutureStatesLocked()`

* We need to differentiate between "pending" and "future" in this class.
* "Pending": a request this class has received but not yet fulfilled.
* "Future": a predicted result based on "pending" requests.
  • `*Locked()`: the method is `@GuardedBy` a lock.
Lijin Shen

Done

Line 327, Patchset 12: if (action == PendingAction.CLOSE) mIsClosed = true;
Linyu He . resolved

Following the comment for `isActive()` above: let's try removing `mIsClosed`.

```
switch (action) {
//...

case PendingAction.CLOSE: // <-- new
mIsActive = false;
break;
default:
break;
}
```

(Same for `mIsVisible` below.)

Lijin Shen

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Linyu He
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ida63168a57cf8a262d989ee1e161e4c172273481
Gerrit-Change-Number: 7027658
Gerrit-PatchSet: 15
Gerrit-Owner: Lijin Shen <laz...@google.com>
Gerrit-Reviewer: Lijin Shen <laz...@google.com>
Gerrit-Reviewer: Linyu He <lin...@google.com>
Gerrit-CC: Aishwarya Rajesh <aishw...@google.com>
Gerrit-Attention: Linyu He <lin...@google.com>
Gerrit-Comment-Date: Mon, 20 Oct 2025 17:26:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Lijin Shen <laz...@google.com>
Comment-In-Reply-To: Linyu He <lin...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Linyu He (Gerrit)

unread,
4:26 PM (3 hours ago) 4:26 PM
to Lijin Shen, Chromium LUCI CQ, Aishwarya Rajesh, chromium...@chromium.org
Attention needed from Lijin Shen

Linyu He added 8 comments

Patchset-level comments
File-level comment, Patchset 15 (Latest):
Linyu He . resolved

LGTM % (minor comments)

Commit Message
Line 12, Patchset 15 (Latest):This CL makes the isActive and is Visible temporarily return true when
Linyu He . unresolved

nit:

```suggestion
This CL makes isActive() and isVisible() temporarily return true when
```

File chrome/browser/ui/browser_window/internal/android/java/src/org/chromium/chrome/browser/ui/browser_window/ChromeAndroidTaskImpl.java
Linyu He . unresolved

Can we add unit tests for the new changes?

Lijin Shen

I was thinking the changes in IntergrationsTest have already covered the changes.

Do you mean it would better to add more unit tests in ChromeAndroidTaskImplUnitTest.java?

Linyu He

I was thinking the changes in IntergrationsTest have already covered the changes.

That's correct, but please see the reply below.


> Do you mean it would better to add more unit tests in ChromeAndroidTaskImplUnitTest.java?

Yes, `ChromeAndroidTaskIntegrationTest` is in CI so it won't be run by default (we know it needs to be run; folks not working on this project don't). Based on my gardening experience, when CI fails, it would take longer to identify and fix an issue.

So we'll use unit tests as quick sanity checks, similar to [these existing unit tests](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/browser_window/internal/android/java/src/org/chromium/chrome/browser/ui/browser_window/ChromeAndroidTaskImplUnitTest.java;l=1193,1204,1217;drc=b5a0fa6584b0931f30f672d3f877bb4833d107b9).

Usually when practically feasible, we add both unit tests and integration tests.

[ Note: we need to be clear what `_whenPending_` means in the test names now, i.e., existing tests should have `_whenPendingCreate_` and new ones are `_whenPendingUpdate_`. ]

File chrome/browser/ui/browser_window/internal/android/java/src/org/chromium/chrome/browser/ui/browser_window/ChromeAndroidTaskIntegrationTest.java
Line 328, Patchset 15 (Latest): "Activate should make isActive true immediately", chromeAndroidTask.isActive());
Linyu He . unresolved
```suggestion
"Show() should make isActive true immediately", chromeAndroidTask.isActive());
```
Line 333, Patchset 15 (Latest): "Activate should make isActive true eventually", chromeAndroidTask.isActive());
Linyu He . unresolved
```suggestion
"Show() should make isActive true eventually", chromeAndroidTask.isActive());
```
Line 344, Patchset 15 (Latest): /*WebPageStation webPageStation = mFreshCtaTransitTestRule.startOnBlankPage();
Linyu He . unresolved

Uncomment this? :)

Line 362, Patchset 15 (Latest): Assert.assertTrue(
"Activate should make isActive true immediately", chromeAndroidTask.isActive());
CriteriaHelper.pollUiThread(
assumeNonNull(webPageStation.getActivity().getWindowAndroid())
::isTopResumedActivity);
Assert.assertTrue(
"Activate should make isActive true eventually", chromeAndroidTask.isActive());
CriteriaHelper.pollUiThread(() -> !secondChromeAndroidTask.isActive());
Linyu He . unresolved

As `showInactive()` is the method under test here, I think this part should be:

```
Assert.assertFalse(
"ShowInactive should make isActive() false immediately",
secondChromeAndroidTask.isActive());
// Wait for the first Task to become active.
CriteriaHelper.pollUiThread(
assumeNonNull(webPageStation.getActivity().getWindowAndroid())
::isTopResumedActivity);
Assert.assertFalse(
"ShowInactive should make isActive() false eventually",
secondChromeAndroidTask.isActive());
```
Line 396, Patchset 15 (Latest): Assert.assertTrue(
"Activate should make isActive true immediately", chromeAndroidTask.isActive());
CriteriaHelper.pollUiThread(
assumeNonNull(webPageStation.getActivity().getWindowAndroid())
::isTopResumedActivity);
Assert.assertTrue(
"Activate should make isActive true eventually", chromeAndroidTask.isActive());
assertFalse(secondChromeAndroidTask.isActive());
Linyu He . unresolved

Same here, we are testing `deactivate()` for `secondChromeAndroidTask`:

```
Assert.assertFalse(
"Deactivate() should make isActive() false immediately",
secondChromeAndroidTask.isActive());
// Wait for the first Task to become active, which completes the deactivation
// of the second Task.
CriteriaHelper.pollUiThread(
assumeNonNull(webpageStation.getActivity().getWindowAndroid())
::isTopResumedActivity);
Assert.assertFalse(
"Deactivate() should make isActive() false eventually",
secondChromeAndroidTask.isActive());
```
Open in Gerrit

Related details

Attention is currently required from:
  • Lijin Shen
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ida63168a57cf8a262d989ee1e161e4c172273481
Gerrit-Change-Number: 7027658
Gerrit-PatchSet: 15
Gerrit-Owner: Lijin Shen <laz...@google.com>
Gerrit-Reviewer: Lijin Shen <laz...@google.com>
Gerrit-Reviewer: Linyu He <lin...@google.com>
Gerrit-CC: Aishwarya Rajesh <aishw...@google.com>
Gerrit-Attention: Lijin Shen <laz...@google.com>
Gerrit-Comment-Date: Mon, 20 Oct 2025 20:26:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages