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

Side by Side Diff: cc/scheduler/begin_frame_source_unittest.cc

Issue 2767933002: [cc] Don't send missed BeginFrames with past deadline.
Patch Set: add ExternalBFS tests, don't check in DelayBasedBFS. 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 unified diff | Download patch
« no previous file with comments | « cc/scheduler/begin_frame_source.cc ('k') | cc/scheduler/delay_based_time_source.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 } 795 }
796 796
797 // ExternalBeginFrameSource testing -------------------------------------------- 797 // ExternalBeginFrameSource testing --------------------------------------------
798 class MockExternalBeginFrameSourceClient 798 class MockExternalBeginFrameSourceClient
799 : public ExternalBeginFrameSourceClient { 799 : public ExternalBeginFrameSourceClient {
800 public: 800 public:
801 MOCK_METHOD1(OnNeedsBeginFrames, void(bool)); 801 MOCK_METHOD1(OnNeedsBeginFrames, void(bool));
802 MOCK_METHOD1(OnDidFinishFrame, void(const BeginFrameAck&)); 802 MOCK_METHOD1(OnDidFinishFrame, void(const BeginFrameAck&));
803 }; 803 };
804 804
805 class ExternalBeginFrameSourceForTest : public ExternalBeginFrameSource {
806 public:
807 using ExternalBeginFrameSource::ExternalBeginFrameSource;
808 base::TimeTicks Now() const override { return now_; }
809
810 base::TimeTicks now_;
811 };
812
805 class ExternalBeginFrameSourceTest : public ::testing::Test { 813 class ExternalBeginFrameSourceTest : public ::testing::Test {
806 public: 814 public:
807 std::unique_ptr<MockExternalBeginFrameSourceClient> client_; 815 std::unique_ptr<MockExternalBeginFrameSourceClient> client_;
808 std::unique_ptr<ExternalBeginFrameSource> source_; 816 std::unique_ptr<ExternalBeginFrameSourceForTest> source_;
809 std::unique_ptr<MockBeginFrameObserver> obs_; 817 std::unique_ptr<MockBeginFrameObserver> obs_;
810 818
811 void SetUp() override { 819 void SetUp() override {
812 client_.reset(new MockExternalBeginFrameSourceClient); 820 client_.reset(new MockExternalBeginFrameSourceClient);
813 source_.reset(new ExternalBeginFrameSource(client_.get())); 821 source_.reset(new ExternalBeginFrameSourceForTest(client_.get()));
814 obs_.reset(new MockBeginFrameObserver); 822 obs_.reset(new MockBeginFrameObserver);
815 } 823 }
816 824
817 void TearDown() override { 825 void TearDown() override {
818 client_.reset(); 826 client_.reset();
819 obs_.reset(); 827 obs_.reset();
820 } 828 }
821 }; 829 };
822 830
823 TEST_F(ExternalBeginFrameSourceTest, CallsOnDidFinishFrameWithoutObservers) { 831 TEST_F(ExternalBeginFrameSourceTest, CallsOnDidFinishFrameWithoutObservers) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 909
902 // Providing same args through a different ExternalBeginFrameSource also does 910 // Providing same args through a different ExternalBeginFrameSource also does
903 // not notify observer. 911 // not notify observer.
904 EXPECT_BEGIN_FRAME_SOURCE_PAUSED(*obs_, false); 912 EXPECT_BEGIN_FRAME_SOURCE_PAUSED(*obs_, false);
905 EXPECT_CALL((*client_), OnNeedsBeginFrames(true)).Times(1); 913 EXPECT_CALL((*client_), OnNeedsBeginFrames(true)).Times(1);
906 ExternalBeginFrameSource source2(client_.get()); 914 ExternalBeginFrameSource source2(client_.get());
907 source2.AddObserver(obs_.get()); 915 source2.AddObserver(obs_.get());
908 source2.OnBeginFrame(args); 916 source2.OnBeginFrame(args);
909 } 917 }
910 918
919 TEST_F(ExternalBeginFrameSourceTest, AddObserverSendsMissedBeginFrame) {
920 BeginFrameArgs args = CreateBeginFrameArgsForTesting(
921 BEGINFRAME_FROM_HERE, 0, 2, base::TimeTicks::FromInternalValue(10000));
922 EXPECT_CALL((*client_), OnDidFinishFrame(BeginFrameAck(0, 2, 2, 0, false)))
923 .Times(1);
924 source_->OnBeginFrame(args);
925
926 args.type = BeginFrameArgs::MISSED;
927 EXPECT_CALL((*client_), OnNeedsBeginFrames(true)).Times(1);
928 EXPECT_BEGIN_FRAME_SOURCE_PAUSED(*obs_, false);
929 EXPECT_BEGIN_FRAME_ARGS_USED(*obs_, args);
930 source_->AddObserver(obs_.get());
931 }
932
933 TEST_F(ExternalBeginFrameSourceTest,
934 AddObserverDoesNotSendMissedBeginFrameAfterDeadline) {
935 BeginFrameArgs args = CreateBeginFrameArgsForTesting(
936 BEGINFRAME_FROM_HERE, 0, 2, base::TimeTicks::FromInternalValue(10000));
937 EXPECT_CALL((*client_), OnDidFinishFrame(BeginFrameAck(0, 2, 2, 0, false)))
938 .Times(1);
939 source_->OnBeginFrame(args);
940
941 source_->now_ = args.deadline;
942 args.type = BeginFrameArgs::MISSED;
943 EXPECT_CALL((*client_), OnNeedsBeginFrames(true)).Times(1);
944 EXPECT_BEGIN_FRAME_SOURCE_PAUSED(*obs_, false);
945 // Should not call OnBeginFrame for missed BeginFrame with past deadline.
946 EXPECT_CALL((*obs_), OnBeginFrame(::testing::_)).Times(0);
947 source_->AddObserver(obs_.get());
948 }
949
911 } // namespace 950 } // namespace
912 } // namespace cc 951 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/begin_frame_source.cc ('k') | cc/scheduler/delay_based_time_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698