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 10 matching lines...) Expand all Loading... |
21 | 21 |
22 class ProximityAuthCryptAuthApiCallFlowTest | 22 class ProximityAuthCryptAuthApiCallFlowTest |
23 : public testing::Test, | 23 : public testing::Test, |
24 public net::TestURLFetcherDelegateForTests { | 24 public net::TestURLFetcherDelegateForTests { |
25 protected: | 25 protected: |
26 ProximityAuthCryptAuthApiCallFlowTest() | 26 ProximityAuthCryptAuthApiCallFlowTest() |
27 : url_request_context_getter_(new net::TestURLRequestContextGetter( | 27 : url_request_context_getter_(new net::TestURLRequestContextGetter( |
28 new base::TestSimpleTaskRunner())), | 28 new base::TestSimpleTaskRunner())), |
29 flow_(GURL(kRequestUrl)) {} | 29 flow_(GURL(kRequestUrl)) {} |
30 | 30 |
31 virtual void SetUp() override { | 31 void SetUp() override { |
32 // The TestURLFetcherFactory will override the global URLFetcherFactory for | 32 // The TestURLFetcherFactory will override the global URLFetcherFactory for |
33 // the entire test. | 33 // the entire test. |
34 url_fetcher_factory_.reset(new net::TestURLFetcherFactory()); | 34 url_fetcher_factory_.reset(new net::TestURLFetcherFactory()); |
35 url_fetcher_factory_->SetDelegateForTests(this); | 35 url_fetcher_factory_->SetDelegateForTests(this); |
36 } | 36 } |
37 | 37 |
38 void StartApiCallFlow() { | 38 void StartApiCallFlow() { |
39 flow_.Start(url_request_context_getter_.get(), | 39 flow_.Start(url_request_context_getter_.get(), |
40 "access_token", | 40 "access_token", |
41 kSerializedRequestProto, | 41 kSerializedRequestProto, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |