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

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

Issue 2380463005: It2Me Host cleanup - Remove task_runner_ (Closed)
Patch Set: Removing unused header file Created 4 years, 2 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
« no previous file with comments | « remoting/host/it2me/it2me_host.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_native_messaging_host.h" 5 #include "remoting/host/it2me/it2me_native_messaging_host.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 private: 144 private:
145 ~MockIt2MeHost() override {} 145 ~MockIt2MeHost() override {}
146 146
147 void RunSetState(It2MeHostState state); 147 void RunSetState(It2MeHostState state);
148 148
149 DISALLOW_COPY_AND_ASSIGN(MockIt2MeHost); 149 DISALLOW_COPY_AND_ASSIGN(MockIt2MeHost);
150 }; 150 };
151 151
152 void MockIt2MeHost::Connect() { 152 void MockIt2MeHost::Connect() {
153 if (!host_context()->ui_task_runner()->BelongsToCurrentThread()) { 153 if (!host_context()->ui_task_runner()->BelongsToCurrentThread()) {
154 DCHECK(task_runner()->BelongsToCurrentThread());
155 host_context()->ui_task_runner()->PostTask( 154 host_context()->ui_task_runner()->PostTask(
156 FROM_HERE, base::Bind(&MockIt2MeHost::Connect, this)); 155 FROM_HERE, base::Bind(&MockIt2MeHost::Connect, this));
157 return; 156 return;
158 } 157 }
159 158
160 RunSetState(kStarting); 159 RunSetState(kStarting);
161 RunSetState(kRequestedAccessCode); 160 RunSetState(kRequestedAccessCode);
162 161
163 std::string access_code(kTestAccessCode); 162 std::string access_code(kTestAccessCode);
164 base::TimeDelta lifetime = 163 base::TimeDelta lifetime =
165 base::TimeDelta::FromSeconds(kTestAccessCodeLifetimeInSeconds); 164 base::TimeDelta::FromSeconds(kTestAccessCodeLifetimeInSeconds);
166 task_runner()->PostTask(FROM_HERE, 165 host_context()->ui_task_runner()->PostTask(
167 base::Bind(&It2MeHost::Observer::OnStoreAccessCode, 166 FROM_HERE, base::Bind(&It2MeHost::Observer::OnStoreAccessCode, observer(),
168 observer(), 167 access_code, lifetime));
169 access_code,
170 lifetime));
171 168
172 RunSetState(kReceivedAccessCode); 169 RunSetState(kReceivedAccessCode);
173 170
174 std::string client_username(kTestClientUsername); 171 std::string client_username(kTestClientUsername);
175 task_runner()->PostTask( 172 host_context()->ui_task_runner()->PostTask(
176 FROM_HERE, 173 FROM_HERE, base::Bind(&It2MeHost::Observer::OnClientAuthenticated,
177 base::Bind(&It2MeHost::Observer::OnClientAuthenticated, 174 observer(), client_username));
178 observer(),
179 client_username));
180 175
181 RunSetState(kConnected); 176 RunSetState(kConnected);
182 } 177 }
183 178
184 void MockIt2MeHost::Disconnect() { 179 void MockIt2MeHost::Disconnect() {
185 if (!host_context()->network_task_runner()->BelongsToCurrentThread()) { 180 if (!host_context()->network_task_runner()->BelongsToCurrentThread()) {
186 DCHECK(task_runner()->BelongsToCurrentThread()); 181 DCHECK(host_context()->ui_task_runner()->BelongsToCurrentThread());
187 host_context()->network_task_runner()->PostTask( 182 host_context()->network_task_runner()->PostTask(
188 FROM_HERE, base::Bind(&MockIt2MeHost::Disconnect, this)); 183 FROM_HERE, base::Bind(&MockIt2MeHost::Disconnect, this));
189 return; 184 return;
190 } 185 }
191 186
192 RunSetState(kDisconnected); 187 RunSetState(kDisconnected);
193 } 188 }
194 189
195 void MockIt2MeHost::RequestNatPolicy() {} 190 void MockIt2MeHost::RequestNatPolicy() {}
196 191
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 } 619 }
625 620
626 // Verify rejection if type is unrecognized. 621 // Verify rejection if type is unrecognized.
627 TEST_F(It2MeNativeMessagingHostTest, InvalidType) { 622 TEST_F(It2MeNativeMessagingHostTest, InvalidType) {
628 base::DictionaryValue message; 623 base::DictionaryValue message;
629 message.SetString("type", "xxx"); 624 message.SetString("type", "xxx");
630 TestBadRequest(message, true); 625 TestBadRequest(message, true);
631 } 626 }
632 627
633 } // namespace remoting 628 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/it2me/it2me_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698