Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/CompositorMutatorClientTest.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/PtrUtil.h" 13 #include "wtf/OwnPtr.h"
14 #include <memory>
15 14
16 using ::testing::_; 15 using ::testing::_;
17 16
18 namespace blink { 17 namespace blink {
19 namespace { 18 namespace {
20 19
21 class StubCompositorMutator : public CompositorMutator { 20 class StubCompositorMutator : public CompositorMutator {
22 public: 21 public:
23 StubCompositorMutator() {} 22 StubCompositorMutator() {}
24 23
25 bool mutate(double monotonicTimeNow, 24 bool mutate(double monotonicTimeNow,
26 CompositorMutableStateProvider* stateProvider) override 25 CompositorMutableStateProvider* stateProvider) override
27 { 26 {
28 return false; 27 return false;
29 } 28 }
30 }; 29 };
31 30
32 class MockCompositoMutationsTarget : public CompositorMutationsTarget { 31 class MockCompositoMutationsTarget : public CompositorMutationsTarget {
33 public: 32 public:
34 MOCK_METHOD1(applyMutations, void(CompositorMutations*)); 33 MOCK_METHOD1(applyMutations, void(CompositorMutations*));
35 }; 34 };
36 35
37 TEST(CompositorMutatorClient, CallbackForNonNullMutationsShouldApply) 36 TEST(CompositorMutatorClient, CallbackForNonNullMutationsShouldApply)
38 { 37 {
39 MockCompositoMutationsTarget target; 38 MockCompositoMutationsTarget target;
40 39
41 CompositorMutatorClient client(new StubCompositorMutator, &target); 40 CompositorMutatorClient client(new StubCompositorMutator, &target);
42 std::unique_ptr<CompositorMutations> mutations = wrapUnique(new CompositorMu tations()); 41 OwnPtr<CompositorMutations> mutations = adoptPtr(new CompositorMutations());
43 client.setMutationsForTesting(std::move(mutations)); 42 client.setMutationsForTesting(std::move(mutations));
44 43
45 EXPECT_CALL(target, applyMutations(_)); 44 EXPECT_CALL(target, applyMutations(_));
46 client.TakeMutations().Run(); 45 client.TakeMutations().Run();
47 } 46 }
48 47
49 TEST(CompositorMutatorClient, CallbackForNullMutationsShouldBeNoop) 48 TEST(CompositorMutatorClient, CallbackForNullMutationsShouldBeNoop)
50 { 49 {
51 MockCompositoMutationsTarget target; 50 MockCompositoMutationsTarget target;
52 CompositorMutatorClient client(new StubCompositorMutator, &target); 51 CompositorMutatorClient client(new StubCompositorMutator, &target);
53 52
54 EXPECT_CALL(target, applyMutations(_)).Times(0); 53 EXPECT_CALL(target, applyMutations(_)).Times(0);
55 EXPECT_TRUE(client.TakeMutations().is_null()); 54 EXPECT_TRUE(client.TakeMutations().is_null());
56 } 55 }
57 56
58 } // namespace 57 } // namespace
59 } // namespace blink 58 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698