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

Side by Side Diff: remoting/host/it2me/it2me_confirmation_dialog_proxy_unittest.cc

Issue 2650443002: Webapp share dialog is not closed when client end of the connection is closed (Closed)
Patch Set: Merging changes from dependent CL Created 3 years, 9 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 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/ptr_util.h"
10 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
11 #include "base/run_loop.h" 12 #include "base/run_loop.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gmock_mutant.h" 16 #include "testing/gmock_mutant.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 using ::testing::InvokeWithoutArgs; 19 using ::testing::InvokeWithoutArgs;
19 using ::testing::CreateFunctor; 20 using ::testing::CreateFunctor;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 108
108 StubIt2MeConfirmationDialog* dialog() { 109 StubIt2MeConfirmationDialog* dialog() {
109 return dialog_; 110 return dialog_;
110 } 111 }
111 112
112 private: 113 private:
113 base::MessageLoop message_loop_; 114 base::MessageLoop message_loop_;
114 base::RunLoop run_loop_; 115 base::RunLoop run_loop_;
115 base::Thread dialog_thread_; 116 base::Thread dialog_thread_;
116 117
117 // |dialog_| is owned by |dialog_proxy_| but we keep an alias for test 118 // |dialog_| is owned by |dialog_proxy_| but we keep an alias for testing.
118 // purposes. 119 StubIt2MeConfirmationDialog* dialog_ = nullptr;
119 StubIt2MeConfirmationDialog* dialog_;
120 std::unique_ptr<It2MeConfirmationDialogProxy> dialog_proxy_; 120 std::unique_ptr<It2MeConfirmationDialogProxy> dialog_proxy_;
121 }; 121 };
122 122
123 It2MeConfirmationDialogProxyTest::It2MeConfirmationDialogProxyTest() 123 It2MeConfirmationDialogProxyTest::It2MeConfirmationDialogProxyTest()
124 : dialog_thread_("test dialog thread") { 124 : dialog_thread_("test dialog thread") {
125 dialog_thread_.Start(); 125 dialog_thread_.Start();
126 126
127 dialog_ = new StubIt2MeConfirmationDialog(dialog_task_runner()); 127 auto dialog =
128 dialog_proxy_.reset(new It2MeConfirmationDialogProxy( 128 base::MakeUnique<StubIt2MeConfirmationDialog>(dialog_task_runner());
129 dialog_task_runner(), std::unique_ptr<It2MeConfirmationDialog>(dialog_))); 129 dialog_ = dialog.get();
130 dialog_proxy_.reset(new It2MeConfirmationDialogProxy(dialog_task_runner(),
131 std::move(dialog)));
130 } 132 }
131 133
132 It2MeConfirmationDialogProxyTest::~It2MeConfirmationDialogProxyTest() {} 134 It2MeConfirmationDialogProxyTest::~It2MeConfirmationDialogProxyTest() {}
133 135
134 TEST_F(It2MeConfirmationDialogProxyTest, Show) { 136 TEST_F(It2MeConfirmationDialogProxyTest, Show) {
135 ResultCallbackTarget callback_target(main_task_runner()); 137 ResultCallbackTarget callback_target(main_task_runner());
136 138
137 EXPECT_CALL(*dialog(), OnShow()) 139 EXPECT_CALL(*dialog(), OnShow())
138 .WillOnce( 140 .WillOnce(
139 InvokeWithoutArgs( 141 InvokeWithoutArgs(
140 CreateFunctor( 142 CreateFunctor(
141 &StubIt2MeConfirmationDialog::ReportResult, 143 &StubIt2MeConfirmationDialog::ReportResult,
142 base::Unretained(dialog()), 144 base::Unretained(dialog()),
143 It2MeConfirmationDialog::Result::CANCEL))); 145 It2MeConfirmationDialog::Result::CANCEL)));
144 146
145 EXPECT_CALL(callback_target, 147 EXPECT_CALL(callback_target,
146 OnDialogResult(It2MeConfirmationDialog::Result::CANCEL)) 148 OnDialogResult(It2MeConfirmationDialog::Result::CANCEL))
147 .WillOnce( 149 .WillOnce(
148 InvokeWithoutArgs(this, &It2MeConfirmationDialogProxyTest::Quit)); 150 InvokeWithoutArgs(this, &It2MeConfirmationDialogProxyTest::Quit));
149 151
150 dialog_proxy()->Show(kTestEmailAddress, callback_target.MakeCallback()); 152 dialog_proxy()->Show(kTestEmailAddress, callback_target.MakeCallback());
151 153
152 Run(); 154 Run();
153 } 155 }
154 156
155 } // namespace remoting 157 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/it2me/it2me_confirmation_dialog_mac.mm ('k') | remoting/host/it2me/it2me_confirmation_dialog_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698