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