| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 "media/capture/content/video_capture_oracle.h" | 5 #include "media/capture/content/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 media { | 10 namespace media { |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 last_capture_size = oracle.capture_size(); | 343 last_capture_size = oracle.capture_size(); |
| 344 } | 344 } |
| 345 | 345 |
| 346 base::TimeTicks ignored; | 346 base::TimeTicks ignored; |
| 347 const int frame_number = oracle.next_frame_number(); | 347 const int frame_number = oracle.next_frame_number(); |
| 348 oracle.RecordCapture(0.0); | 348 oracle.RecordCapture(0.0); |
| 349 ASSERT_TRUE(oracle.CompleteCapture(frame_number, true, &ignored)); | 349 ASSERT_TRUE(oracle.CompleteCapture(frame_number, true, &ignored)); |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 | 352 |
| 353 // Tests that un-sampled compositor update event will fail the next passive |
| 354 // refresh request, forcing an active refresh. |
| 355 TEST(VideoCaptureOracleTest, EnforceActiveRefreshForUnsampledCompositorUpdate) { |
| 356 const gfx::Rect damage_rect(Get720pSize()); |
| 357 const base::TimeDelta event_increment = Get30HzPeriod() * 2; |
| 358 const base::TimeDelta short_event_increment = Get30HzPeriod() / 4; |
| 359 |
| 360 VideoCaptureOracle oracle(Get30HzPeriod(), Get720pSize(), |
| 361 media::RESOLUTION_POLICY_FIXED_RESOLUTION, false); |
| 362 |
| 363 base::TimeTicks t = InitialTestTimeTicks(); |
| 364 int last_frame_number; |
| 365 base::TimeTicks ignored; |
| 366 |
| 367 // CompositorUpdate is sampled normally. |
| 368 t += event_increment; |
| 369 ASSERT_TRUE(oracle.ObserveEventAndDecideCapture( |
| 370 VideoCaptureOracle::kCompositorUpdate, damage_rect, t)); |
| 371 last_frame_number = oracle.next_frame_number(); |
| 372 oracle.RecordCapture(0.0); |
| 373 ASSERT_TRUE(oracle.CompleteCapture(last_frame_number, true, &ignored)); |
| 374 |
| 375 // Next CompositorUpdate comes too soon and won't be sampled. |
| 376 t += short_event_increment; |
| 377 ASSERT_FALSE(oracle.ObserveEventAndDecideCapture( |
| 378 VideoCaptureOracle::kCompositorUpdate, damage_rect, t)); |
| 379 |
| 380 // Then the next valid PassiveRefreshRequest will fail to enforce an |
| 381 // ActiveRefreshRequest to capture the updated content. |
| 382 t += event_increment; |
| 383 ASSERT_FALSE(oracle.ObserveEventAndDecideCapture( |
| 384 VideoCaptureOracle::kPassiveRefreshRequest, damage_rect, t)); |
| 385 ASSERT_TRUE(oracle.ObserveEventAndDecideCapture( |
| 386 VideoCaptureOracle::kActiveRefreshRequest, damage_rect, t)); |
| 387 } |
| 388 |
| 353 namespace { | 389 namespace { |
| 354 | 390 |
| 355 // Tests that VideoCaptureOracle can auto-throttle by stepping the capture size | 391 // Tests that VideoCaptureOracle can auto-throttle by stepping the capture size |
| 356 // up or down. When |is_content_animating| is false, there is more | 392 // up or down. When |is_content_animating| is false, there is more |
| 357 // aggressiveness expected in the timing of stepping upwards. If | 393 // aggressiveness expected in the timing of stepping upwards. If |
| 358 // |with_consumer_feedback| is false, only buffer pool utilization varies and no | 394 // |with_consumer_feedback| is false, only buffer pool utilization varies and no |
| 359 // consumer feedback is provided. If |with_consumer_feedback| is true, the | 395 // consumer feedback is provided. If |with_consumer_feedback| is true, the |
| 360 // buffer pool utilization is held constant at 25%, and the consumer utilization | 396 // buffer pool utilization is held constant at 25%, and the consumer utilization |
| 361 // feedback varies. | 397 // feedback varies. |
| 362 void RunAutoThrottleTest(bool is_content_animating, | 398 void RunAutoThrottleTest(bool is_content_animating, |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 VideoCaptureOracle::kCompositorUpdate, gfx::Rect(), t)); | 663 VideoCaptureOracle::kCompositorUpdate, gfx::Rect(), t)); |
| 628 ASSERT_EQ(Get720pSize(), oracle.capture_size()); | 664 ASSERT_EQ(Get720pSize(), oracle.capture_size()); |
| 629 base::TimeTicks ignored; | 665 base::TimeTicks ignored; |
| 630 const int frame_number = oracle.next_frame_number(); | 666 const int frame_number = oracle.next_frame_number(); |
| 631 oracle.RecordCapture(2.0); | 667 oracle.RecordCapture(2.0); |
| 632 ASSERT_TRUE(oracle.CompleteCapture(frame_number, true, &ignored)); | 668 ASSERT_TRUE(oracle.CompleteCapture(frame_number, true, &ignored)); |
| 633 } | 669 } |
| 634 } | 670 } |
| 635 | 671 |
| 636 } // namespace media | 672 } // namespace media |
| OLD | NEW |