Index: cc/scheduler/begin_frame_source_unittest.cc |
diff --git a/cc/scheduler/begin_frame_source_unittest.cc b/cc/scheduler/begin_frame_source_unittest.cc |
index 1f85622878e91680efd7f5ea56402c3653d81ada..2401d51d110966ba3bbb90e4983d6483dbf9f774 100644 |
--- a/cc/scheduler/begin_frame_source_unittest.cc |
+++ b/cc/scheduler/begin_frame_source_unittest.cc |
@@ -231,9 +231,6 @@ TEST(BeginFrameSourceBaseTest, ObserverManipulation) { |
EXPECT_EQ(&obs, source.GetObserver()); |
#ifndef NDEBUG |
- // Adding an observer when an observer already exists should DCHECK fail. |
- EXPECT_DEATH({ source.AddObserver(&otherObs); }, ""); |
- |
// Removing wrong observer should DCHECK fail. |
EXPECT_DEATH({ source.RemoveObserver(&otherObs); }, ""); |
@@ -271,6 +268,92 @@ TEST(BeginFrameSourceBaseTest, NoObserver) { |
SEND_BEGIN_FRAME_DROP(source, 100, 200, 300); |
} |
+TEST(BeginFrameSourceBaseTest, ObserverMulti) { |
brianderson
2015/09/12 00:23:50
Looks like the same test as ObserverMultiSimple?
|
+ MockBeginFrameObserver obs; |
+ MockBeginFrameObserver otherObs; |
+ FakeBeginFrameSource source; |
+ |
+ EXPECT_BEGIN_FRAME_USED(obs, 100, 200, 300); |
+ EXPECT_BEGIN_FRAME_USED(obs, 400, 600, 300); |
+ EXPECT_BEGIN_FRAME_USED(obs, 450, 650, 300); |
+ EXPECT_BEGIN_FRAME_USED(obs, 700, 900, 300); |
+ |
+ EXPECT_BEGIN_FRAME_USED(otherObs, 400, 600, 300); |
+ EXPECT_BEGIN_FRAME_USED(otherObs, 450, 650, 300); |
+ |
+ source.AddObserver(&obs); |
+ SEND_BEGIN_FRAME_USED(source, 100, 200, 300); |
+ source.AddObserver(&otherObs); |
+ SEND_BEGIN_FRAME_USED(source, 400, 600, 300); |
+ SEND_BEGIN_FRAME_USED(source, 450, 650, 300); |
+ source.RemoveObserver(&otherObs); |
+ SEND_BEGIN_FRAME_USED(source, 700, 900, 300); |
+} |
+ |
+TEST(BeginFrameSourceBaseTest, ObserverMultiSimple) { |
+ MockBeginFrameObserver obs; |
+ MockBeginFrameObserver otherObs; |
+ FakeBeginFrameSource source; |
+ |
+ EXPECT_BEGIN_FRAME_USED(obs, 100, 200, 300); |
+ EXPECT_BEGIN_FRAME_USED(obs, 400, 600, 300); |
+ EXPECT_BEGIN_FRAME_USED(obs, 450, 650, 300); |
+ EXPECT_BEGIN_FRAME_USED(obs, 700, 900, 300); |
+ |
+ EXPECT_BEGIN_FRAME_USED(otherObs, 400, 600, 300); |
+ EXPECT_BEGIN_FRAME_USED(otherObs, 450, 650, 300); |
+ |
+ source.AddObserver(&obs); |
+ SEND_BEGIN_FRAME_USED(source, 100, 200, 300); |
+ source.AddObserver(&otherObs); |
+ SEND_BEGIN_FRAME_USED(source, 400, 600, 300); |
+ SEND_BEGIN_FRAME_USED(source, 450, 650, 300); |
+ source.RemoveObserver(&otherObs); |
+ SEND_BEGIN_FRAME_USED(source, 700, 900, 300); |
+ |
+ scoped_refptr<base::trace_event::TracedValue> state1 = |
+ new base::trace_event::TracedValue(); |
+ source.AsValueInto(state1.get()); |
+ |
+ source.AddObserver(&otherObs); |
+ scoped_refptr<base::trace_event::TracedValue> state2 = |
+ new base::trace_event::TracedValue(); |
+ source.AsValueInto(state2.get()); |
+} |
+ |
+class RemovingBeginFrameObserver : public BeginFrameObserverBase { |
+ public: |
+ explicit RemovingBeginFrameObserver(BeginFrameSource* bfs) : source_(bfs) {} |
+ |
+ protected: |
+ // BeginFrameObserverBase |
+ bool OnBeginFrameDerivedImpl(const BeginFrameArgs& args) override { |
+ source_->RemoveObserver(this); |
+ return true; |
+ } |
+ |
+ BeginFrameSource* source_; |
+}; |
+ |
+TEST(BeginFrameSourceBaseTest, ObserverMultiRemoveOnBeginFrame) { |
brianderson
2015/09/12 00:23:50
If you are going to add a WillLoseBeginFrameSource
|
+ MockBeginFrameObserver obs; |
+ FakeBeginFrameSource source; |
+ RemovingBeginFrameObserver otherObs(&source); |
+ |
+ EXPECT_BEGIN_FRAME_USED(obs, 100, 200, 300); |
+ EXPECT_BEGIN_FRAME_USED(obs, 400, 600, 300); |
+ EXPECT_BEGIN_FRAME_USED(obs, 700, 900, 300); |
+ |
+ source.AddObserver(&obs); |
+ SEND_BEGIN_FRAME_USED(source, 100, 200, 300); |
+ source.AddObserver(&otherObs); |
+ SEND_BEGIN_FRAME_USED(source, 400, 600, 300); |
+ SEND_BEGIN_FRAME_USED(source, 700, 900, 300); |
+ EXPECT_EQ( |
+ otherObs.LastUsedBeginFrameArgs(), |
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 400, 600, 300)); |
+} |
+ |
TEST(BeginFrameSourceBaseTest, NeedsBeginFrames) { |
FakeBeginFrameSource source; |
EXPECT_FALSE(source.NeedsBeginFrames()); |