| 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/cryptauth/cryptauth_api_call_flow.h" | 5 #include "components/cryptauth/cryptauth_api_call_flow.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 const char kRequestUrl[] = "https://googleapis.com/cryptauth/test"; | 23 const char kRequestUrl[] = "https://googleapis.com/cryptauth/test"; |
| 24 | 24 |
| 25 } // namespace | 25 } // namespace |
| 26 | 26 |
| 27 class CryptAuthApiCallFlowTest | 27 class CryptAuthApiCallFlowTest |
| 28 : public testing::Test, | 28 : public testing::Test, |
| 29 public net::TestURLFetcherDelegateForTests { | 29 public net::TestURLFetcherDelegateForTests { |
| 30 protected: | 30 protected: |
| 31 CryptAuthApiCallFlowTest() | 31 CryptAuthApiCallFlowTest() |
| 32 : url_request_context_getter_(new net::TestURLRequestContextGetter( | 32 : url_request_context_getter_(new net::TestURLRequestContextGetter( |
| 33 new base::TestSimpleTaskRunner())) {} | 33 new base::TestSimpleTaskRunner())) { |
| 34 flow_.SetPartialNetworkTrafficAnnotation( |
| 35 PARTIAL_TRAFFIC_ANNOTATION_FOR_TESTS); |
| 36 } |
| 34 | 37 |
| 35 void SetUp() override { | 38 void SetUp() override { |
| 36 // The TestURLFetcherFactory will override the global URLFetcherFactory for | 39 // The TestURLFetcherFactory will override the global URLFetcherFactory for |
| 37 // the entire test. | 40 // the entire test. |
| 38 url_fetcher_factory_.reset(new net::TestURLFetcherFactory()); | 41 url_fetcher_factory_.reset(new net::TestURLFetcherFactory()); |
| 39 url_fetcher_factory_->SetDelegateForTests(this); | 42 url_fetcher_factory_->SetDelegateForTests(this); |
| 40 } | 43 } |
| 41 | 44 |
| 42 void StartApiCallFlow() { | 45 void StartApiCallFlow() { |
| 43 StartApiCallFlowWithRequest(kSerializedRequestProto); | 46 StartApiCallFlowWithRequest(kSerializedRequestProto); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 147 |
| 145 // The empty string is a valid protocol buffer message serialization. | 148 // The empty string is a valid protocol buffer message serialization. |
| 146 TEST_F(CryptAuthApiCallFlowTest, ResponseWithNoBody) { | 149 TEST_F(CryptAuthApiCallFlowTest, ResponseWithNoBody) { |
| 147 StartApiCallFlow(); | 150 StartApiCallFlow(); |
| 148 CompleteCurrentRequest(net::OK, net::HTTP_OK, std::string()); | 151 CompleteCurrentRequest(net::OK, net::HTTP_OK, std::string()); |
| 149 EXPECT_EQ(std::string(), *result_); | 152 EXPECT_EQ(std::string(), *result_); |
| 150 EXPECT_FALSE(error_message_); | 153 EXPECT_FALSE(error_message_); |
| 151 } | 154 } |
| 152 | 155 |
| 153 } // namespace cryptauth | 156 } // namespace cryptauth |
| OLD | NEW |