summaryrefslogtreecommitdiffstats
path: root/media/blink/cache_util_unittest.cc
diff options
context:
space:
mode:
authoracolwell <acolwell@chromium.org>2014-09-06 12:01:32 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-06 19:06:46 +0000
commit9e0840d0672da96350a1f33d684f2c64d2574f46 (patch)
tree6d72e3d50fcfd66f70a58c5d3583358055de4d9a /media/blink/cache_util_unittest.cc
parent87a3ebac6b26918b151151efed3311d0ddc20d73 (diff)
downloadchromium_src-9e0840d0672da96350a1f33d684f2c64d2574f46.zip
chromium_src-9e0840d0672da96350a1f33d684f2c64d2574f46.tar.gz
chromium_src-9e0840d0672da96350a1f33d684f2c64d2574f46.tar.bz2
Move WebMediaPlayerImpl and its dependencies to media/blink.
Moving WebMediaPlayerImpl and related classes in content/renderer/media to media/blink so that they can be reused by Mojo code. BUG=408338 Review URL: https://codereview.chromium.org/495353003 Cr-Commit-Position: refs/heads/master@{#293628}
Diffstat (limited to 'media/blink/cache_util_unittest.cc')
-rw-r--r--media/blink/cache_util_unittest.cc97
1 files changed, 97 insertions, 0 deletions
diff --git a/media/blink/cache_util_unittest.cc b/media/blink/cache_util_unittest.cc
new file mode 100644
index 0000000..7ea2f13
--- /dev/null
+++ b/media/blink/cache_util_unittest.cc
@@ -0,0 +1,97 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/blink/cache_util.h"
+
+#include <string>
+
+#include "base/format_macros.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/public/platform/WebString.h"
+#include "third_party/WebKit/public/platform/WebURLResponse.h"
+
+using blink::WebString;
+using blink::WebURLResponse;
+
+namespace media {
+
+// Inputs & expected output for GetReasonsForUncacheability.
+struct GRFUTestCase {
+ WebURLResponse::HTTPVersion version;
+ int status_code;
+ const char* headers;
+ uint32 expected_reasons;
+};
+
+// Create a new WebURLResponse object.
+static WebURLResponse CreateResponse(const GRFUTestCase& test) {
+ WebURLResponse response;
+ response.initialize();
+ response.setHTTPVersion(test.version);
+ response.setHTTPStatusCode(test.status_code);
+ std::vector<std::string> lines;
+ Tokenize(test.headers, "\n", &lines);
+ for (size_t i = 0; i < lines.size(); ++i) {
+ size_t colon = lines[i].find(": ");
+ response.addHTTPHeaderField(
+ WebString::fromUTF8(lines[i].substr(0, colon)),
+ WebString::fromUTF8(lines[i].substr(colon + 2)));
+ }
+ return response;
+}
+
+TEST(CacheUtilTest, GetReasonsForUncacheability) {
+ enum { kNoReasons = 0 };
+
+ const GRFUTestCase tests[] = {
+ {
+ WebURLResponse::HTTP_1_1, 206, "ETag: 'fooblort'", kNoReasons
+ },
+ {
+ WebURLResponse::HTTP_1_1, 206, "", kNoStrongValidatorOnPartialResponse
+ },
+ {
+ WebURLResponse::HTTP_1_0, 206, "",
+ kPre11PartialResponse | kNoStrongValidatorOnPartialResponse
+ },
+ {
+ WebURLResponse::HTTP_1_1, 200, "cache-control: max-Age=42", kShortMaxAge
+ },
+ {
+ WebURLResponse::HTTP_1_1, 200, "cache-control: max-Age=4200", kNoReasons
+ },
+ {
+ WebURLResponse::HTTP_1_1, 200,
+ "Date: Tue, 22 May 2012 23:46:08 GMT\n"
+ "Expires: Tue, 22 May 2012 23:56:08 GMT", kExpiresTooSoon
+ },
+ {
+ WebURLResponse::HTTP_1_1, 200, "cache-control: must-revalidate",
+ kHasMustRevalidate
+ },
+ {
+ WebURLResponse::HTTP_1_1, 200, "cache-control: no-cache", kNoCache
+ },
+ {
+ WebURLResponse::HTTP_1_1, 200, "cache-control: no-store", kNoStore
+ },
+ {
+ WebURLResponse::HTTP_1_1, 200,
+ "cache-control: no-cache\ncache-control: no-store", kNoCache | kNoStore
+ },
+ };
+ for (size_t i = 0; i < arraysize(tests); ++i) {
+ SCOPED_TRACE(base::StringPrintf("case: %" PRIuS
+ ", version: %d, code: %d, headers: %s",
+ i, tests[i].version, tests[i].status_code,
+ tests[i].headers));
+ EXPECT_EQ(GetReasonsForUncacheability(CreateResponse(tests[i])),
+ tests[i].expected_reasons);
+ }
+}
+
+} // namespace media