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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 source.SetNeedsBeginFrames(true); | 249 source.SetNeedsBeginFrames(true); |
250 EXPECT_TRUE(source.NeedsBeginFrames()); | 250 EXPECT_TRUE(source.NeedsBeginFrames()); |
251 source.SetNeedsBeginFrames(false); | 251 source.SetNeedsBeginFrames(false); |
252 EXPECT_FALSE(source.NeedsBeginFrames()); | 252 EXPECT_FALSE(source.NeedsBeginFrames()); |
253 } | 253 } |
254 | 254 |
255 class LoopingBeginFrameObserver : public BeginFrameObserverMixIn { | 255 class LoopingBeginFrameObserver : public BeginFrameObserverMixIn { |
256 public: | 256 public: |
257 BeginFrameSource* source_; | 257 BeginFrameSource* source_; |
258 | 258 |
259 virtual void AsValueInto(base::debug::TracedValue* dict) const override { | 259 void AsValueInto(base::debug::TracedValue* dict) const override { |
260 dict->SetString("type", "LoopingBeginFrameObserver"); | 260 dict->SetString("type", "LoopingBeginFrameObserver"); |
261 dict->BeginDictionary("source"); | 261 dict->BeginDictionary("source"); |
262 source_->AsValueInto(dict); | 262 source_->AsValueInto(dict); |
263 dict->EndDictionary(); | 263 dict->EndDictionary(); |
264 } | 264 } |
265 | 265 |
266 protected: | 266 protected: |
267 // BeginFrameObserverMixIn | 267 // BeginFrameObserverMixIn |
268 virtual bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override { | 268 bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override { |
269 return true; | 269 return true; |
270 } | 270 } |
271 }; | 271 }; |
272 | 272 |
273 TEST(BeginFrameSourceMixInTest, DetectAsValueIntoLoop) { | 273 TEST(BeginFrameSourceMixInTest, DetectAsValueIntoLoop) { |
274 LoopingBeginFrameObserver obs; | 274 LoopingBeginFrameObserver obs; |
275 FakeBeginFrameSource source; | 275 FakeBeginFrameSource source; |
276 | 276 |
277 obs.source_ = &source; | 277 obs.source_ = &source; |
278 source.AddObserver(&obs); | 278 source.AddObserver(&obs); |
(...skipping 11 matching lines...) Expand all Loading... |
290 base::SingleThreadTaskRunner* task_runner) { | 290 base::SingleThreadTaskRunner* task_runner) { |
291 return make_scoped_ptr( | 291 return make_scoped_ptr( |
292 new TestBackToBackBeginFrameSource(now_src, task_runner)); | 292 new TestBackToBackBeginFrameSource(now_src, task_runner)); |
293 } | 293 } |
294 | 294 |
295 protected: | 295 protected: |
296 TestBackToBackBeginFrameSource(scoped_refptr<TestNowSource> now_src, | 296 TestBackToBackBeginFrameSource(scoped_refptr<TestNowSource> now_src, |
297 base::SingleThreadTaskRunner* task_runner) | 297 base::SingleThreadTaskRunner* task_runner) |
298 : BackToBackBeginFrameSource(task_runner), now_src_(now_src) {} | 298 : BackToBackBeginFrameSource(task_runner), now_src_(now_src) {} |
299 | 299 |
300 virtual base::TimeTicks Now() override { return now_src_->Now(); } | 300 base::TimeTicks Now() override { return now_src_->Now(); } |
301 | 301 |
302 scoped_refptr<TestNowSource> now_src_; | 302 scoped_refptr<TestNowSource> now_src_; |
303 }; | 303 }; |
304 | 304 |
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_; |
(...skipping 427 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 |