Avoid SyncConfirmationHandler unittest creating its own Profile
The SyncConfirmationHandler unittest inherits from BrowserWithTestWindowTest. It currently overrides the latter's CreateProfile() method to create and own a Profile instance via IdentityTestEnvironmentProfileAdaptor. However, this blocks the upcoming elimination of FakeSigninManager, via a subtle circular dependency that gets introduced: - SigninManagerFactory supplies |g_browser_process->local_state()| to SigninManager's Initialize() method. - In the testing context, the object thus supplied is actually owned by BrowserWithTestWindowTest's TestingProfileManager object. - Hence, the Profile of the question must be torn down before the TestingProfileManager to avoid a crash that otherwise occurs in SigninManager::Shutdown() when it accesses the PrefService pointer that it has cached. - However, it is not possible to move the teardown of the SyncConfirmationHandler unittest's |profile_| instance to be before the call to BrowserWithTestWindowTest::TearDown(), as that in turn causes a crash because other objects that BrowserWithTestWindowTest owns (namely, |browser_|) must be torn down *before* the Profile. This CL fixes the problem by simply eliminating SyncConfirmationHandler owning its own Profile instance. Instead, it just supplies the factories that IdentityTestEnvironmentProfileAdaptor requires directly to BrowserWithTestWindowTest via an override of GetTestingFactories(). This allows the natural teardown order in BrowserWithTestWindowTest::TearDown() to be preserved. Bug: 796544 Change-Id: I06528d564d836d83e1ac87a6cfc94c9ca12a033c Reviewed-on: https://chromium-review.googlesource.com/c/1488872Reviewed-by:David Roger <droger@chromium.org> Commit-Queue: Colin Blundell <blundell@chromium.org> Cr-Commit-Position: refs/heads/master@{#635485}
Showing
Please register or sign in to comment