| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/http/http_util.h" | |
| 6 #include "webkit/glue/media/media_resource_loader_bridge_factory.h" | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 namespace webkit_glue { | |
| 10 | |
| 11 TEST(MediaResourceLoaderBridgeFactoryTest, GenerateHeaders) { | |
| 12 static const struct { | |
| 13 const bool success; | |
| 14 const int64 first_byte_position; | |
| 15 const int64 last_byte_position; | |
| 16 } data[] = { | |
| 17 { false, -1, -1 }, | |
| 18 { false, -5, 0 }, | |
| 19 { false, 100, 0 }, | |
| 20 { true, 0, -1 }, | |
| 21 { true, 0, 0 }, | |
| 22 { true, 100, 100 }, | |
| 23 { true, 50, -1 }, | |
| 24 { true, 10000, -1 }, | |
| 25 { true, 50, 100 }, | |
| 26 }; | |
| 27 | |
| 28 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { | |
| 29 std::string headers = MediaResourceLoaderBridgeFactory::GenerateHeaders( | |
| 30 data[i].first_byte_position, data[i].last_byte_position); | |
| 31 std::vector<net::HttpByteRange> ranges; | |
| 32 bool ret = net::HttpUtil::ParseRanges(headers, &ranges); | |
| 33 EXPECT_EQ(data[i].success, ret); | |
| 34 if (ret) { | |
| 35 EXPECT_EQ(1u, ranges.size()); | |
| 36 EXPECT_EQ(data[i].first_byte_position, | |
| 37 ranges[0].first_byte_position()); | |
| 38 EXPECT_EQ(data[i].last_byte_position, | |
| 39 ranges[0].last_byte_position()); | |
| 40 } | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 } // namespace webkit_glue | |
| OLD | NEW |