OLD | NEW |
---|---|
(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 "components/password_manager/content/browser/content_credential_manager _dispatcher.h" | |
6 | |
7 #include "base/command_line.h" | |
8 #include "base/strings/string16.h" | |
9 #include "base/strings/utf_string_conversions.h" | |
10 #include "components/password_manager/content/common/credential_manager_messages .h" | |
11 #include "components/password_manager/content/common/credential_manager_types.h" | |
12 #include "content/public/test/mock_render_process_host.h" | |
13 #include "content/public/test/test_renderer_host.h" | |
14 #include "testing/gmock/include/gmock/gmock.h" | |
15 #include "testing/gtest/include/gtest/gtest.h" | |
16 | |
17 using content::BrowserContext; | |
18 using content::WebContents; | |
19 | |
20 namespace { | |
21 | |
22 // Chosen by fair dice roll. Guaranteed to be random. | |
23 const int kRequestId = 4; | |
24 | |
25 } // namespace | |
26 | |
27 namespace password_manager { | |
28 | |
29 class ContentCredentialManagerDispatcherTest | |
30 : public content::RenderViewHostTestHarness { | |
31 public: | |
32 ContentCredentialManagerDispatcherTest() {} | |
33 | |
34 virtual void SetUp() OVERRIDE { | |
35 content::RenderViewHostTestHarness::SetUp(); | |
36 dispatcher_.reset( | |
37 new ContentCredentialManagerDispatcher(web_contents(), nullptr)); | |
vabr (Chromium)
2014/09/29 11:05:27
Yaay++11! Thanks for making me check and realise a
| |
38 } | |
39 | |
40 ContentCredentialManagerDispatcher* dispatcher() { return dispatcher_.get(); } | |
41 | |
42 private: | |
43 scoped_ptr<ContentCredentialManagerDispatcher> dispatcher_; | |
44 }; | |
45 | |
46 TEST_F(ContentCredentialManagerDispatcherTest, | |
47 CredentialManagerOnNotifyFailedSignIn) { | |
48 CredentialInfo info(base::ASCIIToUTF16("id"), | |
49 base::ASCIIToUTF16("name"), | |
50 GURL("https://example.com/image.png")); | |
51 dispatcher()->OnNotifyFailedSignIn(kRequestId, info); | |
52 | |
53 const uint32 kMsgID = CredentialManagerMsg_AcknowledgeFailedSignIn::ID; | |
54 const IPC::Message* message = | |
55 process()->sink().GetFirstMessageMatching(kMsgID); | |
56 EXPECT_TRUE(message); | |
57 process()->sink().ClearMessages(); | |
58 } | |
59 | |
60 TEST_F(ContentCredentialManagerDispatcherTest, | |
61 CredentialManagerOnNotifySignedIn) { | |
62 CredentialInfo info(base::ASCIIToUTF16("id"), | |
63 base::ASCIIToUTF16("name"), | |
64 GURL("https://example.com/image.png")); | |
65 dispatcher()->OnNotifySignedIn(kRequestId, info); | |
66 | |
67 const uint32 kMsgID = CredentialManagerMsg_AcknowledgeSignedIn::ID; | |
68 const IPC::Message* message = | |
69 process()->sink().GetFirstMessageMatching(kMsgID); | |
70 EXPECT_TRUE(message); | |
71 process()->sink().ClearMessages(); | |
72 } | |
73 | |
74 TEST_F(ContentCredentialManagerDispatcherTest, | |
75 CredentialManagerOnNotifySignedOut) { | |
76 dispatcher()->OnNotifySignedOut(kRequestId); | |
77 | |
78 const uint32 kMsgID = CredentialManagerMsg_AcknowledgeSignedOut::ID; | |
79 const IPC::Message* message = | |
80 process()->sink().GetFirstMessageMatching(kMsgID); | |
81 EXPECT_TRUE(message); | |
82 process()->sink().ClearMessages(); | |
83 } | |
84 | |
85 TEST_F(ContentCredentialManagerDispatcherTest, | |
86 CredentialManagerOnRequestCredential) { | |
87 std::vector<GURL> federations; | |
88 dispatcher()->OnRequestCredential(kRequestId, false, federations); | |
89 | |
90 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | |
91 const IPC::Message* message = | |
92 process()->sink().GetFirstMessageMatching(kMsgID); | |
93 EXPECT_TRUE(message); | |
94 process()->sink().ClearMessages(); | |
95 } | |
96 | |
97 } // namespace password_manager | |
OLD | NEW |