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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 #ifdef NDEBUG | 163 #ifdef NDEBUG |
164 nullptr, | 164 nullptr, |
165 #else | 165 #else |
166 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 166 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
167 "MockBeginFrameObserver::kDefaultBeginFrameArgs"), | 167 "MockBeginFrameObserver::kDefaultBeginFrameArgs"), |
168 #endif | 168 #endif |
169 -1, | 169 -1, |
170 -1, | 170 -1, |
171 -1); | 171 -1); |
172 | 172 |
173 // BeginFrameObserverMixIn testing --------------------------------------- | 173 // BeginFrameObserverBase testing --------------------------------------- |
174 class MockMinimalBeginFrameObserverMixIn : public BeginFrameObserverMixIn { | 174 class MockMinimalBeginFrameObserverBase : public BeginFrameObserverBase { |
175 public: | 175 public: |
176 MOCK_METHOD1(OnBeginFrameMixInDelegate, bool(const BeginFrameArgs&)); | 176 MOCK_METHOD1(OnBeginFrameMixInDelegate, bool(const BeginFrameArgs&)); |
177 int64_t dropped_begin_frame_args() const { return dropped_begin_frame_args_; } | 177 int64_t dropped_begin_frame_args() const { return dropped_begin_frame_args_; } |
178 }; | 178 }; |
179 | 179 |
180 TEST(BeginFrameObserverMixInTest, OnBeginFrameImplementation) { | 180 TEST(BeginFrameObserverBaseTest, OnBeginFrameImplementation) { |
181 using ::testing::Return; | 181 using ::testing::Return; |
182 MockMinimalBeginFrameObserverMixIn obs; | 182 MockMinimalBeginFrameObserverBase obs; |
183 ::testing::InSequence ordered; // These calls should be ordered | 183 ::testing::InSequence ordered; // These calls should be ordered |
184 | 184 |
185 // Initial conditions | 185 // Initial conditions |
186 EXPECT_EQ(BeginFrameArgs(), obs.LastUsedBeginFrameArgs()); | 186 EXPECT_EQ(BeginFrameArgs(), obs.LastUsedBeginFrameArgs()); |
187 EXPECT_EQ(0, obs.dropped_begin_frame_args()); | 187 EXPECT_EQ(0, obs.dropped_begin_frame_args()); |
188 | 188 |
189 #ifndef NDEBUG | 189 #ifndef NDEBUG |
190 EXPECT_DEATH({ obs.OnBeginFrame(BeginFrameArgs()); }, ""); | 190 EXPECT_DEATH({ obs.OnBeginFrame(BeginFrameArgs()); }, ""); |
191 #endif | 191 #endif |
192 | 192 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 | 273 |
274 TEST(BeginFrameSourceMixInTest, NeedsBeginFrames) { | 274 TEST(BeginFrameSourceMixInTest, NeedsBeginFrames) { |
275 FakeBeginFrameSource source; | 275 FakeBeginFrameSource source; |
276 EXPECT_FALSE(source.NeedsBeginFrames()); | 276 EXPECT_FALSE(source.NeedsBeginFrames()); |
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 BeginFrameObserverBase { |
284 public: | 284 public: |
285 BeginFrameSource* source_; | 285 BeginFrameSource* source_; |
286 | 286 |
287 void AsValueInto(base::trace_event::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 // BeginFrameObserverBase |
296 bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override { | 296 bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override { |
sunnyps
2015/05/26 21:45:44
Please rename OnBeginFrameMixInDelegate too. I wou
| |
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); |
(...skipping 459 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 |