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

Side by Side Diff: content/browser/media/capture/video_capture_oracle_unittest.cc

Issue 986823002: De-dupe copy requests for tab capture in DelegatedFrameHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove redundant portion of new test. Created 5 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
OLDNEW
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 <cstdlib> 7 #include <cstdlib>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 damage_rect, t)); 1138 damage_rect, t));
1139 last_frame_number = oracle.RecordCapture(); 1139 last_frame_number = oracle.RecordCapture();
1140 } 1140 }
1141 ASSERT_TRUE(oracle.CompleteCapture(last_frame_number, &ignored)); 1141 ASSERT_TRUE(oracle.CompleteCapture(last_frame_number, &ignored));
1142 for (int j = 1; j < num_in_flight; ++j) { 1142 for (int j = 1; j < num_in_flight; ++j) {
1143 ASSERT_FALSE(oracle.CompleteCapture(last_frame_number - j, &ignored)); 1143 ASSERT_FALSE(oracle.CompleteCapture(last_frame_number - j, &ignored));
1144 } 1144 }
1145 } 1145 }
1146 } 1146 }
1147 1147
1148 // Tests that VideoCaptureOracle modifies the timestamp of an older capture when
1149 // newer captures have been aborted before the older one succeeds (since the
1150 // older frame will contain newer content).
1151 TEST(VideoCaptureOracleTest, ModifiesTimestampsDueToAbortedCaptures) {
1152 const base::TimeDelta min_capture_period =
1153 base::TimeDelta::FromSeconds(1) / 30;
1154 const gfx::Rect empty_damage_rect;
1155 const base::TimeDelta event_increment = min_capture_period * 2;
1156
1157 VideoCaptureOracle oracle(min_capture_period);
1158
1159 // Start with a stream of captures alternating success vs failure.
1160 base::TimeTicks t = InitialTestTimeTicks();
1161 int last_frame_number;
1162 base::TimeTicks timestamp;
1163 for (int i = 0; i < 10; ++i) {
1164 t += event_increment;
1165 ASSERT_TRUE(oracle.ObserveEventAndDecideCapture(
1166 VideoCaptureOracle::kCompositorUpdate,
1167 empty_damage_rect, t));
1168 last_frame_number = oracle.RecordCapture();
1169 if (i % 2 == 0) {
1170 ASSERT_TRUE(oracle.CompleteCapture(last_frame_number, &timestamp));
1171 ASSERT_EQ(t, timestamp);
1172 } else {
1173 oracle.CaptureAbortedOrFailed(last_frame_number);
1174 }
1175 }
1176
1177 // One capture will succeed after the 1 to 3 captures scheduled after it are
1178 // first aborted.
1179 for (int num_aborts = 1; num_aborts <= 3; ++num_aborts) {
1180 t += event_increment;
1181 ASSERT_TRUE(oracle.ObserveEventAndDecideCapture(
1182 VideoCaptureOracle::kCompositorUpdate,
1183 empty_damage_rect, t));
1184 last_frame_number = oracle.RecordCapture();
1185 for (int i = 0; i < num_aborts; ++i) {
1186 t += event_increment;
1187 ASSERT_TRUE(oracle.ObserveEventAndDecideCapture(
1188 VideoCaptureOracle::kCompositorUpdate,
1189 empty_damage_rect, t));
1190 last_frame_number = oracle.RecordCapture();
1191 oracle.CaptureAbortedOrFailed(last_frame_number);
1192 }
1193 ASSERT_TRUE(oracle.CompleteCapture(
1194 last_frame_number - num_aborts, &timestamp));
1195 ASSERT_EQ(t, timestamp);
1196 }
1197 }
1198
1148 // Tests that VideoCaptureOracle transitions between using its two samplers in a 1199 // Tests that VideoCaptureOracle transitions between using its two samplers in a
1149 // way that does not introduce severe jank, pauses, etc. 1200 // way that does not introduce severe jank, pauses, etc.
1150 TEST(VideoCaptureOracleTest, TransitionsSmoothlyBetweenSamplers) { 1201 TEST(VideoCaptureOracleTest, TransitionsSmoothlyBetweenSamplers) {
1151 const base::TimeDelta min_capture_period = 1202 const base::TimeDelta min_capture_period =
1152 base::TimeDelta::FromSeconds(1) / 30; 1203 base::TimeDelta::FromSeconds(1) / 30;
1153 const gfx::Rect animation_damage_rect(0, 0, 1280, 720); 1204 const gfx::Rect animation_damage_rect(0, 0, 1280, 720);
1154 const base::TimeDelta event_increment = min_capture_period * 2; 1205 const base::TimeDelta event_increment = min_capture_period * 2;
1155 1206
1156 VideoCaptureOracle oracle(min_capture_period); 1207 VideoCaptureOracle oracle(min_capture_period);
1157 1208
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 // |event_increment|. 1248 // |event_increment|.
1198 const base::TimeDelta max_acceptable_delta = (i % 100) == 78 ? 1249 const base::TimeDelta max_acceptable_delta = (i % 100) == 78 ?
1199 event_increment * 5 : event_increment * 2; 1250 event_increment * 5 : event_increment * 2;
1200 EXPECT_GE(max_acceptable_delta.InMicroseconds(), delta.InMicroseconds()); 1251 EXPECT_GE(max_acceptable_delta.InMicroseconds(), delta.InMicroseconds());
1201 } 1252 }
1202 last_frame_timestamp = frame_timestamp; 1253 last_frame_timestamp = frame_timestamp;
1203 } 1254 }
1204 } 1255 }
1205 1256
1206 } // namespace content 1257 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698