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

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

Issue 1162583003: Credential Management: Rename 'LocalCredential' to 'PasswordCredential' (2/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@drop
Patch Set: Fix. Created 5 years, 6 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"
11 #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h" 11 #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h"
12 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" 12 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h"
13 #include "third_party/WebKit/public/platform/WebLocalCredential.h" 13 #include "third_party/WebKit/public/platform/WebPasswordCredential.h"
14 14
15 namespace password_manager { 15 namespace password_manager {
16 16
17 namespace { 17 namespace {
18 18
19 // This test has crashed on Android since commit 19 // This test has crashed on Android since commit
20 // d94a4430bc4448406b7564790d06110c7c5bcaaf was merged. 20 // d94a4430bc4448406b7564790d06110c7c5bcaaf was merged.
21 // http://crbug.com/481415 21 // http://crbug.com/481415
22 #if defined(OS_ANDROID) 22 #if defined(OS_ANDROID)
23 #define MAYBE_CredentialManagerClientTest DISABLED_CredentialManagerClientTest 23 #define MAYBE_CredentialManagerClientTest DISABLED_CredentialManagerClientTest
24 #else 24 #else
25 #define MAYBE_CredentialManagerClientTest CredentialManagerClientTest 25 #define MAYBE_CredentialManagerClientTest CredentialManagerClientTest
26 #endif // defined(OS_ANDROID) 26 #endif // defined(OS_ANDROID)
27 27
28 class MAYBE_CredentialManagerClientTest : public content::RenderViewTest { 28 class MAYBE_CredentialManagerClientTest : public content::RenderViewTest {
29 public: 29 public:
30 MAYBE_CredentialManagerClientTest() 30 MAYBE_CredentialManagerClientTest()
31 : callback_errored_(false), callback_succeeded_(false) {} 31 : callback_errored_(false), callback_succeeded_(false) {}
32 ~MAYBE_CredentialManagerClientTest() override {} 32 ~MAYBE_CredentialManagerClientTest() override {}
33 33
34 void SetUp() override { 34 void SetUp() override {
35 content::RenderViewTest::SetUp(); 35 content::RenderViewTest::SetUp();
36 credential_.reset(new blink::WebLocalCredential("", "", GURL(), "")); 36 credential_.reset(new blink::WebPasswordCredential("", "", "", GURL()));
37 client_.reset(new CredentialManagerClient(view_)); 37 client_.reset(new CredentialManagerClient(view_));
38 } 38 }
39 39
40 void TearDown() override { 40 void TearDown() override {
41 credential_.reset(); 41 credential_.reset();
42 client_.reset(); 42 client_.reset();
43 content::RenderViewTest::TearDown(); 43 content::RenderViewTest::TearDown();
44 } 44 }
45 45
46 IPC::TestSink& sink() { return render_thread_->sink(); } 46 IPC::TestSink& sink() { return render_thread_->sink(); }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 scoped_ptr<CredentialManagerClient> client_; 105 scoped_ptr<CredentialManagerClient> client_;
106 106
107 // True if a message's callback's 'onSuccess'/'onError' methods were called, 107 // True if a message's callback's 'onSuccess'/'onError' methods were called,
108 // false otherwise. We put these on the test object rather than on the 108 // false otherwise. We put these on the test object rather than on the
109 // Test*Callbacks objects because ownership of those objects passes into the 109 // Test*Callbacks objects because ownership of those objects passes into the
110 // client, which destroys the callbacks after calling them to resolve the 110 // client, which destroys the callbacks after calling them to resolve the
111 // pending Blink-side Promise. 111 // pending Blink-side Promise.
112 bool callback_errored_; 112 bool callback_errored_;
113 bool callback_succeeded_; 113 bool callback_succeeded_;
114 114
115 scoped_ptr<blink::WebLocalCredential> credential_; 115 scoped_ptr<blink::WebPasswordCredential> credential_;
116 }; 116 };
117 117
118 class TestNotificationCallbacks 118 class TestNotificationCallbacks
119 : public blink::WebCredentialManagerClient::NotificationCallbacks { 119 : public blink::WebCredentialManagerClient::NotificationCallbacks {
120 public: 120 public:
121 explicit TestNotificationCallbacks(MAYBE_CredentialManagerClientTest* test) 121 explicit TestNotificationCallbacks(MAYBE_CredentialManagerClientTest* test)
122 : test_(test) {} 122 : test_(test) {}
123 123
124 virtual ~TestNotificationCallbacks() {} 124 virtual ~TestNotificationCallbacks() {}
125 125
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 request_id)); 212 request_id));
213 213
214 scoped_ptr<TestRequestCallbacks> callbacks(new TestRequestCallbacks(this)); 214 scoped_ptr<TestRequestCallbacks> callbacks(new TestRequestCallbacks(this));
215 std::vector<GURL> federations; 215 std::vector<GURL> federations;
216 client_->dispatchRequest(false, federations, callbacks.release()); 216 client_->dispatchRequest(false, federations, callbacks.release());
217 217
218 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, 218 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID,
219 request_id)); 219 request_id));
220 220
221 CredentialInfo info; 221 CredentialInfo info;
222 info.type = CredentialType::CREDENTIAL_TYPE_LOCAL; 222 info.type = CredentialType::CREDENTIAL_TYPE_PASSWORD;
223 client_->OnSendCredential(request_id, info); 223 client_->OnSendCredential(request_id, info);
224 EXPECT_TRUE(callback_succeeded()); 224 EXPECT_TRUE(callback_succeeded());
225 EXPECT_FALSE(callback_errored()); 225 EXPECT_FALSE(callback_errored());
226 } 226 }
227 227
228 TEST_F(MAYBE_CredentialManagerClientTest, SendRequestCredentialEmpty) { 228 TEST_F(MAYBE_CredentialManagerClientTest, SendRequestCredentialEmpty) {
229 int request_id; 229 int request_id;
230 EXPECT_FALSE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, 230 EXPECT_FALSE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID,
231 request_id)); 231 request_id));
232 232
233 scoped_ptr<TestRequestCallbacks> callbacks(new TestRequestCallbacks(this)); 233 scoped_ptr<TestRequestCallbacks> callbacks(new TestRequestCallbacks(this));
234 std::vector<GURL> federations; 234 std::vector<GURL> federations;
235 client_->dispatchRequest(false, federations, callbacks.release()); 235 client_->dispatchRequest(false, federations, callbacks.release());
236 236
237 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, 237 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID,
238 request_id)); 238 request_id));
239 239
240 CredentialInfo info; // Send an empty credential in response. 240 CredentialInfo info; // Send an empty credential in response.
241 client_->OnSendCredential(request_id, info); 241 client_->OnSendCredential(request_id, info);
242 EXPECT_TRUE(callback_succeeded()); 242 EXPECT_TRUE(callback_succeeded());
243 EXPECT_FALSE(callback_errored()); 243 EXPECT_FALSE(callback_errored());
244 } 244 }
245 245
246 } // namespace password_manager 246 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698