OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/blink/cache_util.h" | 5 #include "media/blink/cache_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "third_party/WebKit/public/platform/WebString.h" | 15 #include "third_party/WebKit/public/platform/WebString.h" |
16 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 16 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
17 | 17 |
18 using blink::WebString; | 18 using blink::WebString; |
19 using blink::WebURLResponse; | 19 using blink::WebURLResponse; |
20 | 20 |
21 namespace media { | 21 namespace media { |
22 | 22 |
23 // Inputs & expected output for GetReasonsForUncacheability. | 23 // Inputs & expected output for GetReasonsForUncacheability. |
24 struct GRFUTestCase { | 24 struct GRFUTestCase { |
25 WebURLResponse::HTTPVersion version; | 25 WebURLResponse::HTTPVersion version; |
26 int status_code; | 26 int status_code; |
27 const char* headers; | 27 const char* headers; |
28 uint32 expected_reasons; | 28 uint32_t expected_reasons; |
29 }; | 29 }; |
30 | 30 |
31 // Create a new WebURLResponse object. | 31 // Create a new WebURLResponse object. |
32 static WebURLResponse CreateResponse(const GRFUTestCase& test) { | 32 static WebURLResponse CreateResponse(const GRFUTestCase& test) { |
33 WebURLResponse response; | 33 WebURLResponse response; |
34 response.initialize(); | 34 response.initialize(); |
35 response.setHTTPVersion(test.version); | 35 response.setHTTPVersion(test.version); |
36 response.setHTTPStatusCode(test.status_code); | 36 response.setHTTPStatusCode(test.status_code); |
37 for (const std::string& line : | 37 for (const std::string& line : |
38 base::SplitString(test.headers, "\n", base::KEEP_WHITESPACE, | 38 base::SplitString(test.headers, "\n", base::KEEP_WHITESPACE, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 SCOPED_TRACE(base::StringPrintf("case: %" PRIuS | 75 SCOPED_TRACE(base::StringPrintf("case: %" PRIuS |
76 ", version: %d, code: %d, headers: %s", | 76 ", version: %d, code: %d, headers: %s", |
77 i, tests[i].version, tests[i].status_code, | 77 i, tests[i].version, tests[i].status_code, |
78 tests[i].headers)); | 78 tests[i].headers)); |
79 EXPECT_EQ(GetReasonsForUncacheability(CreateResponse(tests[i])), | 79 EXPECT_EQ(GetReasonsForUncacheability(CreateResponse(tests[i])), |
80 tests[i].expected_reasons); | 80 tests[i].expected_reasons); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 } // namespace media | 84 } // namespace media |
OLD | NEW |