OLD | NEW |
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/affiliation_fetcher.h" | 5 #include "components/password_manager/core/browser/affiliation_fetcher.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "base/test/null_task_runner.h" | 10 #include "base/test/null_task_runner.h" |
9 #include "components/password_manager/core/browser/affiliation_api.pb.h" | 11 #include "components/password_manager/core/browser/affiliation_api.pb.h" |
10 #include "net/url_request/test_url_fetcher_factory.h" | 12 #include "net/url_request/test_url_fetcher_factory.h" |
11 #include "net/url_request/url_request_test_util.h" | 13 #include "net/url_request/url_request_test_util.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
14 | 16 |
15 namespace password_manager { | 17 namespace password_manager { |
16 | 18 |
17 namespace { | 19 namespace { |
18 | 20 |
19 const char kExampleAndroidFacetURI[] = "android://hash@com.example"; | 21 const char kExampleAndroidFacetURI[] = "android://hash@com.example"; |
20 const char kExampleWebFacet1URI[] = "https://www.example.com"; | 22 const char kExampleWebFacet1URI[] = "https://www.example.com"; |
21 const char kExampleWebFacet2URI[] = "https://www.example.org"; | 23 const char kExampleWebFacet2URI[] = "https://www.example.org"; |
22 | 24 |
23 class MockAffiliationFetcherDelegate | 25 class MockAffiliationFetcherDelegate |
24 : public testing::StrictMock<AffiliationFetcherDelegate> { | 26 : public testing::StrictMock<AffiliationFetcherDelegate> { |
25 public: | 27 public: |
26 MockAffiliationFetcherDelegate() {} | 28 MockAffiliationFetcherDelegate() {} |
27 ~MockAffiliationFetcherDelegate() {} | 29 ~MockAffiliationFetcherDelegate() {} |
28 | 30 |
29 MOCK_METHOD0(OnFetchSucceededProxy, void()); | 31 MOCK_METHOD0(OnFetchSucceededProxy, void()); |
30 MOCK_METHOD0(OnFetchFailed, void()); | 32 MOCK_METHOD0(OnFetchFailed, void()); |
31 MOCK_METHOD0(OnMalformedResponse, void()); | 33 MOCK_METHOD0(OnMalformedResponse, void()); |
32 | 34 |
33 void OnFetchSucceeded(scoped_ptr<Result> result) override { | 35 void OnFetchSucceeded(scoped_ptr<Result> result) override { |
34 OnFetchSucceededProxy(); | 36 OnFetchSucceededProxy(); |
35 result_ = result.Pass(); | 37 result_ = std::move(result); |
36 } | 38 } |
37 | 39 |
38 const Result& result() const { return *result_.get(); } | 40 const Result& result() const { return *result_.get(); } |
39 | 41 |
40 private: | 42 private: |
41 scoped_ptr<Result> result_; | 43 scoped_ptr<Result> result_; |
42 | 44 |
43 DISALLOW_COPY_AND_ASSIGN(MockAffiliationFetcherDelegate); | 45 DISALLOW_COPY_AND_ASSIGN(MockAffiliationFetcherDelegate); |
44 }; | 46 }; |
45 | 47 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 MockAffiliationFetcherDelegate mock_delegate; | 328 MockAffiliationFetcherDelegate mock_delegate; |
327 scoped_ptr<AffiliationFetcher> fetcher(AffiliationFetcher::Create( | 329 scoped_ptr<AffiliationFetcher> fetcher(AffiliationFetcher::Create( |
328 request_context_getter(), uris, &mock_delegate)); | 330 request_context_getter(), uris, &mock_delegate)); |
329 fetcher->StartRequest(); | 331 fetcher->StartRequest(); |
330 | 332 |
331 EXPECT_CALL(mock_delegate, OnFetchFailed()); | 333 EXPECT_CALL(mock_delegate, OnFetchFailed()); |
332 ASSERT_NO_FATAL_FAILURE(SimulateNetworkError()); | 334 ASSERT_NO_FATAL_FAILURE(SimulateNetworkError()); |
333 } | 335 } |
334 | 336 |
335 } // namespace password_manager | 337 } // namespace password_manager |
OLD | NEW |