OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 <deque> | 5 #include <deque> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 class BackToBackBeginFrameSourceTest : public ::testing::Test { | 305 class BackToBackBeginFrameSourceTest : public ::testing::Test { |
306 public: | 306 public: |
307 static const int64_t kDeadline; | 307 static const int64_t kDeadline; |
308 static const int64_t kInterval; | 308 static const int64_t kInterval; |
309 | 309 |
310 scoped_refptr<TestNowSource> now_src_; | 310 scoped_refptr<TestNowSource> now_src_; |
311 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 311 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
312 scoped_ptr<TestBackToBackBeginFrameSource> source_; | 312 scoped_ptr<TestBackToBackBeginFrameSource> source_; |
313 scoped_ptr<MockBeginFrameObserver> obs_; | 313 scoped_ptr<MockBeginFrameObserver> obs_; |
314 | 314 |
315 virtual void SetUp() override { | 315 void SetUp() override { |
316 now_src_ = TestNowSource::Create(1000); | 316 now_src_ = TestNowSource::Create(1000); |
317 task_runner_ = | 317 task_runner_ = |
318 make_scoped_refptr(new OrderedSimpleTaskRunner(now_src_, false)); | 318 make_scoped_refptr(new OrderedSimpleTaskRunner(now_src_, false)); |
319 task_runner_->SetRunTaskLimit(1); | 319 task_runner_->SetRunTaskLimit(1); |
320 source_ = | 320 source_ = |
321 TestBackToBackBeginFrameSource::Create(now_src_, task_runner_.get()); | 321 TestBackToBackBeginFrameSource::Create(now_src_, task_runner_.get()); |
322 obs_ = make_scoped_ptr(new ::testing::StrictMock<MockBeginFrameObserver>()); | 322 obs_ = make_scoped_ptr(new ::testing::StrictMock<MockBeginFrameObserver>()); |
323 source_->AddObserver(obs_.get()); | 323 source_->AddObserver(obs_.get()); |
324 } | 324 } |
325 | 325 |
326 virtual void TearDown() override { obs_.reset(); } | 326 void TearDown() override { obs_.reset(); } |
327 }; | 327 }; |
328 | 328 |
329 const int64_t BackToBackBeginFrameSourceTest::kDeadline = | 329 const int64_t BackToBackBeginFrameSourceTest::kDeadline = |
330 BeginFrameArgs::DefaultInterval().ToInternalValue(); | 330 BeginFrameArgs::DefaultInterval().ToInternalValue(); |
331 | 331 |
332 const int64_t BackToBackBeginFrameSourceTest::kInterval = | 332 const int64_t BackToBackBeginFrameSourceTest::kInterval = |
333 BeginFrameArgs::DefaultInterval().ToInternalValue(); | 333 BeginFrameArgs::DefaultInterval().ToInternalValue(); |
334 | 334 |
335 TEST_F(BackToBackBeginFrameSourceTest, SetNeedsBeginFramesSendsBeginFrame) { | 335 TEST_F(BackToBackBeginFrameSourceTest, SetNeedsBeginFramesSendsBeginFrame) { |
336 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); | 336 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 } | 471 } |
472 | 472 |
473 // SyntheticBeginFrameSource testing ------------------------------------------ | 473 // SyntheticBeginFrameSource testing ------------------------------------------ |
474 class SyntheticBeginFrameSourceTest : public ::testing::Test { | 474 class SyntheticBeginFrameSourceTest : public ::testing::Test { |
475 public: | 475 public: |
476 scoped_refptr<TestNowSource> now_src_; | 476 scoped_refptr<TestNowSource> now_src_; |
477 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 477 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
478 scoped_ptr<TestSyntheticBeginFrameSource> source_; | 478 scoped_ptr<TestSyntheticBeginFrameSource> source_; |
479 scoped_ptr<MockBeginFrameObserver> obs_; | 479 scoped_ptr<MockBeginFrameObserver> obs_; |
480 | 480 |
481 virtual void SetUp() override { | 481 void SetUp() override { |
482 now_src_ = TestNowSource::Create(1000); | 482 now_src_ = TestNowSource::Create(1000); |
483 task_runner_ = | 483 task_runner_ = |
484 make_scoped_refptr(new OrderedSimpleTaskRunner(now_src_, false)); | 484 make_scoped_refptr(new OrderedSimpleTaskRunner(now_src_, false)); |
485 source_ = TestSyntheticBeginFrameSource::Create( | 485 source_ = TestSyntheticBeginFrameSource::Create( |
486 now_src_, task_runner_.get(), base::TimeDelta::FromMicroseconds(10000)); | 486 now_src_, task_runner_.get(), base::TimeDelta::FromMicroseconds(10000)); |
487 obs_ = make_scoped_ptr(new MockBeginFrameObserver()); | 487 obs_ = make_scoped_ptr(new MockBeginFrameObserver()); |
488 source_->AddObserver(obs_.get()); | 488 source_->AddObserver(obs_.get()); |
489 } | 489 } |
490 | 490 |
491 virtual void TearDown() override { obs_.reset(); } | 491 void TearDown() override { obs_.reset(); } |
492 }; | 492 }; |
493 | 493 |
494 TEST_F(SyntheticBeginFrameSourceTest, | 494 TEST_F(SyntheticBeginFrameSourceTest, |
495 SetNeedsBeginFramesCallsOnBeginFrameWithMissedTick) { | 495 SetNeedsBeginFramesCallsOnBeginFrameWithMissedTick) { |
496 now_src_->SetNowMicroseconds(10010); | 496 now_src_->SetNowMicroseconds(10010); |
497 EXPECT_CALL((*obs_), | 497 EXPECT_CALL((*obs_), |
498 OnBeginFrame(CreateTypedBeginFrameArgsForTesting( | 498 OnBeginFrame(CreateTypedBeginFrameArgsForTesting( |
499 10000, 20000, 10000, BeginFrameArgs::MISSED))); | 499 10000, 20000, 10000, BeginFrameArgs::MISSED))); |
500 source_->SetNeedsBeginFrames(true); // Should cause the last tick to be sent | 500 source_->SetNeedsBeginFrames(true); // Should cause the last tick to be sent |
501 // No tasks should need to be run for this to occur. | 501 // No tasks should need to be run for this to occur. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 540 |
541 EXPECT_BEGIN_FRAME_USED(*obs_, 40000, 47502, 10001); | 541 EXPECT_BEGIN_FRAME_USED(*obs_, 40000, 47502, 10001); |
542 EXPECT_BEGIN_FRAME_USED(*obs_, 47502, 57503, 10001); | 542 EXPECT_BEGIN_FRAME_USED(*obs_, 47502, 57503, 10001); |
543 EXPECT_BEGIN_FRAME_USED(*obs_, 57503, 67504, 10001); | 543 EXPECT_BEGIN_FRAME_USED(*obs_, 57503, 67504, 10001); |
544 task_runner_->RunUntilTime(base::TimeTicks::FromInternalValue(60000)); | 544 task_runner_->RunUntilTime(base::TimeTicks::FromInternalValue(60000)); |
545 } | 545 } |
546 | 546 |
547 // BeginFrameSourceMultiplexer testing ----------------------------------- | 547 // BeginFrameSourceMultiplexer testing ----------------------------------- |
548 class BeginFrameSourceMultiplexerTest : public ::testing::Test { | 548 class BeginFrameSourceMultiplexerTest : public ::testing::Test { |
549 protected: | 549 protected: |
550 virtual void SetUp() override { | 550 void SetUp() override { |
551 mux_ = BeginFrameSourceMultiplexer::Create(); | 551 mux_ = BeginFrameSourceMultiplexer::Create(); |
552 | 552 |
553 source1_store_ = make_scoped_ptr(new FakeBeginFrameSource()); | 553 source1_store_ = make_scoped_ptr(new FakeBeginFrameSource()); |
554 source2_store_ = make_scoped_ptr(new FakeBeginFrameSource()); | 554 source2_store_ = make_scoped_ptr(new FakeBeginFrameSource()); |
555 source3_store_ = make_scoped_ptr(new FakeBeginFrameSource()); | 555 source3_store_ = make_scoped_ptr(new FakeBeginFrameSource()); |
556 | 556 |
557 source1_ = source1_store_.get(); | 557 source1_ = source1_store_.get(); |
558 source2_ = source2_store_.get(); | 558 source2_ = source2_store_.get(); |
559 source3_ = source3_store_.get(); | 559 source3_ = source3_store_.get(); |
560 } | 560 } |
561 | 561 |
562 virtual void TearDown() override { | 562 void TearDown() override { |
563 // Make sure the mux is torn down before the sources. | 563 // Make sure the mux is torn down before the sources. |
564 mux_.reset(); | 564 mux_.reset(); |
565 } | 565 } |
566 | 566 |
567 scoped_ptr<BeginFrameSourceMultiplexer> mux_; | 567 scoped_ptr<BeginFrameSourceMultiplexer> mux_; |
568 FakeBeginFrameSource* source1_; | 568 FakeBeginFrameSource* source1_; |
569 FakeBeginFrameSource* source2_; | 569 FakeBeginFrameSource* source2_; |
570 FakeBeginFrameSource* source3_; | 570 FakeBeginFrameSource* source3_; |
571 | 571 |
572 private: | 572 private: |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 mux_->SetActiveSource(source2_); | 738 mux_->SetActiveSource(source2_); |
739 SEND_BEGIN_FRAME_DROP(*source2_, 750, 1050, 300); | 739 SEND_BEGIN_FRAME_DROP(*source2_, 750, 1050, 300); |
740 SEND_BEGIN_FRAME_USED(*source2_, 1050, 1250, 300); | 740 SEND_BEGIN_FRAME_USED(*source2_, 1050, 1250, 300); |
741 | 741 |
742 mux_->SetActiveSource(source1_); | 742 mux_->SetActiveSource(source1_); |
743 SEND_BEGIN_FRAME_DROP(*source2_, 1100, 1400, 300); | 743 SEND_BEGIN_FRAME_DROP(*source2_, 1100, 1400, 300); |
744 } | 744 } |
745 | 745 |
746 } // namespace | 746 } // namespace |
747 } // namespace cc | 747 } // namespace cc |
OLD | NEW |