This source file includes following definitions.
- AddCue
- Reset
- RangeCount
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
#include "media/base/text_ranges.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace media {
class TextRangesTest : public ::testing::Test {
protected:
bool AddCue(int seconds) {
return ranges_.AddCue(base::TimeDelta::FromSeconds(seconds));
}
void Reset() {
ranges_.Reset();
}
size_t RangeCount() {
return ranges_.RangeCountForTesting();
}
TextRanges ranges_;
};
TEST_F(TextRangesTest, TestEmptyRanges) {
EXPECT_TRUE(AddCue(5));
Reset();
EXPECT_TRUE(AddCue(2));
Reset();
EXPECT_TRUE(AddCue(8));
Reset();
EXPECT_FALSE(AddCue(2));
EXPECT_EQ(RangeCount(), 3U);
EXPECT_FALSE(AddCue(5));
EXPECT_EQ(RangeCount(), 2U);
EXPECT_FALSE(AddCue(8));
EXPECT_EQ(RangeCount(), 1U);
EXPECT_TRUE(AddCue(9));
EXPECT_EQ(RangeCount(), 1U);
}
TEST_F(TextRangesTest, TestOneRange) {
EXPECT_TRUE(AddCue(0));
EXPECT_TRUE(AddCue(1));
EXPECT_TRUE(AddCue(4));
Reset();
EXPECT_FALSE(AddCue(2));
EXPECT_FALSE(AddCue(3));
EXPECT_FALSE(AddCue(4));
}
TEST_F(TextRangesTest, TestDuplicateLast) {
EXPECT_TRUE(AddCue(0));
EXPECT_TRUE(AddCue(1));
Reset();
EXPECT_FALSE(AddCue(1));
EXPECT_TRUE(AddCue(1));
}
TEST_F(TextRangesTest, TestTwoRanges) {
EXPECT_TRUE(AddCue(0));
EXPECT_TRUE(AddCue(2));
Reset();
EXPECT_TRUE(AddCue(4));
EXPECT_TRUE(AddCue(5));
Reset();
EXPECT_FALSE(AddCue(0));
EXPECT_FALSE(AddCue(2));
EXPECT_TRUE(AddCue(3));
EXPECT_FALSE(AddCue(4));
EXPECT_EQ(RangeCount(), 1U);
}
TEST_F(TextRangesTest, TestThreeRanges) {
EXPECT_TRUE(AddCue(0));
EXPECT_TRUE(AddCue(2));
Reset();
EXPECT_TRUE(AddCue(4));
EXPECT_TRUE(AddCue(5));
Reset();
EXPECT_TRUE(AddCue(3));
EXPECT_FALSE(AddCue(4));
Reset();
EXPECT_FALSE(AddCue(0));
EXPECT_FALSE(AddCue(2));
EXPECT_FALSE(AddCue(3));
EXPECT_EQ(RangeCount(), 1U);
}
}