• Lukasz Anforowicz's avatar
    Insulate browser tests from environmental memory pressure. · 80ec8e2b
    Lukasz Anforowicz authored
    This CL also makes sure that the default base::MemoryPressureMonitor
    won't be created when running browser tests.  This helps insulate the
    tests from their environment and ensure that the tests behave
    deterministically (rather than flakily depending on things outside the
    test control, like the overall memory pressure on the bot which runs the
    test).  This is accomplished by avoiding creating the monitor if
    --browser-test switch is present.
    
    Before this CL, the --browser-test switch would be injected by
    ContentBrowserTest::SetUp.  After this CL, the switch is injected by
    BrowserTestBase::SetUp - this means that insulation from memory pressure
    covers not only content_browsertests, but also browser_tests (and other
    tests that subclass BrowserTestBase rather than ContentBrowserTest).
    
    This CL also makes tweaks in memory-pressure-monitoring code to make
    sure that things work properly after the changes described above.
    In particular, the CL also makes the following changes:
    
    - Move DummyMemoryPressureMonitor from
      //chrome/browser/chromeos/resource_reporter/resource_reporter_unittest.cc
      into //base (renaming the class into FakeMemoryPressureMonitor), so
      that it can be reused by TabManagerTest.OomPressureListener browser
      test.  Note that the FakeMemoryPressureMonitor has to be constructed
      and present early during browser startup (so that TabManager::Start
      detects presence of the monitor).
    
    - Stop incorrect downcasting that used to be made by
      base::chromeos::MemoryPressureMonitor::Get
    
    There are also some opportunistic changes that are not really required
    for correctness:
    
    - Rewrite TabManager::OnMemoryPressure to follow most recent
      style guidelines that help enforce that missing a switch/case
      branch will lead to a compile error (thanks to a missing "default"
      branch).
    
    Bug: 852905
    Change-Id: I6eb651a4f7a7bc6d1a2138ba31dd248c7e33f2a4
    Reviewed-on: https://chromium-review.googlesource.com/1194879
    Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
    Reviewed-by: default avatarChris Hamilton <chrisha@chromium.org>
    Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
    Reviewed-by: default avatarAlbert J. Wong <ajwong@chromium.org>
    Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#590331}
    80ec8e2b
shell_switches.cc 2.43 KB