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/proximity_auth/cryptauth/cryptauth_api_call_flow.h" | 5 #include "components/proximity_auth/cryptauth/cryptauth_api_call_flow.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
10 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
11 #include "net/url_request/test_url_fetcher_factory.h" | 12 #include "net/url_request/test_url_fetcher_factory.h" |
12 #include "net/url_request/url_request_status.h" | 13 #include "net/url_request/url_request_status.h" |
13 #include "net/url_request/url_request_test_util.h" | 14 #include "net/url_request/url_request_test_util.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace proximity_auth { | 17 namespace proximity_auth { |
17 | 18 |
18 namespace { | 19 namespace { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // net::TestURLFetcherDelegateForTests overrides. | 94 // net::TestURLFetcherDelegateForTests overrides. |
94 void OnRequestStart(int fetcher_id) override { | 95 void OnRequestStart(int fetcher_id) override { |
95 url_fetcher_ = url_fetcher_factory_->GetFetcherByID(fetcher_id); | 96 url_fetcher_ = url_fetcher_factory_->GetFetcherByID(fetcher_id); |
96 } | 97 } |
97 | 98 |
98 void OnChunkUpload(int fetcher_id) override {} | 99 void OnChunkUpload(int fetcher_id) override {} |
99 | 100 |
100 void OnRequestEnd(int fetcher_id) override {} | 101 void OnRequestEnd(int fetcher_id) override {} |
101 | 102 |
102 net::TestURLFetcher* url_fetcher_; | 103 net::TestURLFetcher* url_fetcher_; |
103 scoped_ptr<std::string> result_; | 104 std::unique_ptr<std::string> result_; |
104 scoped_ptr<std::string> error_message_; | 105 std::unique_ptr<std::string> error_message_; |
105 | 106 |
106 private: | 107 private: |
107 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; | 108 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; |
108 scoped_ptr<net::TestURLFetcherFactory> url_fetcher_factory_; | 109 std::unique_ptr<net::TestURLFetcherFactory> url_fetcher_factory_; |
109 CryptAuthApiCallFlow flow_; | 110 CryptAuthApiCallFlow flow_; |
110 | 111 |
111 DISALLOW_COPY_AND_ASSIGN(ProximityAuthCryptAuthApiCallFlowTest); | 112 DISALLOW_COPY_AND_ASSIGN(ProximityAuthCryptAuthApiCallFlowTest); |
112 }; | 113 }; |
113 | 114 |
114 TEST_F(ProximityAuthCryptAuthApiCallFlowTest, RequestSuccess) { | 115 TEST_F(ProximityAuthCryptAuthApiCallFlowTest, RequestSuccess) { |
115 StartApiCallFlow(); | 116 StartApiCallFlow(); |
116 CompleteCurrentRequest(net::OK, net::HTTP_OK, kSerializedResponseProto); | 117 CompleteCurrentRequest(net::OK, net::HTTP_OK, kSerializedResponseProto); |
117 EXPECT_EQ(kSerializedResponseProto, *result_); | 118 EXPECT_EQ(kSerializedResponseProto, *result_); |
118 EXPECT_FALSE(error_message_); | 119 EXPECT_FALSE(error_message_); |
(...skipping 24 matching lines...) Expand all Loading... |
143 | 144 |
144 // The empty string is a valid protocol buffer message serialization. | 145 // The empty string is a valid protocol buffer message serialization. |
145 TEST_F(ProximityAuthCryptAuthApiCallFlowTest, ResponseWithNoBody) { | 146 TEST_F(ProximityAuthCryptAuthApiCallFlowTest, ResponseWithNoBody) { |
146 StartApiCallFlow(); | 147 StartApiCallFlow(); |
147 CompleteCurrentRequest(net::OK, net::HTTP_OK, std::string()); | 148 CompleteCurrentRequest(net::OK, net::HTTP_OK, std::string()); |
148 EXPECT_EQ(std::string(), *result_); | 149 EXPECT_EQ(std::string(), *result_); |
149 EXPECT_FALSE(error_message_); | 150 EXPECT_FALSE(error_message_); |
150 } | 151 } |
151 | 152 |
152 } // namespace proximity_auth | 153 } // namespace proximity_auth |
OLD | NEW |