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> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 | 107 |
108 StubIt2MeConfirmationDialog* dialog() { | 108 StubIt2MeConfirmationDialog* dialog() { |
109 return dialog_; | 109 return dialog_; |
110 } | 110 } |
111 | 111 |
112 private: | 112 private: |
113 base::MessageLoop message_loop_; | 113 base::MessageLoop message_loop_; |
114 base::RunLoop run_loop_; | 114 base::RunLoop run_loop_; |
115 base::Thread dialog_thread_; | 115 base::Thread dialog_thread_; |
116 | 116 |
117 // |dialog_| is owned by |dialog_proxy_| but we keep an alias for test | 117 // |dialog_| is owned by |dialog_proxy_| but we keep an alias for testing. |
118 // purposes. | 118 StubIt2MeConfirmationDialog* dialog_ = nullptr; |
119 StubIt2MeConfirmationDialog* dialog_; | |
120 std::unique_ptr<It2MeConfirmationDialogProxy> dialog_proxy_; | 119 std::unique_ptr<It2MeConfirmationDialogProxy> dialog_proxy_; |
121 }; | 120 }; |
122 | 121 |
123 It2MeConfirmationDialogProxyTest::It2MeConfirmationDialogProxyTest() | 122 It2MeConfirmationDialogProxyTest::It2MeConfirmationDialogProxyTest() |
124 : dialog_thread_("test dialog thread") { | 123 : dialog_thread_("test dialog thread") { |
125 dialog_thread_.Start(); | 124 dialog_thread_.Start(); |
126 | 125 |
127 dialog_ = new StubIt2MeConfirmationDialog(dialog_task_runner()); | 126 std::unique_ptr<StubIt2MeConfirmationDialog> dialog( |
Sergey Ulanov
2017/03/14 21:50:35
auto dialog = base::MakeUnique<StubIt2MeConfirmati
joedow
2017/03/16 21:39:10
Done.
| |
128 dialog_proxy_.reset(new It2MeConfirmationDialogProxy( | 127 new StubIt2MeConfirmationDialog(dialog_task_runner())); |
129 dialog_task_runner(), std::unique_ptr<It2MeConfirmationDialog>(dialog_))); | 128 dialog_ = dialog.get(); |
129 dialog_proxy_.reset(new It2MeConfirmationDialogProxy(dialog_task_runner(), | |
130 std::move(dialog))); | |
130 } | 131 } |
131 | 132 |
132 It2MeConfirmationDialogProxyTest::~It2MeConfirmationDialogProxyTest() {} | 133 It2MeConfirmationDialogProxyTest::~It2MeConfirmationDialogProxyTest() {} |
133 | 134 |
134 TEST_F(It2MeConfirmationDialogProxyTest, Show) { | 135 TEST_F(It2MeConfirmationDialogProxyTest, Show) { |
135 ResultCallbackTarget callback_target(main_task_runner()); | 136 ResultCallbackTarget callback_target(main_task_runner()); |
136 | 137 |
137 EXPECT_CALL(*dialog(), OnShow()) | 138 EXPECT_CALL(*dialog(), OnShow()) |
138 .WillOnce( | 139 .WillOnce( |
139 InvokeWithoutArgs( | 140 InvokeWithoutArgs( |
140 CreateFunctor( | 141 CreateFunctor( |
141 &StubIt2MeConfirmationDialog::ReportResult, | 142 &StubIt2MeConfirmationDialog::ReportResult, |
142 base::Unretained(dialog()), | 143 base::Unretained(dialog()), |
143 It2MeConfirmationDialog::Result::CANCEL))); | 144 It2MeConfirmationDialog::Result::CANCEL))); |
144 | 145 |
145 EXPECT_CALL(callback_target, | 146 EXPECT_CALL(callback_target, |
146 OnDialogResult(It2MeConfirmationDialog::Result::CANCEL)) | 147 OnDialogResult(It2MeConfirmationDialog::Result::CANCEL)) |
147 .WillOnce( | 148 .WillOnce( |
148 InvokeWithoutArgs(this, &It2MeConfirmationDialogProxyTest::Quit)); | 149 InvokeWithoutArgs(this, &It2MeConfirmationDialogProxyTest::Quit)); |
149 | 150 |
150 dialog_proxy()->Show(kTestEmailAddress, callback_target.MakeCallback()); | 151 dialog_proxy()->Show(kTestEmailAddress, callback_target.MakeCallback()); |
151 | 152 |
152 Run(); | 153 Run(); |
153 } | 154 } |
154 | 155 |
155 } // namespace remoting | 156 } // namespace remoting |
OLD | NEW |