[Contextual Search] Revive 4 tests in ContextualSearchCriticalTest (redux).

This CL relands crrev.com/4637353 (reverted by crrev.com/4650737) while
incorporating crrev.com/4649959 and fixing the flake that caused the
revert.

The 4 disabled tests in ContextualSearchCriticalTest
  testChainedSearchCreatesNewContent
  testChainedSearchLoadsCorrectSearchTerm
  testChainedSearchContentVisibility
  testChainedTapsRemovedFromHistory

are the tests that make multiple calls to simulate{Non}ResolveSearch(),
i.e., try to open the panel when it is already open (peeked). For these
tests, 3 causes for failures were found:
 1. "Space issue": TapFarFromPreviousSuppression suppresses clicks that
    are >75 dp (see RETAP_DISTANCE_SQUARED_DP) away from the previous
    click. In test case with "Search Term Resolution", growing screen
    resolutions have made "Search" and "Resolution" so distant the
    suppression engages. Apparently this was perceived as a flake, and
    retryPanelBarInteractions() -- which makes more clicks -- was added
    to mitigate it. When combined with (2), (1) triggers assert failure:

Caused by: org.chromium.base.test.util.CriteriaNotSatisfiedException:
     Expected: is "Resolution"
     but: was null

    This issue affects:
      testChainedSearchLoadsCorrectSearchTerm_
      testChainedSearchContentVisibility

 2. "Time issue": ContextualSearchInstrumentationBase.clickWordNode()
    clicks on node#search, waits for the panel to peek, then clicks on
    node#resolution. However, the wait exits quickly because the panel
    is already peeked from the earlier click. This breaks the callers
    trigger{Non}Resolve(), which rely on the wait to temporarily tweak
    "decided" to a provided value. In particular, the non-resolved flow
    (tweak to false) on "Resolution" would behave as the resolved flow,
    leading to assertion errors from |mFakeServer.getLoadedUrlCount()|
    returning the wrong value.

 3. ContextualSearchInstrumentationBase.swipePanelDown() is not robust,
    and swipes sometimes to fail to transit ContextualSearchPanel state
    from EXPANDED to PEEKED. This in turn seems to be caused by passing
    to swipe() |stepCount| = 100, which is too small.

This CL fixes the above, and revives the 4 tests.
* For (1): The earlier de-flaking attempt merely masks the problem: The
  first (suppressed) click closes the panel, and the second reopens it.
  (instead of being a tap-near). The solution:
  * tap_test.html: For text "Search Term Resolution", wrap "Resolution"
    to next line to bring node#resolution closer to node#search.
  * Add testSeparateSearchContentVisibility, which is same as
    testChainedSearchContentVisibility except it closes the Panel before
    clicking node#resolution. By comparison, this test is helpful in
    hinting whether tap-near suppression is causing problems. It's also
    much simpler than alternatives (i.e., dedicated distance test, or
    disabling tap suppression).
  * Remove retryPanelBarInteractions() and its usage, since it's no
    longer needed for the bug. There's some risk that the removal can
    expose other flakes -- we'll address these if they show up.
  * Note that we didn't increase RETAP_DISTANCE_SQUARED_DP = 75 ** 2,
    which is likely now too small. A general solution would be to adjust
    this based on screen resolution. It's unclear whether this is worth
    the effort though.

* For (2): Fix trigger{Non}Resolve() to wait for a "fresh" panel peek
  by ignoring an existing one. Ultimately this detects a fresh call to
  OverlayPanel.peekPanel(). Ideally we'd use an observer, but since the
  testing framework uses polling and delays, so a simple time-based
  solution is used:
  * Have OverlayPanel store |mLastPeekSequence|, incremented on each
    peekPanel() call, and accessed via getLastPeekSequence().
  * In ContextualSearchInstrumentationBase, add
    waitForPanelToFreshlyPeek(), which is waitForPanelToPeek() that also
    waits for getLastPeekSequence() to change.
  * Change clickWordNode() to use waitForPanelToFreshlyPeek().

* For (3): Increase |stepCount| from 100 to 1000. This drastically
  reduced the occurrence of flakes.

Bug: 1192285, 1333161
Change-Id: I0a63b4fdcb437c4970c526e837196149bab666c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4653255
Reviewed-by: Gang Wu <gangwu@chromium.org>
Commit-Queue: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1171286}
5 files changed
tree: f003044eda477541989ef199087555d5ea11c02c
  1. android_webview/
  2. apps/
  3. ash/
  4. base/
  5. build/
  6. build_overrides/
  7. buildtools/
  8. cc/
  9. chrome/
  10. chromecast/
  11. chromeos/
  12. codelabs/
  13. components/
  14. content/
  15. courgette/
  16. crypto/
  17. dbus/
  18. device/
  19. docs/
  20. extensions/
  21. fuchsia_web/
  22. gin/
  23. google_apis/
  24. google_update/
  25. gpu/
  26. headless/
  27. infra/
  28. ios/
  29. ipc/
  30. media/
  31. mojo/
  32. native_client_sdk/
  33. net/
  34. pdf/
  35. ppapi/
  36. printing/
  37. remoting/
  38. rlz/
  39. sandbox/
  40. services/
  41. skia/
  42. sql/
  43. storage/
  44. styleguide/
  45. testing/
  46. third_party/
  47. tools/
  48. ui/
  49. url/
  50. weblayer/
  51. .clang-format
  52. .clang-tidy
  53. .eslintrc.js
  54. .git-blame-ignore-revs
  55. .gitattributes
  56. .gitignore
  57. .gn
  58. .mailmap
  59. .rustfmt.toml
  60. .vpython3
  61. .yapfignore
  62. ATL_OWNERS
  63. AUTHORS
  64. BUILD.gn
  65. CODE_OF_CONDUCT.md
  66. codereview.settings
  67. DEPS
  68. DIR_METADATA
  69. LICENSE
  70. LICENSE.chromium_os
  71. OWNERS
  72. PRESUBMIT.py
  73. PRESUBMIT_test.py
  74. PRESUBMIT_test_mocks.py
  75. README.md
  76. WATCHLISTS
README.md

Logo Chromium

Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.

The project's web site is https://www.chromium.org.

To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.

Documentation in the source is rooted in docs/README.md.

Learn how to Get Around the Chromium Source Code Directory Structure .

For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.

If you found a bug, please file it at https://crbug.com/new.