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 StubCompositorMutator : public CompositorMutator { |
| 21 public: |
| 22 StubCompositorMutator() {} |
| 23 |
| 24 bool mutate(double monotonicTimeNow) override { return false; } |
| 25 }; |
| 26 |
19 class MockCompositoMutationsTarget : public CompositorMutationsTarget { | 27 class MockCompositoMutationsTarget : public CompositorMutationsTarget { |
20 public: | 28 public: |
21 MOCK_METHOD1(applyMutations, void(CompositorMutations*)); | 29 MOCK_METHOD1(applyMutations, void(CompositorMutations*)); |
22 }; | 30 }; |
23 | 31 |
24 TEST(CompositorMutatorClient, CallbackForNonNullMutationsShouldApply) | 32 TEST(CompositorMutatorClient, CallbackForNonNullMutationsShouldApply) |
25 { | 33 { |
26 MockCompositoMutationsTarget target; | 34 MockCompositoMutationsTarget target; |
27 | 35 |
28 CompositorMutatorClient client(&target); | 36 CompositorMutatorClient client(new StubCompositorMutator, &target); |
29 OwnPtr<CompositorMutations> mutations = adoptPtr(new CompositorMutations()); | 37 OwnPtr<CompositorMutations> mutations = adoptPtr(new CompositorMutations()); |
30 client.setMutationsForTesting(std::move(mutations)); | 38 client.setMutationsForTesting(std::move(mutations)); |
31 | 39 |
32 EXPECT_CALL(target, applyMutations(_)); | 40 EXPECT_CALL(target, applyMutations(_)); |
33 client.TakeMutations().Run(); | 41 client.TakeMutations().Run(); |
34 } | 42 } |
35 | 43 |
36 TEST(CompositorMutatorClient, CallbackForNullMutationsShouldBeNoop) | 44 TEST(CompositorMutatorClient, CallbackForNullMutationsShouldBeNoop) |
37 { | 45 { |
38 MockCompositoMutationsTarget target; | 46 MockCompositoMutationsTarget target; |
39 CompositorMutatorClient client(&target); | 47 CompositorMutatorClient client(new StubCompositorMutator, &target); |
40 | 48 |
41 EXPECT_CALL(target, applyMutations(_)).Times(0); | 49 EXPECT_CALL(target, applyMutations(_)).Times(0); |
42 EXPECT_TRUE(client.TakeMutations().is_null()); | 50 EXPECT_TRUE(client.TakeMutations().is_null()); |
43 } | 51 } |
44 | 52 |
45 } // namespace | 53 } // namespace |
46 } // namespace blink | 54 } // namespace blink |
OLD | NEW |