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

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

Issue 262583007: Password manager internals page service: introduction (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add client registration, remove IsActive Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/password_manager/password_manager_internals_service.h"
6
7 #include "chrome/test/base/testing_profile.h"
8 #include "components/keyed_service/content/browser_context_dependency_manager.h"
9 #include "components/password_manager/core/browser/password_manager_logger.h"
10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace {
14
15 const char kTestText[] = "abcd1234";
16
17 class MockLogReceiver : public password_manager::PasswordManagerLogger {
18 public:
19 MockLogReceiver() {}
20
21 MOCK_METHOD1(LogSavePasswordProgress, void(const std::string&));
22 };
23
24 enum ProfileType { NORMAL_PROFILE, OTR_PROFILE };
Ilya Sherman 2014/05/02 23:38:38 nit: "OTR" -> "INCOGNITO"
vabr (Chromium) 2014/05/06 13:16:30 Done.
25
26 scoped_ptr<TestingProfile> CreateProfile(ProfileType type) {
27 TestingProfile::Builder builder;
28 if (type == OTR_PROFILE)
29 builder.SetIncognito();
30 scoped_ptr<TestingProfile> context(builder.Build());
Ilya Sherman 2014/05/02 23:38:38 nit: "context" -> "profile"
vabr (Chromium) 2014/05/06 13:16:30 Done.
31 // During the test cases, the contexts may get created on the same address. To
32 // avoid over-zealous asserts we need to mark the newly created one as "live".
33 // See declaration of MarkBrowserContextLiveForTesting for more details.
34 BrowserContextDependencyManager::GetInstance()
35 ->MarkBrowserContextLiveForTesting(context.get());
vabr (Chromium) 2014/05/02 15:33:10 TODO(vabr): Need to put this inside #if !defined(N
36 return context.Pass();
37 }
38
39 } // namespace
40
41 // When the browser context is not off-the-record, it should be possible to
42 // activate the service.
43 TEST(PasswordManagerInternalsServiceTest, ServiceActiveNoOTR) {
Ilya Sherman 2014/05/02 23:38:38 nit: "OTR" -> "Incognito" throughout. Likewise, "
vabr (Chromium) 2014/05/06 13:16:30 Thanks, Ilya, I did not know that OTR is deprecate
44 scoped_ptr<TestingProfile> context(CreateProfile(NORMAL_PROFILE));
Ilya Sherman 2014/05/02 23:38:38 nit: Please be consistent about "profile" or "cont
vabr (Chromium) 2014/05/06 13:16:30 That's a fair point. I'll switch to "profile" comp
45 PasswordManagerInternalsService* service =
46 PasswordManagerInternalsService::Get(context.get());
47 testing::StrictMock<MockLogReceiver> receiver;
48
49 ASSERT_TRUE(context);
50 ASSERT_TRUE(service);
51 ASSERT_TRUE(service->RegisterReceiver(&receiver));
52
53 // TODO(vabr): Use a MockPasswordManagerClient to detect activity changes.
54 EXPECT_CALL(receiver, LogSavePasswordProgress(kTestText)).Times(1);
55 service->ProcessLog(kTestText);
56
57 ASSERT_TRUE(service->UnregisterReceiver(&receiver));
58 }
59
60 // When the browser context is off-the-record, it should not be possible to
61 // activate the service.
62 TEST(PasswordManagerInternalsServiceTest, ServiceNotActiveOTR) {
63 scoped_ptr<TestingProfile> context(CreateProfile(OTR_PROFILE));
64 ASSERT_TRUE(context);
65 PasswordManagerInternalsService* service =
66 PasswordManagerInternalsService::Get(context.get());
67 // BrowserContextKeyedBaseFactory::GetBrowserContextToUse should return NULL
68 // for |context|, because |context| is OTR. Therefore the returned |service|
69 // should also be NULL.
70 EXPECT_FALSE(service);
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698