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

Unified Diff: media/capture/content/video_capture_oracle_unittest.cc

Issue 2770923003: TabCapture: enforce active refresh if there is un-sampled compositor update (Closed)
Patch Set: Apply suggested patch Created 3 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 side-by-side diff with in-line comments
Download patch
Index: media/capture/content/video_capture_oracle_unittest.cc
diff --git a/media/capture/content/video_capture_oracle_unittest.cc b/media/capture/content/video_capture_oracle_unittest.cc
index fcfa40c469178c924ea86f65e432190c7341e994..9b110024fb491599bb782d05fc37916553e6b0cc 100644
--- a/media/capture/content/video_capture_oracle_unittest.cc
+++ b/media/capture/content/video_capture_oracle_unittest.cc
@@ -350,6 +350,42 @@ TEST(VideoCaptureOracleTest, DoesNotRapidlyChangeCaptureSize) {
}
}
+// Tests that un-sampled compositor update event will fail the next passive
+// refresh request to force an active refresh.
miu 2017/03/24 21:19:39 nit: s/refresh request to force/refresh request, f
braveyao 2017/03/24 23:12:27 Done.
+TEST(VideoCaptureOracleTest, EnforceActiveRefreshForUnsampledCompositorUpdate) {
+ const gfx::Rect damage_rect(Get720pSize());
+ const base::TimeDelta event_increment = Get30HzPeriod() * 2;
+ const base::TimeDelta short_event_increment = Get30HzPeriod() / 4;
+
+ VideoCaptureOracle oracle(Get30HzPeriod(), Get720pSize(),
+ media::RESOLUTION_POLICY_FIXED_RESOLUTION, false);
+
+ base::TimeTicks t = InitialTestTimeTicks();
+ int last_frame_number;
+ base::TimeTicks ignored;
+
+ // CompositorUpdate is sampled normally.
+ t += event_increment;
+ ASSERT_TRUE(oracle.ObserveEventAndDecideCapture(
+ VideoCaptureOracle::kCompositorUpdate, damage_rect, t));
+ last_frame_number = oracle.next_frame_number();
+ oracle.RecordCapture(0.0);
+ ASSERT_TRUE(oracle.CompleteCapture(last_frame_number, true, &ignored));
+
+ // Next CompositorUpdate comes too soon and won't be sampled.
+ t += short_event_increment;
+ ASSERT_FALSE(oracle.ObserveEventAndDecideCapture(
+ VideoCaptureOracle::kCompositorUpdate, damage_rect, t));
+
+ // Then the next valid PassiveRefreshRequest will fail to enforce an
+ // ActiveRefreshRequest to capture the updated content.
+ t += event_increment;
+ ASSERT_FALSE(oracle.ObserveEventAndDecideCapture(
+ VideoCaptureOracle::kPassiveRefreshRequest, damage_rect, t));
+ ASSERT_TRUE(oracle.ObserveEventAndDecideCapture(
+ VideoCaptureOracle::kActiveRefreshRequest, damage_rect, t));
+}
+
namespace {
// Tests that VideoCaptureOracle can auto-throttle by stepping the capture size

Powered by Google App Engine
This is Rietveld 408576698