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 "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
8 #include "net/url_request/test_url_fetcher_factory.h" | 8 #include "net/url_request/test_url_fetcher_factory.h" |
9 #include "net/url_request/url_request_test_util.h" | 9 #include "net/url_request/url_request_test_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 url_fetcher_ = NULL; | 79 url_fetcher_ = NULL; |
80 url_fetcher->set_status(net::URLRequestStatus(request_status, 0)); | 80 url_fetcher->set_status(net::URLRequestStatus(request_status, 0)); |
81 if (request_status == net::URLRequestStatus::SUCCESS) { | 81 if (request_status == net::URLRequestStatus::SUCCESS) { |
82 url_fetcher->set_response_code(response_code); | 82 url_fetcher->set_response_code(response_code); |
83 url_fetcher->SetResponseString(response_string); | 83 url_fetcher->SetResponseString(response_string); |
84 } | 84 } |
85 url_fetcher->delegate()->OnURLFetchComplete(url_fetcher); | 85 url_fetcher->delegate()->OnURLFetchComplete(url_fetcher); |
86 } | 86 } |
87 | 87 |
88 // net::TestURLFetcherDelegateForTests overrides. | 88 // net::TestURLFetcherDelegateForTests overrides. |
89 virtual void OnRequestStart(int fetcher_id) override { | 89 void OnRequestStart(int fetcher_id) override { |
90 url_fetcher_ = url_fetcher_factory_->GetFetcherByID(fetcher_id); | 90 url_fetcher_ = url_fetcher_factory_->GetFetcherByID(fetcher_id); |
91 } | 91 } |
92 | 92 |
93 virtual void OnChunkUpload(int fetcher_id) override {} | 93 void OnChunkUpload(int fetcher_id) override {} |
94 | 94 |
95 virtual void OnRequestEnd(int fetcher_id) override {} | 95 void OnRequestEnd(int fetcher_id) override {} |
96 | 96 |
97 net::TestURLFetcher* url_fetcher_; | 97 net::TestURLFetcher* url_fetcher_; |
98 scoped_ptr<std::string> result_; | 98 scoped_ptr<std::string> result_; |
99 scoped_ptr<std::string> error_message_; | 99 scoped_ptr<std::string> error_message_; |
100 | 100 |
101 private: | 101 private: |
102 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; | 102 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; |
103 scoped_ptr<net::TestURLFetcherFactory> url_fetcher_factory_; | 103 scoped_ptr<net::TestURLFetcherFactory> url_fetcher_factory_; |
104 CryptAuthApiCallFlow flow_; | 104 CryptAuthApiCallFlow flow_; |
105 }; | 105 }; |
(...skipping 24 matching lines...) Expand all Loading... |
130 | 130 |
131 TEST_F(ProximityAuthCryptAuthApiCallFlowTest, ResponseWithNoBody) { | 131 TEST_F(ProximityAuthCryptAuthApiCallFlowTest, ResponseWithNoBody) { |
132 StartApiCallFlow(); | 132 StartApiCallFlow(); |
133 CompleteCurrentRequest( | 133 CompleteCurrentRequest( |
134 net::URLRequestStatus::SUCCESS, net::HTTP_OK, std::string()); | 134 net::URLRequestStatus::SUCCESS, net::HTTP_OK, std::string()); |
135 EXPECT_FALSE(result_); | 135 EXPECT_FALSE(result_); |
136 EXPECT_EQ("No response body", *error_message_); | 136 EXPECT_EQ("No response body", *error_message_); |
137 } | 137 } |
138 | 138 |
139 } // namespace proximity_auth | 139 } // namespace proximity_auth |
OLD | NEW |