Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/graphics/CompositorMutatorClient.h" | 5 #include "platform/graphics/CompositorMutatorClient.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "platform/graphics/CompositorMutation.h" | 8 #include "platform/graphics/CompositorMutation.h" |
| 9 #include "platform/graphics/CompositorMutationsTarget.h" | 9 #include "platform/graphics/CompositorMutationsTarget.h" |
| 10 #include "platform/graphics/CompositorMutator.h" | |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "wtf/OwnPtr.h" | 13 #include "wtf/OwnPtr.h" |
| 13 | 14 |
| 14 using ::testing::_; | 15 using ::testing::_; |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 20 class MockCompositorMutator : public GarbageCollected<MockCompositorMutator>, pu blic CompositorMutator { | |
|
jbroman
2016/05/04 22:11:06
super-nit: consider not using the term "Mock" when
flackr
2016/05/05 14:04:15
Done.
| |
| 21 USING_GARBAGE_COLLECTED_MIXIN(MockCompositorMutator); | |
| 22 public: | |
| 23 MockCompositorMutator() {} | |
| 24 | |
| 25 bool mutate(double monotonicTimeNow) override { return false; } | |
| 26 }; | |
| 27 | |
| 19 class MockCompositoMutationsTarget : public CompositorMutationsTarget { | 28 class MockCompositoMutationsTarget : public CompositorMutationsTarget { |
| 20 public: | 29 public: |
| 21 MOCK_METHOD1(applyMutations, void(CompositorMutations*)); | 30 MOCK_METHOD1(applyMutations, void(CompositorMutations*)); |
| 22 }; | 31 }; |
| 23 | 32 |
| 24 TEST(CompositorMutatorClient, CallbackForNonNullMutationsShouldApply) | 33 TEST(CompositorMutatorClient, CallbackForNonNullMutationsShouldApply) |
| 25 { | 34 { |
| 26 MockCompositoMutationsTarget target; | 35 MockCompositoMutationsTarget target; |
| 27 | 36 |
| 28 CompositorMutatorClient client(&target); | 37 CompositorMutatorClient client(new MockCompositorMutator, &target); |
| 29 OwnPtr<CompositorMutations> mutations = adoptPtr(new CompositorMutations()); | 38 OwnPtr<CompositorMutations> mutations = adoptPtr(new CompositorMutations()); |
| 30 client.setMutationsForTesting(mutations.release()); | 39 client.setMutationsForTesting(mutations.release()); |
| 31 | 40 |
| 32 EXPECT_CALL(target, applyMutations(_)); | 41 EXPECT_CALL(target, applyMutations(_)); |
| 33 client.TakeMutations().Run(); | 42 client.TakeMutations().Run(); |
| 34 } | 43 } |
| 35 | 44 |
| 36 TEST(CompositorMutatorClient, CallbackForNullMutationsShouldBeNoop) | 45 TEST(CompositorMutatorClient, CallbackForNullMutationsShouldBeNoop) |
| 37 { | 46 { |
| 38 MockCompositoMutationsTarget target; | 47 MockCompositoMutationsTarget target; |
| 39 CompositorMutatorClient client(&target); | 48 CompositorMutatorClient client(new MockCompositorMutator, &target); |
| 40 | 49 |
| 41 EXPECT_CALL(target, applyMutations(_)).Times(0); | 50 EXPECT_CALL(target, applyMutations(_)).Times(0); |
| 42 EXPECT_TRUE(client.TakeMutations().is_null()); | 51 EXPECT_TRUE(client.TakeMutations().is_null()); |
| 43 } | 52 } |
| 44 | 53 |
| 45 } // namespace | 54 } // namespace |
| 46 } // namespace blink | 55 } // namespace blink |
| OLD | NEW |