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/data_reduction_proxy/common/data_reduction_proxy_headers.h" | 5 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers_te
st_utils.h" | |
10 #include "net/http/http_response_headers.h" | 9 #include "net/http/http_response_headers.h" |
11 #include "net/proxy/proxy_service.h" | 10 #include "net/proxy/proxy_service.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
13 | 12 |
| 13 namespace { |
| 14 |
| 15 // Transform "normal"-looking headers (\n-separated) to the appropriate |
| 16 // input format for ParseRawHeaders (\0-separated). |
| 17 void HeadersToRaw(std::string* headers) { |
| 18 std::replace(headers->begin(), headers->end(), '\n', '\0'); |
| 19 if (!headers->empty()) |
| 20 *headers += '\0'; |
| 21 } |
| 22 |
| 23 } // namespace |
| 24 |
14 namespace data_reduction_proxy { | 25 namespace data_reduction_proxy { |
15 | 26 |
16 class DataReductionProxyHeadersTest : public testing::Test {}; | 27 class DataReductionProxyHeadersTest : public testing::Test {}; |
17 | 28 |
18 TEST_F(DataReductionProxyHeadersTest, GetDataReductionProxyActionValue) { | 29 TEST_F(DataReductionProxyHeadersTest, GetDataReductionProxyActionValue) { |
19 const struct { | 30 const struct { |
20 const char* headers; | 31 const char* headers; |
21 std::string action_key; | 32 std::string action_key; |
22 bool expected_result; | 33 bool expected_result; |
23 std::string expected_action_value; | 34 std::string expected_action_value; |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 std::string output_values_string; | 878 std::string output_values_string; |
868 for (size_t j = 0; j < output_values.size(); ++j) | 879 for (size_t j = 0; j < output_values.size(); ++j) |
869 output_values_string += output_values[j] + ","; | 880 output_values_string += output_values[j] + ","; |
870 | 881 |
871 EXPECT_EQ(test[i].expected_output_values_string, output_values_string) | 882 EXPECT_EQ(test[i].expected_output_values_string, output_values_string) |
872 << test[i].label; | 883 << test[i].label; |
873 } | 884 } |
874 } | 885 } |
875 | 886 |
876 } // namespace data_reduction_proxy | 887 } // namespace data_reduction_proxy |
OLD | NEW |