Reland "[Enrollment] Mock EnrollmentLauncher with a factory." This is a reland of commit 0090223f92fb1a29f3b3ccf2638c382836b69ab3 The problem with original commit was that MockEnrollmentLauncher has to outlive its tested consumers. The reland adds better lifetime handling of EnrollmentScreen, DemoSetupController and MockEnrollmentLauncher in unittests. Browsertest already have satisfying lifetime. Now in unit tests, lifetime of mock and tested consumer are managed via construction order: 1. In EnrollmentScreenUnitTest, mocks are regular non-pointer members initialized before enrollment screen. Except for MockErrorScreen which has to be reset in TearDown() before network portal shutdown. Enrollment screen is also destroyed in TearDown() as it requires browser process shutdown. 2. In DemoSetupControllerTest, mocks are regular non-pointer members initialized before tested DemoSetupController. 3. In DemoSetupControllerTest, task environment moved to be the first member so that all other members (specifically DemoSetupControllerTestHelper) use it. 4. All mocks are wrapped with NiceMock to prevent unused warnings. Original change's description: > [Enrollment] Mock EnrollmentLauncher with a factory. > > In tests, enrollment launcher was mocked via global mock holder. Tests > used to set a mock before it is yanked by > EnrollmentLauncher::Create function called by a launcher's consumer > (e.g. enrollment screen). It was one time set after which tests needed > to set another mock, and had to know when to do so. > > Now, tests have full control and access to the launcher's mock and can > easily set and reset expectations. Tests have no care about when > fake enrollment launchers, connected to the mock, are created and used. > Tests can inject fake enrollment launchers via factory override. > > Bug: b:233859530 > Test: None > Change-Id: Ica1aac291bcaafbc3648a9745c3a4c66e0b9699a > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4567496 > Commit-Queue: Artem Sumaneev <asumaneev@google.com> > Reviewed-by: Jackson Tadie <jacksontadie@google.com> > Reviewed-by: Roman Sorokin <rsorokin@google.com> > Reviewed-by: Renato Silva <rrsilva@google.com> > Cr-Commit-Position: refs/heads/main@{#1152426} Bug: b:233859530 Test: unit_tests --gtest_filter="EnrollmentScreenUnitTest.*" Test: unit_tests --gtest_filter="*AutomaticEnrollmentScreenUnitTest.*" Test: unit_tests --gtest_filter="DemoSetupControllerTest.*" Test: unit_tests --gtest_filter="*RetailerNameCanonicalizationTestCase.*" Change-Id: Ice8787429450d90963a4887e7489c21a9465f3c6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4584249 Reviewed-by: Jackson Tadie <jacksontadie@google.com> Commit-Queue: Artem Sumaneev <asumaneev@google.com> Reviewed-by: Renato Silva <rrsilva@google.com> Cr-Commit-Position: refs/heads/main@{#1156109}
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.