| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // BeginFrameSource testing ---------------------------------------------- | 224 // BeginFrameSource testing ---------------------------------------------- |
| 225 TEST(BeginFrameSourceBaseTest, ObserverManipulation) { | 225 TEST(BeginFrameSourceBaseTest, ObserverManipulation) { |
| 226 MockBeginFrameObserver obs; | 226 MockBeginFrameObserver obs; |
| 227 MockBeginFrameObserver otherObs; | 227 MockBeginFrameObserver otherObs; |
| 228 FakeBeginFrameSource source; | 228 FakeBeginFrameSource source; |
| 229 | 229 |
| 230 source.AddObserver(&obs); | 230 source.AddObserver(&obs); |
| 231 EXPECT_EQ(&obs, source.GetObserver()); | 231 EXPECT_EQ(&obs, source.GetObserver()); |
| 232 | 232 |
| 233 #ifndef NDEBUG | 233 #ifndef NDEBUG |
| 234 // Adding an observer when an observer already exists should DCHECK fail. | |
| 235 EXPECT_DEATH({ source.AddObserver(&otherObs); }, ""); | |
| 236 | |
| 237 // Removing wrong observer should DCHECK fail. | 234 // Removing wrong observer should DCHECK fail. |
| 238 EXPECT_DEATH({ source.RemoveObserver(&otherObs); }, ""); | 235 EXPECT_DEATH({ source.RemoveObserver(&otherObs); }, ""); |
| 239 | 236 |
| 240 // Removing an observer when there is no observer should DCHECK fail. | 237 // Removing an observer when there is no observer should DCHECK fail. |
| 241 EXPECT_DEATH({ | 238 EXPECT_DEATH({ |
| 242 source.RemoveObserver(&obs); | 239 source.RemoveObserver(&obs); |
| 243 source.RemoveObserver(&obs); | 240 source.RemoveObserver(&obs); |
| 244 }, | 241 }, |
| 245 ""); | 242 ""); |
| 246 #endif | 243 #endif |
| 247 source.RemoveObserver(&obs); | 244 source.RemoveObserver(&obs); |
| 248 | 245 |
| 249 source.AddObserver(&otherObs); | 246 source.AddObserver(&otherObs); |
| 250 EXPECT_EQ(&otherObs, source.GetObserver()); | 247 EXPECT_EQ(&otherObs, source.GetObserver()); |
| 251 source.RemoveObserver(&otherObs); | 248 source.RemoveObserver(&otherObs); |
| 249 |
| 250 // TODO(mithro): Add a test here for adding / removing multiple observers. |
| 251 |
| 252 } | 252 } |
| 253 | 253 |
| 254 TEST(BeginFrameSourceBaseTest, Observer) { | 254 TEST(BeginFrameSourceBaseTest, Observer) { |
| 255 FakeBeginFrameSource source; | 255 FakeBeginFrameSource source; |
| 256 MockBeginFrameObserver obs; | 256 MockBeginFrameObserver obs; |
| 257 source.AddObserver(&obs); | 257 source.AddObserver(&obs); |
| 258 EXPECT_BEGIN_FRAME_USED(obs, 100, 200, 300); | 258 EXPECT_BEGIN_FRAME_USED(obs, 100, 200, 300); |
| 259 EXPECT_BEGIN_FRAME_DROP(obs, 400, 600, 300); | 259 EXPECT_BEGIN_FRAME_DROP(obs, 400, 600, 300); |
| 260 EXPECT_BEGIN_FRAME_DROP(obs, 450, 650, 300); | 260 EXPECT_BEGIN_FRAME_DROP(obs, 450, 650, 300); |
| 261 EXPECT_BEGIN_FRAME_USED(obs, 700, 900, 300); | 261 EXPECT_BEGIN_FRAME_USED(obs, 700, 900, 300); |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 mux_->SetActiveSource(source2_); | 770 mux_->SetActiveSource(source2_); |
| 771 SEND_BEGIN_FRAME_DROP(*source2_, 750, 1050, 300); | 771 SEND_BEGIN_FRAME_DROP(*source2_, 750, 1050, 300); |
| 772 SEND_BEGIN_FRAME_USED(*source2_, 1050, 1250, 300); | 772 SEND_BEGIN_FRAME_USED(*source2_, 1050, 1250, 300); |
| 773 | 773 |
| 774 mux_->SetActiveSource(source1_); | 774 mux_->SetActiveSource(source1_); |
| 775 SEND_BEGIN_FRAME_DROP(*source2_, 1100, 1400, 300); | 775 SEND_BEGIN_FRAME_DROP(*source2_, 1100, 1400, 300); |
| 776 } | 776 } |
| 777 | 777 |
| 778 } // namespace | 778 } // namespace |
| 779 } // namespace cc | 779 } // namespace cc |
| OLD | NEW |