| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 SEND_BEGIN_FRAME(new_args, source, frame_time, deadline, interval); | 57 SEND_BEGIN_FRAME(new_args, source, frame_time, deadline, interval); |
| 58 | 58 |
| 59 namespace cc { | 59 namespace cc { |
| 60 namespace { | 60 namespace { |
| 61 | 61 |
| 62 class MockBeginFrameObserver : public BeginFrameObserver { | 62 class MockBeginFrameObserver : public BeginFrameObserver { |
| 63 public: | 63 public: |
| 64 MOCK_METHOD1(OnBeginFrame, void(const BeginFrameArgs&)); | 64 MOCK_METHOD1(OnBeginFrame, void(const BeginFrameArgs&)); |
| 65 MOCK_CONST_METHOD0(LastUsedBeginFrameArgs, const BeginFrameArgs()); | 65 MOCK_CONST_METHOD0(LastUsedBeginFrameArgs, const BeginFrameArgs()); |
| 66 | 66 |
| 67 virtual void AsValueInto(base::debug::TracedValue* dict) const { | 67 virtual void AsValueInto(base::trace_event::TracedValue* dict) const { |
| 68 dict->SetString("type", "MockBeginFrameObserver"); | 68 dict->SetString("type", "MockBeginFrameObserver"); |
| 69 dict->BeginDictionary("last_begin_frame_args"); | 69 dict->BeginDictionary("last_begin_frame_args"); |
| 70 LastUsedBeginFrameArgs().AsValueInto(dict); | 70 LastUsedBeginFrameArgs().AsValueInto(dict); |
| 71 dict->EndDictionary(); | 71 dict->EndDictionary(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 // A value different from the normal default returned by a BeginFrameObserver | 74 // A value different from the normal default returned by a BeginFrameObserver |
| 75 // so it is easiable traced back here. | 75 // so it is easiable traced back here. |
| 76 static const BeginFrameArgs kDefaultBeginFrameArgs; | 76 static const BeginFrameArgs kDefaultBeginFrameArgs; |
| 77 | 77 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 source.SetNeedsBeginFrames(true); | 277 source.SetNeedsBeginFrames(true); |
| 278 EXPECT_TRUE(source.NeedsBeginFrames()); | 278 EXPECT_TRUE(source.NeedsBeginFrames()); |
| 279 source.SetNeedsBeginFrames(false); | 279 source.SetNeedsBeginFrames(false); |
| 280 EXPECT_FALSE(source.NeedsBeginFrames()); | 280 EXPECT_FALSE(source.NeedsBeginFrames()); |
| 281 } | 281 } |
| 282 | 282 |
| 283 class LoopingBeginFrameObserver : public BeginFrameObserverMixIn { | 283 class LoopingBeginFrameObserver : public BeginFrameObserverMixIn { |
| 284 public: | 284 public: |
| 285 BeginFrameSource* source_; | 285 BeginFrameSource* source_; |
| 286 | 286 |
| 287 void AsValueInto(base::debug::TracedValue* dict) const override { | 287 void AsValueInto(base::trace_event::TracedValue* dict) const override { |
| 288 dict->SetString("type", "LoopingBeginFrameObserver"); | 288 dict->SetString("type", "LoopingBeginFrameObserver"); |
| 289 dict->BeginDictionary("source"); | 289 dict->BeginDictionary("source"); |
| 290 source_->AsValueInto(dict); | 290 source_->AsValueInto(dict); |
| 291 dict->EndDictionary(); | 291 dict->EndDictionary(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 protected: | 294 protected: |
| 295 // BeginFrameObserverMixIn | 295 // BeginFrameObserverMixIn |
| 296 bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override { | 296 bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override { |
| 297 return true; | 297 return true; |
| 298 } | 298 } |
| 299 }; | 299 }; |
| 300 | 300 |
| 301 TEST(BeginFrameSourceMixInTest, DetectAsValueIntoLoop) { | 301 TEST(BeginFrameSourceMixInTest, DetectAsValueIntoLoop) { |
| 302 LoopingBeginFrameObserver obs; | 302 LoopingBeginFrameObserver obs; |
| 303 FakeBeginFrameSource source; | 303 FakeBeginFrameSource source; |
| 304 | 304 |
| 305 obs.source_ = &source; | 305 obs.source_ = &source; |
| 306 source.AddObserver(&obs); | 306 source.AddObserver(&obs); |
| 307 | 307 |
| 308 scoped_refptr<base::debug::TracedValue> state = | 308 scoped_refptr<base::trace_event::TracedValue> state = |
| 309 new base::debug::TracedValue(); | 309 new base::trace_event::TracedValue(); |
| 310 source.AsValueInto(state.get()); | 310 source.AsValueInto(state.get()); |
| 311 } | 311 } |
| 312 | 312 |
| 313 // BackToBackBeginFrameSource testing ----------------------------------------- | 313 // BackToBackBeginFrameSource testing ----------------------------------------- |
| 314 class TestBackToBackBeginFrameSource : public BackToBackBeginFrameSource { | 314 class TestBackToBackBeginFrameSource : public BackToBackBeginFrameSource { |
| 315 public: | 315 public: |
| 316 static scoped_ptr<TestBackToBackBeginFrameSource> Create( | 316 static scoped_ptr<TestBackToBackBeginFrameSource> Create( |
| 317 scoped_refptr<TestNowSource> now_src, | 317 scoped_refptr<TestNowSource> now_src, |
| 318 base::SingleThreadTaskRunner* task_runner) { | 318 base::SingleThreadTaskRunner* task_runner) { |
| 319 return make_scoped_ptr( | 319 return make_scoped_ptr( |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 mux_->SetActiveSource(source2_); | 766 mux_->SetActiveSource(source2_); |
| 767 SEND_BEGIN_FRAME_DROP(*source2_, 750, 1050, 300); | 767 SEND_BEGIN_FRAME_DROP(*source2_, 750, 1050, 300); |
| 768 SEND_BEGIN_FRAME_USED(*source2_, 1050, 1250, 300); | 768 SEND_BEGIN_FRAME_USED(*source2_, 1050, 1250, 300); |
| 769 | 769 |
| 770 mux_->SetActiveSource(source1_); | 770 mux_->SetActiveSource(source1_); |
| 771 SEND_BEGIN_FRAME_DROP(*source2_, 1100, 1400, 300); | 771 SEND_BEGIN_FRAME_DROP(*source2_, 1100, 1400, 300); |
| 772 } | 772 } |
| 773 | 773 |
| 774 } // namespace | 774 } // namespace |
| 775 } // namespace cc | 775 } // namespace cc |
| OLD | NEW |