| 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 "platform/network/HTTPParsers.h" | 5 #include "platform/network/HTTPParsers.h" |
| 6 | 6 |
| 7 #include "platform/heap/Handle.h" | 7 #include "platform/heap/Handle.h" |
| 8 #include "platform/loader/fetch/ResourceResponse.h" | 8 #include "platform/loader/fetch/ResourceResponse.h" |
| 9 #include "platform/weborigin/Suborigin.h" | 9 #include "platform/weborigin/Suborigin.h" |
| 10 #include "platform/wtf/MathExtras.h" | 10 #include "platform/wtf/MathExtras.h" |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 | 479 |
| 480 void testServerTimingHeader(const char* headerValue, | 480 void testServerTimingHeader(const char* headerValue, |
| 481 Vector<Vector<String>> expectedResults) { | 481 Vector<Vector<String>> expectedResults) { |
| 482 std::unique_ptr<ServerTimingHeaderVector> results = | 482 std::unique_ptr<ServerTimingHeaderVector> results = |
| 483 ParseServerTimingHeader(headerValue); | 483 ParseServerTimingHeader(headerValue); |
| 484 EXPECT_EQ((*results).size(), expectedResults.size()); | 484 EXPECT_EQ((*results).size(), expectedResults.size()); |
| 485 unsigned i = 0; | 485 unsigned i = 0; |
| 486 for (const auto& header : *results) { | 486 for (const auto& header : *results) { |
| 487 Vector<String> expectedResult = expectedResults[i++]; | 487 Vector<String> expectedResult = expectedResults[i++]; |
| 488 EXPECT_EQ(header->metric, expectedResult[0]); | 488 EXPECT_EQ(header->metric, expectedResult[0]); |
| 489 EXPECT_EQ(header->duration, expectedResult[1].ToDouble()); | 489 EXPECT_EQ(header->value, expectedResult[1].ToDouble()); |
| 490 EXPECT_EQ(header->description, expectedResult[2]); | 490 EXPECT_EQ(header->description, expectedResult[2]); |
| 491 } | 491 } |
| 492 } | 492 } |
| 493 | 493 |
| 494 TEST(HTTPParsersTest, ParseServerTimingHeader) { | 494 TEST(HTTPParsersTest, ParseServerTimingHeader) { |
| 495 testServerTimingHeader("", {}); | 495 testServerTimingHeader("", {}); |
| 496 testServerTimingHeader("metric", {{"metric", "0", ""}}); | 496 testServerTimingHeader("metric", {{"metric", "0", ""}}); |
| 497 testServerTimingHeader("metric,", {{"metric", "0", ""}}); | 497 testServerTimingHeader("metric,", {{"metric", "0", ""}}); |
| 498 testServerTimingHeader("metric ,", {{"metric", "0", ""}}); | 498 testServerTimingHeader("metric ,", {{"metric", "0", ""}}); |
| 499 testServerTimingHeader("metric;", {{"metric", "0", ""}}); | 499 testServerTimingHeader("metric;", {{"metric", "0", ""}}); |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 | 965 |
| 966 // quoted-string | 966 // quoted-string |
| 967 testServerTimingHeader("metric;\"\"", {{"metric", "0", ""}}); | 967 testServerTimingHeader("metric;\"\"", {{"metric", "0", ""}}); |
| 968 testServerTimingHeader("metric;\"\"\"", {{"metric", "0", ""}}); | 968 testServerTimingHeader("metric;\"\"\"", {{"metric", "0", ""}}); |
| 969 testServerTimingHeader("metric;\"\\\"\"", {{"metric", "0", "\""}}); | 969 testServerTimingHeader("metric;\"\\\"\"", {{"metric", "0", "\""}}); |
| 970 testServerTimingHeader("metric;\"\\\\\"\"", {{"metric", "0", "\\"}}); | 970 testServerTimingHeader("metric;\"\\\\\"\"", {{"metric", "0", "\\"}}); |
| 971 testServerTimingHeader("metric;\"\\\\\\\"\"", {{"metric", "0", "\\\""}}); | 971 testServerTimingHeader("metric;\"\\\\\\\"\"", {{"metric", "0", "\\\""}}); |
| 972 } | 972 } |
| 973 | 973 |
| 974 } // namespace blink | 974 } // namespace blink |
| OLD | NEW |