From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- dom/media/gtest/mp4_demuxer/TestInterval.cpp | 88 ++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 dom/media/gtest/mp4_demuxer/TestInterval.cpp (limited to 'dom/media/gtest/mp4_demuxer/TestInterval.cpp') diff --git a/dom/media/gtest/mp4_demuxer/TestInterval.cpp b/dom/media/gtest/mp4_demuxer/TestInterval.cpp new file mode 100644 index 0000000000..2572b1c392 --- /dev/null +++ b/dom/media/gtest/mp4_demuxer/TestInterval.cpp @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "gtest/gtest.h" +#include "MP4Interval.h" + +using mozilla::MP4Interval; + +TEST(MP4Interval, Length) +{ + MP4Interval i(15, 25); + EXPECT_EQ(10, i.Length()); +} + +TEST(MP4Interval, Intersection) +{ + MP4Interval i0(10, 20); + MP4Interval i1(15, 25); + MP4Interval i = i0.Intersection(i1); + EXPECT_EQ(15, i.start); + EXPECT_EQ(20, i.end); +} + +TEST(MP4Interval, Equals) +{ + MP4Interval i0(10, 20); + MP4Interval i1(10, 20); + EXPECT_EQ(i0, i1); + + MP4Interval i2(5, 20); + EXPECT_NE(i0, i2); + + MP4Interval i3(10, 15); + EXPECT_NE(i0, i2); +} + +TEST(MP4Interval, IntersectionVector) +{ + nsTArray> i0; + i0.AppendElement(MP4Interval(5, 10)); + i0.AppendElement(MP4Interval(20, 25)); + i0.AppendElement(MP4Interval(40, 60)); + + nsTArray> i1; + i1.AppendElement(MP4Interval(7, 15)); + i1.AppendElement(MP4Interval(16, 27)); + i1.AppendElement(MP4Interval(45, 50)); + i1.AppendElement(MP4Interval(53, 57)); + + nsTArray> i; + MP4Interval::Intersection(i0, i1, &i); + + EXPECT_EQ(4u, i.Length()); + + EXPECT_EQ(7, i[0].start); + EXPECT_EQ(10, i[0].end); + + EXPECT_EQ(20, i[1].start); + EXPECT_EQ(25, i[1].end); + + EXPECT_EQ(45, i[2].start); + EXPECT_EQ(50, i[2].end); + + EXPECT_EQ(53, i[3].start); + EXPECT_EQ(57, i[3].end); +} + +TEST(MP4Interval, Normalize) +{ + nsTArray> i; + i.AppendElement(MP4Interval(20, 30)); + i.AppendElement(MP4Interval(1, 8)); + i.AppendElement(MP4Interval(5, 10)); + i.AppendElement(MP4Interval(2, 7)); + + nsTArray> o; + MP4Interval::Normalize(i, &o); + + EXPECT_EQ(2u, o.Length()); + + EXPECT_EQ(1, o[0].start); + EXPECT_EQ(10, o[0].end); + + EXPECT_EQ(20, o[1].start); + EXPECT_EQ(30, o[1].end); +} -- cgit v1.2.3