Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: chrome/browser/password_manager/password_manager_internals_service_unittest.cc

Issue 2749823002: Restore KeyedServiceFactory diagnostics for context use-after-destroy. (Closed)
Patch Set: Refactor SiteEngagementService tests. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/password_manager/core/browser/password_manager_internals_se rvice.h" 5 #include "components/password_manager/core/browser/password_manager_internals_se rvice.h"
6 6
7 #include "chrome/test/base/testing_profile.h" 7 #include "chrome/test/base/testing_profile.h"
8 #include "components/keyed_service/content/browser_context_dependency_manager.h" 8 #include "components/keyed_service/content/browser_context_dependency_manager.h"
9 #include "components/password_manager/content/browser/password_manager_internals _service_factory.h" 9 #include "components/password_manager/content/browser/password_manager_internals _service_factory.h"
10 #include "components/password_manager/core/browser/log_receiver.h" 10 #include "components/password_manager/core/browser/log_receiver.h"
(...skipping 12 matching lines...) Expand all
23 public: 23 public:
24 MockLogReceiver() {} 24 MockLogReceiver() {}
25 25
26 MOCK_METHOD1(LogSavePasswordProgress, void(const std::string&)); 26 MOCK_METHOD1(LogSavePasswordProgress, void(const std::string&));
27 }; 27 };
28 28
29 enum ProfileType { NORMAL_PROFILE, INCOGNITO_PROFILE }; 29 enum ProfileType { NORMAL_PROFILE, INCOGNITO_PROFILE };
30 30
31 std::unique_ptr<TestingProfile> CreateProfile(ProfileType type) { 31 std::unique_ptr<TestingProfile> CreateProfile(ProfileType type) {
32 TestingProfile::Builder builder; 32 TestingProfile::Builder builder;
33 std::unique_ptr<TestingProfile> profile(builder.Build()); 33 return builder.Build();
34 #if !defined(NDEBUG)
35 // During the test cases, the profiles may get created on the same address. To
36 // avoid over-zealous asserts we need to mark the newly created one as "live".
37 // See declaration of MarkBrowserContextLiveForTesting for more details.
38 BrowserContextDependencyManager::GetInstance()
39 ->MarkBrowserContextLiveForTesting(profile.get());
40 if (type == INCOGNITO_PROFILE) {
41 BrowserContextDependencyManager::GetInstance()
42 ->MarkBrowserContextLiveForTesting(profile->GetOffTheRecordProfile());
43 }
44 #endif
45 return profile;
46 } 34 }
47 35
48 } // namespace 36 } // namespace
49 37
50 class PasswordManagerInternalsServiceTest : public testing::Test { 38 class PasswordManagerInternalsServiceTest : public testing::Test {
51 content::TestBrowserThreadBundle thread_bundle_; 39 content::TestBrowserThreadBundle thread_bundle_;
52 }; 40 };
53 41
54 // When the profile is not incognito, it should be possible to activate the 42 // When the profile is not incognito, it should be possible to activate the
55 // service. 43 // service.
(...skipping 23 matching lines...) Expand all
79 67
80 Profile* incognito_profile = profile->GetOffTheRecordProfile(); 68 Profile* incognito_profile = profile->GetOffTheRecordProfile();
81 PasswordManagerInternalsService* service = 69 PasswordManagerInternalsService* service =
82 PasswordManagerInternalsServiceFactory::GetForBrowserContext( 70 PasswordManagerInternalsServiceFactory::GetForBrowserContext(
83 incognito_profile); 71 incognito_profile);
84 // BrowserContextKeyedBaseFactory::GetBrowserContextToUse should return NULL 72 // BrowserContextKeyedBaseFactory::GetBrowserContextToUse should return NULL
85 // for |profile|, because |profile| is incognito. Therefore the returned 73 // for |profile|, because |profile| is incognito. Therefore the returned
86 // |service| should also be NULL. 74 // |service| should also be NULL.
87 EXPECT_FALSE(service); 75 EXPECT_FALSE(service);
88 } 76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698