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

Unified Diff: media/filters/video_frame_scheduler_unittest.cc

Issue 257793004: Update VideoFrameScheduler API and add clockless and testing implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 6 years, 8 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 | « media/filters/video_frame_scheduler_impl_unittest.cc ('k') | media/media.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/video_frame_scheduler_unittest.cc
diff --git a/media/filters/video_frame_scheduler_unittest.cc b/media/filters/video_frame_scheduler_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..02b64ae82634bbd056ec2be13b6c2e4381ac37c9
--- /dev/null
+++ b/media/filters/video_frame_scheduler_unittest.cc
@@ -0,0 +1,80 @@
+// Copyright 2014 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 "base/bind.h"
+#include "base/debug/stack_trace.h"
+#include "base/run_loop.h"
+#include "media/base/video_frame.h"
+#include "media/filters/clockless_video_frame_scheduler.h"
+#include "media/filters/test_video_frame_scheduler.h"
+#include "media/filters/video_frame_scheduler_impl.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace media {
+
+static void DoNothing(const scoped_refptr<VideoFrame>& frame) {
+}
+
+static void CheckForReentrancy(std::string* stack_trace,
+ const scoped_refptr<VideoFrame>& frame,
+ VideoFrameScheduler::Reason reason) {
+ *stack_trace = base::debug::StackTrace().ToString();
+ base::MessageLoop::current()->PostTask(FROM_HERE,
+ base::MessageLoop::QuitClosure());
+}
+
+// Type parameterized test harness for validating API contract of
+// VideoFrameScheduler implementations.
+//
+// NOTE: C++ requires using "this" for derived class templates when referencing
+// class members.
+template <typename T>
+class VideoFrameSchedulerTest : public testing::Test {
+ public:
+ VideoFrameSchedulerTest() {}
+ virtual ~VideoFrameSchedulerTest() {}
+
+ base::MessageLoop message_loop_;
+ T scheduler_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(VideoFrameSchedulerTest);
+};
+
+template <>
+VideoFrameSchedulerTest<ClocklessVideoFrameScheduler>::VideoFrameSchedulerTest()
+ : scheduler_(base::Bind(&DoNothing)) {
+}
+
+template <>
+VideoFrameSchedulerTest<VideoFrameSchedulerImpl>::VideoFrameSchedulerTest()
+ : scheduler_(message_loop_.message_loop_proxy(), base::Bind(&DoNothing)) {
+}
+
+TYPED_TEST_CASE_P(VideoFrameSchedulerTest);
+
+TYPED_TEST_P(VideoFrameSchedulerTest, ScheduleVideoFrameIsntReentrant) {
+ scoped_refptr<VideoFrame> frame =
+ VideoFrame::CreateBlackFrame(gfx::Size(8, 8));
+
+ std::string stack_trace;
+ this->scheduler_.ScheduleVideoFrame(
+ frame, base::TimeTicks(), base::Bind(&CheckForReentrancy, &stack_trace));
+ EXPECT_TRUE(stack_trace.empty()) << "Reentracy detected:\n" << stack_trace;
+}
+
+REGISTER_TYPED_TEST_CASE_P(VideoFrameSchedulerTest,
+ ScheduleVideoFrameIsntReentrant);
+
+INSTANTIATE_TYPED_TEST_CASE_P(ClocklessVideoFrameScheduler,
+ VideoFrameSchedulerTest,
+ ClocklessVideoFrameScheduler);
+INSTANTIATE_TYPED_TEST_CASE_P(VideoFrameSchedulerImpl,
+ VideoFrameSchedulerTest,
+ VideoFrameSchedulerImpl);
+INSTANTIATE_TYPED_TEST_CASE_P(TestVideoFrameScheduler,
+ VideoFrameSchedulerTest,
+ TestVideoFrameScheduler);
+
+} // namespace media
« no previous file with comments | « media/filters/video_frame_scheduler_impl_unittest.cc ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698