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

Side by Side Diff: remoting/protocol/chromium_socket_factory_unittest.cc

Issue 2082363002: Remove calls to deprecated MessageLoop methods in remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing include Created 4 years, 6 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/protocol/chromium_socket_factory.h" 5 #include "remoting/protocol/chromium_socket_factory.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/single_thread_task_runner.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/webrtc/base/asyncpacketsocket.h" 17 #include "third_party/webrtc/base/asyncpacketsocket.h"
17 #include "third_party/webrtc/base/socketaddress.h" 18 #include "third_party/webrtc/base/socketaddress.h"
18 19
19 namespace remoting { 20 namespace remoting {
20 namespace protocol { 21 namespace protocol {
21 22
22 class ChromiumSocketFactoryTest : public testing::Test, 23 class ChromiumSocketFactoryTest : public testing::Test,
23 public sigslot::has_slots<> { 24 public sigslot::has_slots<> {
(...skipping 22 matching lines...) Expand all
46 void VerifyCanSendAndReceive(rtc::AsyncPacketSocket* sender) { 47 void VerifyCanSendAndReceive(rtc::AsyncPacketSocket* sender) {
47 // UDP packets may be lost, so we have to retry sending it more than once. 48 // UDP packets may be lost, so we have to retry sending it more than once.
48 const int kMaxAttempts = 3; 49 const int kMaxAttempts = 3;
49 const base::TimeDelta kAttemptPeriod = base::TimeDelta::FromSeconds(1); 50 const base::TimeDelta kAttemptPeriod = base::TimeDelta::FromSeconds(1);
50 std::string test_packet("TEST PACKET"); 51 std::string test_packet("TEST PACKET");
51 int attempts = 0; 52 int attempts = 0;
52 rtc::PacketOptions options; 53 rtc::PacketOptions options;
53 while (last_packet_.empty() && attempts++ < kMaxAttempts) { 54 while (last_packet_.empty() && attempts++ < kMaxAttempts) {
54 sender->SendTo(test_packet.data(), test_packet.size(), 55 sender->SendTo(test_packet.data(), test_packet.size(),
55 socket_->GetLocalAddress(), options); 56 socket_->GetLocalAddress(), options);
56 message_loop_.PostDelayedTask(FROM_HERE, run_loop_.QuitClosure(), 57 message_loop_.task_runner()->PostDelayedTask(
57 kAttemptPeriod); 58 FROM_HERE, run_loop_.QuitClosure(), kAttemptPeriod);
58 run_loop_.Run(); 59 run_loop_.Run();
59 } 60 }
60 EXPECT_EQ(test_packet, last_packet_); 61 EXPECT_EQ(test_packet, last_packet_);
61 EXPECT_EQ(sender->GetLocalAddress(), last_address_); 62 EXPECT_EQ(sender->GetLocalAddress(), last_address_);
62 } 63 }
63 64
64 protected: 65 protected:
65 base::MessageLoopForIO message_loop_; 66 base::MessageLoopForIO message_loop_;
66 base::RunLoop run_loop_; 67 base::RunLoop run_loop_;
67 68
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 sending_socket->SendTo(test_packet.data(), test_packet.size(), 112 sending_socket->SendTo(test_packet.data(), test_packet.size(),
112 rtc::SocketAddress("::1", 0), 113 rtc::SocketAddress("::1", 0),
113 rtc::PacketOptions()); 114 rtc::PacketOptions());
114 115
115 // Verify that socket is still usable. 116 // Verify that socket is still usable.
116 VerifyCanSendAndReceive(sending_socket.get()); 117 VerifyCanSendAndReceive(sending_socket.get());
117 } 118 }
118 119
119 } // namespace protocol 120 } // namespace protocol
120 } // namespace remoting 121 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/authenticator_test_base.cc ('k') | remoting/protocol/pseudotcp_adapter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698