OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef COMPONENTS_BUBBLE_BUBBLE_MANAGER_MOCKS_H_ | 5 #ifndef COMPONENTS_BUBBLE_BUBBLE_MANAGER_MOCKS_H_ |
6 #define COMPONENTS_BUBBLE_BUBBLE_MANAGER_MOCKS_H_ | 6 #define COMPONENTS_BUBBLE_BUBBLE_MANAGER_MOCKS_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <utility> | 9 #include <utility> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "components/bubble/bubble_delegate.h" | 12 #include "components/bubble/bubble_delegate.h" |
12 #include "components/bubble/bubble_reference.h" | 13 #include "components/bubble/bubble_reference.h" |
13 #include "components/bubble/bubble_ui.h" | 14 #include "components/bubble/bubble_ui.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
15 | 16 |
16 class MockBubbleUi : public BubbleUi { | 17 class MockBubbleUi : public BubbleUi { |
17 public: | 18 public: |
(...skipping 10 matching lines...) Expand all Loading... |
28 private: | 29 private: |
29 DISALLOW_COPY_AND_ASSIGN(MockBubbleUi); | 30 DISALLOW_COPY_AND_ASSIGN(MockBubbleUi); |
30 }; | 31 }; |
31 | 32 |
32 class MockBubbleDelegate : public BubbleDelegate { | 33 class MockBubbleDelegate : public BubbleDelegate { |
33 public: | 34 public: |
34 MockBubbleDelegate(); | 35 MockBubbleDelegate(); |
35 ~MockBubbleDelegate() override; | 36 ~MockBubbleDelegate() override; |
36 | 37 |
37 // Default bubble shows UI and closes when asked to close. | 38 // Default bubble shows UI and closes when asked to close. |
38 static scoped_ptr<MockBubbleDelegate> Default(); | 39 static std::unique_ptr<MockBubbleDelegate> Default(); |
39 | 40 |
40 // Stubborn bubble shows UI and doesn't want to close. | 41 // Stubborn bubble shows UI and doesn't want to close. |
41 static scoped_ptr<MockBubbleDelegate> Stubborn(); | 42 static std::unique_ptr<MockBubbleDelegate> Stubborn(); |
42 | 43 |
43 MOCK_CONST_METHOD1(ShouldClose, bool(BubbleCloseReason reason)); | 44 MOCK_CONST_METHOD1(ShouldClose, bool(BubbleCloseReason reason)); |
44 MOCK_METHOD1(DidClose, void(BubbleCloseReason reason)); | 45 MOCK_METHOD1(DidClose, void(BubbleCloseReason reason)); |
45 | 46 |
46 // A scoped_ptr can't be returned in MOCK_METHOD. | 47 // A scoped_ptr can't be returned in MOCK_METHOD. |
47 scoped_ptr<BubbleUi> BuildBubbleUi() override { | 48 std::unique_ptr<BubbleUi> BuildBubbleUi() override { |
48 return std::move(bubble_ui_); | 49 return std::move(bubble_ui_); |
49 } | 50 } |
50 | 51 |
51 MOCK_METHOD1(UpdateBubbleUi, bool(BubbleUi*)); | 52 MOCK_METHOD1(UpdateBubbleUi, bool(BubbleUi*)); |
52 | 53 |
53 std::string GetName() const override { return "MockBubble"; } | 54 std::string GetName() const override { return "MockBubble"; } |
54 | 55 |
55 // To verify destructor call. | 56 // To verify destructor call. |
56 MOCK_METHOD0(Destroyed, void()); | 57 MOCK_METHOD0(Destroyed, void()); |
57 | 58 |
58 // Will be null after |BubbleManager::ShowBubble| is called. | 59 // Will be null after |BubbleManager::ShowBubble| is called. |
59 MockBubbleUi* bubble_ui() { return bubble_ui_.get(); } | 60 MockBubbleUi* bubble_ui() { return bubble_ui_.get(); } |
60 | 61 |
61 MOCK_CONST_METHOD0(OwningFrame, const content::RenderFrameHost*()); | 62 MOCK_CONST_METHOD0(OwningFrame, const content::RenderFrameHost*()); |
62 | 63 |
63 private: | 64 private: |
64 scoped_ptr<MockBubbleUi> bubble_ui_; | 65 std::unique_ptr<MockBubbleUi> bubble_ui_; |
65 | 66 |
66 DISALLOW_COPY_AND_ASSIGN(MockBubbleDelegate); | 67 DISALLOW_COPY_AND_ASSIGN(MockBubbleDelegate); |
67 }; | 68 }; |
68 | 69 |
69 #endif // COMPONENTS_BUBBLE_BUBBLE_MANAGER_MOCKS_H_ | 70 #endif // COMPONENTS_BUBBLE_BUBBLE_MANAGER_MOCKS_H_ |
OLD | NEW |