diff options
author | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-20 00:51:52 +0000 |
---|---|---|
committer | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-20 00:51:52 +0000 |
commit | c566cb79b77ee9dfe3f287fb930c2e9e419793d3 (patch) | |
tree | e5dc3c731b7d7ca2399d412bcf96825b4de67bcf /media/base/ranges_unittest.cc | |
parent | 2767ca041af88d18e387d59c12a49fff10443ce8 (diff) | |
download | chromium_src-c566cb79b77ee9dfe3f287fb930c2e9e419793d3.zip chromium_src-c566cb79b77ee9dfe3f287fb930c2e9e419793d3.tar.gz chromium_src-c566cb79b77ee9dfe3f287fb930c2e9e419793d3.tar.bz2 |
Fix ChunkDemuxer so it properly outputs buffered ranges.
BUG=133042
TEST=None. Verified manually by a simple test page that appends some data
and then checks the buffered attribute. I will convert this to a
LayoutTest soon.
Review URL: https://chromiumcodereview.appspot.com/10558011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143106 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/ranges_unittest.cc')
-rw-r--r-- | media/base/ranges_unittest.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/media/base/ranges_unittest.cc b/media/base/ranges_unittest.cc index 30c00b0..967d138 100644 --- a/media/base/ranges_unittest.cc +++ b/media/base/ranges_unittest.cc @@ -99,4 +99,53 @@ TEST(RangesTest, CoalesceRanges) { ASSERT_RANGES(r, "{ [0,2) }"); } +TEST(RangesTest, IntersectionWith) { + Ranges<int> a; + Ranges<int> b; + + ASSERT_EQ(a.Add(0, 1), 1u) << a; + ASSERT_EQ(a.Add(4, 7), 2u) << a; + ASSERT_EQ(a.Add(10, 12), 3u) << a; + + // Test intersections with an empty range. + ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }"); + ASSERT_RANGES(b, "{ }"); + ASSERT_RANGES(a.IntersectionWith(b), "{ }"); + ASSERT_RANGES(b.IntersectionWith(a), "{ }"); + + // Test intersections with a completely overlaping range. + ASSERT_EQ(b.Add(-1, 13), 1u) << b; + ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }"); + ASSERT_RANGES(b, "{ [-1,13) }"); + ASSERT_RANGES(a.IntersectionWith(b), "{ [0,1) [4,7) [10,12) }"); + ASSERT_RANGES(b.IntersectionWith(a), "{ [0,1) [4,7) [10,12) }"); + + // Test intersections with a disjoint ranges. + b.clear(); + ASSERT_EQ(b.Add(1, 4), 1u) << b; + ASSERT_EQ(b.Add(8, 9), 2u) << b; + ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }"); + ASSERT_RANGES(b, "{ [1,4) [8,9) }"); + ASSERT_RANGES(a.IntersectionWith(b), "{ }"); + ASSERT_RANGES(b.IntersectionWith(a), "{ }"); + + // Test intersections with partially overlapping ranges. + b.clear(); + ASSERT_EQ(b.Add(0, 3), 1u) << b; + ASSERT_EQ(b.Add(5, 11), 2u) << b; + ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }"); + ASSERT_RANGES(b, "{ [0,3) [5,11) }"); + ASSERT_RANGES(a.IntersectionWith(b), "{ [0,1) [5,7) [10,11) }"); + ASSERT_RANGES(b.IntersectionWith(a), "{ [0,1) [5,7) [10,11) }"); + + // Test intersection with a range that starts at the beginning of the + // first range and ends at the end of the last range. + b.clear(); + ASSERT_EQ(b.Add(0, 12), 1u) << b; + ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }"); + ASSERT_RANGES(b, "{ [0,12) }"); + ASSERT_RANGES(a.IntersectionWith(b), "{ [0,1) [4,7) [10,12) }"); + ASSERT_RANGES(b.IntersectionWith(a), "{ [0,1) [4,7) [10,12) }"); +} + } // namespace media |