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

Side by Side Diff: components/password_manager/content/renderer/credential_manager_client_browsertest.cc

Issue 1215653003: Remove the notifyFailedSignedIn callback from Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: components_browsertests Created 5 years, 5 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/content/common/credential_manager_messages .h" 5 #include "components/password_manager/content/common/credential_manager_messages .h"
6 #include "components/password_manager/content/renderer/credential_manager_client .h" 6 #include "components/password_manager/content/renderer/credential_manager_client .h"
7 #include "content/public/test/render_view_test.h" 7 #include "content/public/test/render_view_test.h"
8 #include "ipc/ipc_test_sink.h" 8 #include "ipc/ipc_test_sink.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/WebKit/public/platform/WebCredential.h" 10 #include "third_party/WebKit/public/platform/WebCredential.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // returns false, and the |request_id| is set to -1. 45 // returns false, and the |request_id| is set to -1.
46 // 46 //
47 // Clears any pending messages upon return. 47 // Clears any pending messages upon return.
48 bool ExtractRequestId(uint32 message_id, int& request_id) { 48 bool ExtractRequestId(uint32 message_id, int& request_id) {
49 request_id = -1; 49 request_id = -1;
50 const IPC::Message* message = sink().GetFirstMessageMatching(message_id); 50 const IPC::Message* message = sink().GetFirstMessageMatching(message_id);
51 if (!message) 51 if (!message)
52 return false; 52 return false;
53 53
54 switch (message_id) { 54 switch (message_id) {
55 case CredentialManagerHostMsg_NotifyFailedSignIn::ID: {
56 base::Tuple<int, CredentialInfo> param;
57 CredentialManagerHostMsg_NotifyFailedSignIn::Read(message, &param);
58 request_id = base::get<0>(param);
59 break;
60 }
61
62 case CredentialManagerHostMsg_NotifySignedIn::ID: { 55 case CredentialManagerHostMsg_NotifySignedIn::ID: {
63 base::Tuple<int, CredentialInfo> param; 56 base::Tuple<int, CredentialInfo> param;
64 CredentialManagerHostMsg_NotifySignedIn::Read(message, &param); 57 CredentialManagerHostMsg_NotifySignedIn::Read(message, &param);
65 request_id = base::get<0>(param); 58 request_id = base::get<0>(param);
66 break; 59 break;
67 } 60 }
68 61
69 case CredentialManagerHostMsg_RequireUserMediation::ID: { 62 case CredentialManagerHostMsg_RequireUserMediation::ID: {
70 base::Tuple<int> param; 63 base::Tuple<int> param;
71 CredentialManagerHostMsg_RequireUserMediation::Read(message, &param); 64 CredentialManagerHostMsg_RequireUserMediation::Read(message, &param);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 virtual void onError(blink::WebCredentialManagerError* reason) { 132 virtual void onError(blink::WebCredentialManagerError* reason) {
140 test_->set_callback_errored(true); 133 test_->set_callback_errored(true);
141 } 134 }
142 135
143 private: 136 private:
144 CredentialManagerClientTest* test_; 137 CredentialManagerClientTest* test_;
145 }; 138 };
146 139
147 } // namespace 140 } // namespace
148 141
149 TEST_F(CredentialManagerClientTest, SendNotifyFailedSignIn) {
150 int request_id;
151 EXPECT_FALSE(ExtractRequestId(CredentialManagerHostMsg_NotifyFailedSignIn::ID,
152 request_id));
153
154 scoped_ptr<TestNotificationCallbacks> callbacks(
155 new TestNotificationCallbacks(this));
156 client_->dispatchFailedSignIn(*credential(), callbacks.release());
157
158 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_NotifyFailedSignIn::ID,
159 request_id));
160
161 client_->OnAcknowledgeFailedSignIn(request_id);
162 EXPECT_TRUE(callback_succeeded());
163 EXPECT_FALSE(callback_errored());
164 }
165
166 TEST_F(CredentialManagerClientTest, SendNotifySignedIn) { 142 TEST_F(CredentialManagerClientTest, SendNotifySignedIn) {
167 int request_id; 143 int request_id;
168 EXPECT_FALSE(ExtractRequestId(CredentialManagerHostMsg_NotifySignedIn::ID, 144 EXPECT_FALSE(ExtractRequestId(CredentialManagerHostMsg_NotifySignedIn::ID,
169 request_id)); 145 request_id));
170 146
171 scoped_ptr<TestNotificationCallbacks> callbacks( 147 scoped_ptr<TestNotificationCallbacks> callbacks(
172 new TestNotificationCallbacks(this)); 148 new TestNotificationCallbacks(this));
173 client_->dispatchSignedIn(*credential(), callbacks.release()); 149 client_->dispatchSignedIn(*credential(), callbacks.release());
174 150
175 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_NotifySignedIn::ID, 151 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_NotifySignedIn::ID,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, 204 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID,
229 request_id)); 205 request_id));
230 206
231 CredentialInfo info; // Send an empty credential in response. 207 CredentialInfo info; // Send an empty credential in response.
232 client_->OnSendCredential(request_id, info); 208 client_->OnSendCredential(request_id, info);
233 EXPECT_TRUE(callback_succeeded()); 209 EXPECT_TRUE(callback_succeeded());
234 EXPECT_FALSE(callback_errored()); 210 EXPECT_FALSE(callback_errored());
235 } 211 }
236 212
237 } // namespace password_manager 213 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698