OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "remoting/host/it2me/it2me_confirmation_dialog_proxy.h" | 5 #include "remoting/host/it2me/it2me_confirmation_dialog_proxy.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
11 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
12 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gmock_mutant.h" | 15 #include "testing/gmock_mutant.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 using ::testing::InvokeWithoutArgs; | 18 using ::testing::InvokeWithoutArgs; |
18 using ::testing::CreateFunctor; | 19 using ::testing::CreateFunctor; |
19 | 20 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 } | 104 } |
104 | 105 |
105 private: | 106 private: |
106 base::MessageLoop message_loop_; | 107 base::MessageLoop message_loop_; |
107 base::RunLoop run_loop_; | 108 base::RunLoop run_loop_; |
108 base::Thread dialog_thread_; | 109 base::Thread dialog_thread_; |
109 | 110 |
110 // |dialog_| is owned by |dialog_proxy_| but we keep an alias for test | 111 // |dialog_| is owned by |dialog_proxy_| but we keep an alias for test |
111 // purposes. | 112 // purposes. |
112 StubIt2MeConfirmationDialog* dialog_; | 113 StubIt2MeConfirmationDialog* dialog_; |
113 scoped_ptr<It2MeConfirmationDialogProxy> dialog_proxy_; | 114 std::unique_ptr<It2MeConfirmationDialogProxy> dialog_proxy_; |
114 }; | 115 }; |
115 | 116 |
116 It2MeConfirmationDialogProxyTest::It2MeConfirmationDialogProxyTest() | 117 It2MeConfirmationDialogProxyTest::It2MeConfirmationDialogProxyTest() |
117 : dialog_thread_("test dialog thread") { | 118 : dialog_thread_("test dialog thread") { |
118 dialog_thread_.Start(); | 119 dialog_thread_.Start(); |
119 | 120 |
120 dialog_ = new StubIt2MeConfirmationDialog(dialog_task_runner()); | 121 dialog_ = new StubIt2MeConfirmationDialog(dialog_task_runner()); |
121 dialog_proxy_.reset(new It2MeConfirmationDialogProxy( | 122 dialog_proxy_.reset(new It2MeConfirmationDialogProxy( |
122 dialog_task_runner(), | 123 dialog_task_runner(), std::unique_ptr<It2MeConfirmationDialog>(dialog_))); |
123 scoped_ptr<It2MeConfirmationDialog>(dialog_))); | |
124 } | 124 } |
125 | 125 |
126 It2MeConfirmationDialogProxyTest::~It2MeConfirmationDialogProxyTest() {} | 126 It2MeConfirmationDialogProxyTest::~It2MeConfirmationDialogProxyTest() {} |
127 | 127 |
128 TEST_F(It2MeConfirmationDialogProxyTest, Show) { | 128 TEST_F(It2MeConfirmationDialogProxyTest, Show) { |
129 ResultCallbackTarget callback_target(main_task_runner()); | 129 ResultCallbackTarget callback_target(main_task_runner()); |
130 | 130 |
131 EXPECT_CALL(*dialog(), OnShow()) | 131 EXPECT_CALL(*dialog(), OnShow()) |
132 .WillOnce( | 132 .WillOnce( |
133 InvokeWithoutArgs( | 133 InvokeWithoutArgs( |
134 CreateFunctor( | 134 CreateFunctor( |
135 &StubIt2MeConfirmationDialog::ReportResult, | 135 &StubIt2MeConfirmationDialog::ReportResult, |
136 base::Unretained(dialog()), | 136 base::Unretained(dialog()), |
137 It2MeConfirmationDialog::Result::CANCEL))); | 137 It2MeConfirmationDialog::Result::CANCEL))); |
138 | 138 |
139 EXPECT_CALL(callback_target, | 139 EXPECT_CALL(callback_target, |
140 OnDialogResult(It2MeConfirmationDialog::Result::CANCEL)) | 140 OnDialogResult(It2MeConfirmationDialog::Result::CANCEL)) |
141 .WillOnce( | 141 .WillOnce( |
142 InvokeWithoutArgs(this, &It2MeConfirmationDialogProxyTest::Quit)); | 142 InvokeWithoutArgs(this, &It2MeConfirmationDialogProxyTest::Quit)); |
143 | 143 |
144 dialog_proxy()->Show(callback_target.MakeCallback()); | 144 dialog_proxy()->Show(callback_target.MakeCallback()); |
145 | 145 |
146 Run(); | 146 Run(); |
147 } | 147 } |
148 | 148 |
149 } // namespace remoting | 149 } // namespace remoting |
OLD | NEW |