| 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 "platform/graphics/CompositorMutator.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "wtf/OwnPtr.h" | 13 #include "wtf/PtrUtil.h" |
| 14 #include <memory> |
| 14 | 15 |
| 15 using ::testing::_; | 16 using ::testing::_; |
| 16 | 17 |
| 17 namespace blink { | 18 namespace blink { |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 class StubCompositorMutator : public CompositorMutator { | 21 class StubCompositorMutator : public CompositorMutator { |
| 21 public: | 22 public: |
| 22 StubCompositorMutator() {} | 23 StubCompositorMutator() {} |
| 23 | 24 |
| 24 bool mutate(double monotonicTimeNow) override { return false; } | 25 bool mutate(double monotonicTimeNow) override { return false; } |
| 25 }; | 26 }; |
| 26 | 27 |
| 27 class MockCompositoMutationsTarget : public CompositorMutationsTarget { | 28 class MockCompositoMutationsTarget : public CompositorMutationsTarget { |
| 28 public: | 29 public: |
| 29 MOCK_METHOD1(applyMutations, void(CompositorMutations*)); | 30 MOCK_METHOD1(applyMutations, void(CompositorMutations*)); |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 TEST(CompositorMutatorClient, CallbackForNonNullMutationsShouldApply) | 33 TEST(CompositorMutatorClient, CallbackForNonNullMutationsShouldApply) |
| 33 { | 34 { |
| 34 MockCompositoMutationsTarget target; | 35 MockCompositoMutationsTarget target; |
| 35 | 36 |
| 36 CompositorMutatorClient client(new StubCompositorMutator, &target); | 37 CompositorMutatorClient client(new StubCompositorMutator, &target); |
| 37 OwnPtr<CompositorMutations> mutations = adoptPtr(new CompositorMutations()); | 38 std::unique_ptr<CompositorMutations> mutations = wrapUnique(new CompositorMu
tations()); |
| 38 client.setMutationsForTesting(std::move(mutations)); | 39 client.setMutationsForTesting(std::move(mutations)); |
| 39 | 40 |
| 40 EXPECT_CALL(target, applyMutations(_)); | 41 EXPECT_CALL(target, applyMutations(_)); |
| 41 client.TakeMutations().Run(); | 42 client.TakeMutations().Run(); |
| 42 } | 43 } |
| 43 | 44 |
| 44 TEST(CompositorMutatorClient, CallbackForNullMutationsShouldBeNoop) | 45 TEST(CompositorMutatorClient, CallbackForNullMutationsShouldBeNoop) |
| 45 { | 46 { |
| 46 MockCompositoMutationsTarget target; | 47 MockCompositoMutationsTarget target; |
| 47 CompositorMutatorClient client(new StubCompositorMutator, &target); | 48 CompositorMutatorClient client(new StubCompositorMutator, &target); |
| 48 | 49 |
| 49 EXPECT_CALL(target, applyMutations(_)).Times(0); | 50 EXPECT_CALL(target, applyMutations(_)).Times(0); |
| 50 EXPECT_TRUE(client.TakeMutations().is_null()); | 51 EXPECT_TRUE(client.TakeMutations().is_null()); |
| 51 } | 52 } |
| 52 | 53 |
| 53 } // namespace | 54 } // namespace |
| 54 } // namespace blink | 55 } // namespace blink |
| OLD | NEW |