| 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 "cc/scheduler/begin_frame_source.h" | 5 #include "cc/scheduler/begin_frame_source.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
| 11 #include "cc/test/begin_frame_args_test.h" | 11 #include "cc/test/begin_frame_args_test.h" |
| 12 #include "cc/test/begin_frame_source_test.h" | 12 #include "cc/test/begin_frame_source_test.h" |
| 13 #include "cc/test/scheduler_test_common.h" | 13 #include "cc/test/scheduler_test_common.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 using testing::NiceMock; | 17 using testing::NiceMock; |
| 18 using testing::_; | |
| 19 | 18 |
| 20 namespace cc { | 19 namespace cc { |
| 21 namespace { | 20 namespace { |
| 22 | 21 |
| 23 // BeginFrameSource testing ---------------------------------------------------- | 22 // BeginFrameSource testing ---------------------------------------------------- |
| 24 TEST(BeginFrameSourceTest, SourceIdsAreUnique) { | 23 TEST(BeginFrameSourceTest, SourceIdsAreUnique) { |
| 25 StubBeginFrameSource source1; | 24 StubBeginFrameSource source1; |
| 26 StubBeginFrameSource source2; | 25 StubBeginFrameSource source2; |
| 27 StubBeginFrameSource source3; | 26 StubBeginFrameSource source3; |
| 28 EXPECT_NE(source1.source_id(), source2.source_id()); | 27 EXPECT_NE(source1.source_id(), source2.source_id()); |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 | 566 |
| 568 // Providing same args through a different ExternalBeginFrameSource also does | 567 // Providing same args through a different ExternalBeginFrameSource also does |
| 569 // not notify observer. | 568 // not notify observer. |
| 570 EXPECT_BEGIN_FRAME_SOURCE_PAUSED(*obs_, false); | 569 EXPECT_BEGIN_FRAME_SOURCE_PAUSED(*obs_, false); |
| 571 EXPECT_CALL((*client_), OnNeedsBeginFrames(true)).Times(1); | 570 EXPECT_CALL((*client_), OnNeedsBeginFrames(true)).Times(1); |
| 572 ExternalBeginFrameSource source2(client_.get()); | 571 ExternalBeginFrameSource source2(client_.get()); |
| 573 source2.AddObserver(obs_.get()); | 572 source2.AddObserver(obs_.get()); |
| 574 source2.OnBeginFrame(args); | 573 source2.OnBeginFrame(args); |
| 575 } | 574 } |
| 576 | 575 |
| 577 // https://crbug.com/730218: Avoid DCHECK crash in | |
| 578 // ExternalBeginFrameSource::GetMissedBeginFrameArgs. | |
| 579 TEST_F(ExternalBeginFrameSourceTest, GetMissedBeginFrameArgs) { | |
| 580 BeginFrameArgs args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, | |
| 581 2, 10000, 10100, 100); | |
| 582 source_->OnBeginFrame(args); | |
| 583 | |
| 584 EXPECT_BEGIN_FRAME_SOURCE_PAUSED(*obs_, false); | |
| 585 EXPECT_BEGIN_FRAME_USED_MISSED(*obs_, 0, 2, 10000, 10100, 100); | |
| 586 source_->AddObserver(obs_.get()); | |
| 587 source_->RemoveObserver(obs_.get()); | |
| 588 | |
| 589 // Out of order frame_time. This might not be valid but still shouldn't | |
| 590 // cause a DCHECK in ExternalBeginFrameSource code. | |
| 591 args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, 9999, 10100, | |
| 592 101); | |
| 593 source_->OnBeginFrame(args); | |
| 594 | |
| 595 EXPECT_CALL((*client_), OnNeedsBeginFrames(true)).Times(1); | |
| 596 EXPECT_BEGIN_FRAME_SOURCE_PAUSED(*obs_, false); | |
| 597 EXPECT_CALL(*obs_, OnBeginFrame(_)).Times(0); | |
| 598 source_->AddObserver(obs_.get()); | |
| 599 } | |
| 600 | |
| 601 } // namespace | 576 } // namespace |
| 602 } // namespace cc | 577 } // namespace cc |
| OLD | NEW |