OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/media/capture/video_capture_oracle.h" | 5 #include "content/browser/media/capture/video_capture_oracle.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // dropped, because the AnimatedContentSampler doesn't yet realize the | 137 // dropped, because the AnimatedContentSampler doesn't yet realize the |
138 // animation ended. Otherwise, the oracle should always decide to sample | 138 // animation ended. Otherwise, the oracle should always decide to sample |
139 // because one of its samplers says to. | 139 // because one of its samplers says to. |
140 const bool require_oracle_says_sample = (i % 100) < 75 || (i % 100) >= 78; | 140 const bool require_oracle_says_sample = (i % 100) < 75 || (i % 100) >= 78; |
141 const bool oracle_says_sample = oracle.ObserveEventAndDecideCapture( | 141 const bool oracle_says_sample = oracle.ObserveEventAndDecideCapture( |
142 VideoCaptureOracle::kCompositorUpdate, | 142 VideoCaptureOracle::kCompositorUpdate, |
143 provide_animated_content_event ? animation_damage_rect : gfx::Rect(), | 143 provide_animated_content_event ? animation_damage_rect : gfx::Rect(), |
144 t); | 144 t); |
145 if (require_oracle_says_sample) | 145 if (require_oracle_says_sample) |
146 ASSERT_TRUE(oracle_says_sample); | 146 ASSERT_TRUE(oracle_says_sample); |
147 if (!oracle_says_sample) | 147 if (!oracle_says_sample) { |
| 148 ASSERT_EQ(base::TimeDelta(), oracle.estimated_frame_duration()); |
148 continue; | 149 continue; |
| 150 } |
| 151 ASSERT_LT(base::TimeDelta(), oracle.estimated_frame_duration()); |
149 | 152 |
150 const int frame_number = oracle.RecordCapture(); | 153 const int frame_number = oracle.RecordCapture(); |
151 | 154 |
152 base::TimeTicks frame_timestamp; | 155 base::TimeTicks frame_timestamp; |
153 ASSERT_TRUE(oracle.CompleteCapture(frame_number, &frame_timestamp)); | 156 ASSERT_TRUE(oracle.CompleteCapture(frame_number, &frame_timestamp)); |
154 ASSERT_FALSE(frame_timestamp.is_null()); | 157 ASSERT_FALSE(frame_timestamp.is_null()); |
155 if (!last_frame_timestamp.is_null()) { | 158 if (!last_frame_timestamp.is_null()) { |
156 const base::TimeDelta delta = frame_timestamp - last_frame_timestamp; | 159 const base::TimeDelta delta = frame_timestamp - last_frame_timestamp; |
157 EXPECT_LE(event_increment.InMicroseconds(), delta.InMicroseconds()); | 160 EXPECT_LE(event_increment.InMicroseconds(), delta.InMicroseconds()); |
158 // Right after the AnimatedContentSampler lock-out transition, there were | 161 // Right after the AnimatedContentSampler lock-out transition, there were |
159 // a few frames dropped, so allow a gap in the timestamps. Otherwise, the | 162 // a few frames dropped, so allow a gap in the timestamps. Otherwise, the |
160 // delta between frame timestamps should never be more than 2X the | 163 // delta between frame timestamps should never be more than 2X the |
161 // |event_increment|. | 164 // |event_increment|. |
162 const base::TimeDelta max_acceptable_delta = (i % 100) == 78 ? | 165 const base::TimeDelta max_acceptable_delta = (i % 100) == 78 ? |
163 event_increment * 5 : event_increment * 2; | 166 event_increment * 5 : event_increment * 2; |
164 EXPECT_GE(max_acceptable_delta.InMicroseconds(), delta.InMicroseconds()); | 167 EXPECT_GE(max_acceptable_delta.InMicroseconds(), delta.InMicroseconds()); |
165 } | 168 } |
166 last_frame_timestamp = frame_timestamp; | 169 last_frame_timestamp = frame_timestamp; |
167 } | 170 } |
168 } | 171 } |
169 | 172 |
170 } // namespace content | 173 } // namespace content |
OLD | NEW |