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

Side by Side Diff: content/renderer/media/video_frame_compositor_unittest.cc

Issue 214823005: Remove requirement of compositing a video frame for dropped frame count. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "cc/layers/video_frame_provider.h" 7 #include "cc/layers/video_frame_provider.h"
8 #include "content/renderer/media/video_frame_compositor.h" 8 #include "content/renderer/media/video_frame_compositor.h"
9 #include "media/base/video_frame.h" 9 #include "media/base/video_frame.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 EXPECT_EQ(2, natural_size_changed_count()); 125 EXPECT_EQ(2, natural_size_changed_count());
126 } 126 }
127 127
128 TEST_F(VideoFrameCompositorTest, GetFramesDroppedBeforeComposite) { 128 TEST_F(VideoFrameCompositorTest, GetFramesDroppedBeforeComposite) {
129 scoped_refptr<VideoFrame> frame = VideoFrame::CreateEOSFrame(); 129 scoped_refptr<VideoFrame> frame = VideoFrame::CreateEOSFrame();
130 130
131 compositor()->UpdateCurrentFrame(frame); 131 compositor()->UpdateCurrentFrame(frame);
132 EXPECT_EQ(0, did_receive_frame_count()); 132 EXPECT_EQ(0, did_receive_frame_count());
133 EXPECT_EQ(0u, compositor()->GetFramesDroppedBeforeComposite()); 133 EXPECT_EQ(0u, compositor()->GetFramesDroppedBeforeComposite());
134 134
135 // Should not increment if we finished notifying the compositor but didn't 135 // Should not increment if we finished notifying the compositor.
136 // composite the frame.
137 // 136 //
138 // This covers the scenario where the region we're rendering isn't 137 // This covers the normal scenario where the compositor is getting
139 // visible so there wasn't a need to composite. 138 // notifications in a timely manner.
140 message_loop()->RunUntilIdle(); 139 message_loop()->RunUntilIdle();
141 compositor()->UpdateCurrentFrame(frame); 140 compositor()->UpdateCurrentFrame(frame);
142 EXPECT_EQ(1, did_receive_frame_count()); 141 EXPECT_EQ(1, did_receive_frame_count());
143 EXPECT_EQ(0u, compositor()->GetFramesDroppedBeforeComposite()); 142 EXPECT_EQ(0u, compositor()->GetFramesDroppedBeforeComposite());
144 143
145 // Should not increment if we didn't finish notifying the compositor but still 144 // Should increment if we didn't notify the compositor.
146 // managed to composite the frame.
147 // 145 //
148 // This covers the scenario where something else may have notified the 146 // This covers the scenario where the compositor is falling behind.
149 // compositor and managed to composite the current frame. 147 // Consider it dropped.
150 message_loop()->RunUntilIdle();
151 provider()->GetCurrentFrame();
152 provider()->PutCurrentFrame(NULL);
153 compositor()->UpdateCurrentFrame(frame);
154 EXPECT_EQ(2, did_receive_frame_count());
155 EXPECT_EQ(0u, compositor()->GetFramesDroppedBeforeComposite());
156
157 // Should increment if we didn't notify the compositor and didn't composite
158 // the frame.
159 //
160 // This covers the scenario where we didn't even finish notifying nor
161 // compositing the current frame before updating. Consider it dropped.
162 message_loop()->RunUntilIdle(); 148 message_loop()->RunUntilIdle();
163 compositor()->UpdateCurrentFrame(frame); 149 compositor()->UpdateCurrentFrame(frame);
164 compositor()->UpdateCurrentFrame(frame); 150 compositor()->UpdateCurrentFrame(frame);
165 EXPECT_EQ(3, did_receive_frame_count()); 151 EXPECT_EQ(2, did_receive_frame_count());
166 EXPECT_EQ(1u, compositor()->GetFramesDroppedBeforeComposite()); 152 EXPECT_EQ(1u, compositor()->GetFramesDroppedBeforeComposite());
167 153
168 // Shouldn't overflow. 154 // Shouldn't overflow.
169 compositor()->SetFramesDroppedBeforeCompositeForTesting(kuint32max); 155 compositor()->SetFramesDroppedBeforeCompositeForTesting(kuint32max);
170 compositor()->UpdateCurrentFrame(frame); 156 compositor()->UpdateCurrentFrame(frame);
171 EXPECT_EQ(kuint32max, compositor()->GetFramesDroppedBeforeComposite()); 157 EXPECT_EQ(kuint32max, compositor()->GetFramesDroppedBeforeComposite());
172 } 158 }
173 159
174 } // namespace content 160 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698