Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: third_party/WebKit/Source/core/html/track/TextTrackListTest.cpp

Issue 2144543002: Fix invalidating the text track indexes after append or remove text track from the list (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: All with unit tests Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/track/TextTrackList.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/track/TextTrackListTest.cpp
diff --git a/third_party/WebKit/Source/core/html/track/TextTrackListTest.cpp b/third_party/WebKit/Source/core/html/track/TextTrackListTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8e312815fc5e6bd043ff7d6db99c7d9a7e960bf4
--- /dev/null
+++ b/third_party/WebKit/Source/core/html/track/TextTrackListTest.cpp
@@ -0,0 +1,38 @@
+// Copyright 2016 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 "core/html/track/TextTrackList.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+TEST(TextTrackListTest, InvalidateTrackIndexes)
+{
+ // Create and fill the list
+ TextTrackList* list = TextTrackList::create(nullptr);
+ const size_t numTextTracks = 4;
+ TextTrack* textTracks[numTextTracks];
+ for (size_t i = 0; i < numTextTracks; ++i) {
+ textTracks[i] = TextTrack::create("subtitles", "", "");
+ list->append(textTracks[i]);
+ }
+
+ EXPECT_EQ(4u, list->length());
+ EXPECT_EQ(0, textTracks[0]->trackIndex());
+ EXPECT_EQ(1, textTracks[1]->trackIndex());
+ EXPECT_EQ(2, textTracks[2]->trackIndex());
+ EXPECT_EQ(3, textTracks[3]->trackIndex());
+
+ // Remove element from the middle of the list
+ list->remove(textTracks[1]);
+
+ EXPECT_EQ(3u, list->length());
+ EXPECT_EQ(nullptr, textTracks[1]->trackList());
+ EXPECT_EQ(0, textTracks[0]->trackIndex());
+ EXPECT_EQ(1, textTracks[2]->trackIndex());
+ EXPECT_EQ(2, textTracks[3]->trackIndex());
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/html/track/TextTrackList.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698