BrowserProcessImplTest creates a second BrowserProcessImpl in-process |
|
Issue descriptionBrowserProcessImplTest[1] creates a second BrowserProcessImpl, in addition to the one provided by the unit_tests framework(?). This is problematic because it leads to global state being set twice. The test juggles |g_browser_process| to "restore" the original BrowserProcessImpl after the test runs, but there's more to the global state than just that variable. BrowserProcessImpl's constructor calls static methods like: extensions::ExtensionsClient::Set(ExtensionsClient* client) extensions::AppWindowClient::Set(AppWindowClient* client) which expect to be called once per process, so they have special-case logic for unit tests, e.g. [2]. Not all unit tests have a BrowserProcess, so sometimes we want to set this global state on a test-by-test basis, e.g. to test AppWindowClient behavior. That complicates the special-case logic: we'd need to allow tests to Set(nullptr) so that future tests can Set() again to a new pointer. Can we test BrowserProcessImpl a different way? Creating a second BrowserProcessImpl in-process doesn't seem like a realistic test case. [1] https://cs.chromium.org/chromium/src/chrome/browser/browser_process_impl_unittest.cc?sq=package:chromium&dr&l=27&q=BrowserProcessImplTest.LifeCycle [2] https://cs.chromium.org/chromium/src/extensions/common/extensions_client.cc?q=extensions_client%5C.cc&sq=package:chromium&dr&l=36 |
|
►
Sign in to add a comment |
|
Comment 1 by bugdroid1@chromium.org
, Aug 3 2017