OLD | NEW |
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 <queue> | 5 #include <queue> |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "net/base/rand_callback.h" | 9 #include "net/base/rand_callback.h" |
10 #include "net/base/test_completion_callback.h" | 10 #include "net/base/test_completion_callback.h" |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 | 1049 |
1050 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_REMOVED, _)); | 1050 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_REMOVED, _)); |
1051 | 1051 |
1052 RunFor(base::TimeDelta::FromSeconds(6)); | 1052 RunFor(base::TimeDelta::FromSeconds(6)); |
1053 } | 1053 } |
1054 | 1054 |
1055 // Note: These tests assume that the ipv4 socket will always be created first. | 1055 // Note: These tests assume that the ipv4 socket will always be created first. |
1056 // This is a simplifying assumption based on the way the code works now. | 1056 // This is a simplifying assumption based on the way the code works now. |
1057 class SimpleMockSocketFactory : public MDnsSocketFactory { | 1057 class SimpleMockSocketFactory : public MDnsSocketFactory { |
1058 public: | 1058 public: |
1059 virtual void CreateSockets( | 1059 void CreateSockets(ScopedVector<DatagramServerSocket>* sockets) override { |
1060 ScopedVector<DatagramServerSocket>* sockets) override { | |
1061 sockets->clear(); | 1060 sockets->clear(); |
1062 sockets->swap(sockets_); | 1061 sockets->swap(sockets_); |
1063 } | 1062 } |
1064 | 1063 |
1065 void PushSocket(DatagramServerSocket* socket) { | 1064 void PushSocket(DatagramServerSocket* socket) { |
1066 sockets_.push_back(socket); | 1065 sockets_.push_back(socket); |
1067 } | 1066 } |
1068 | 1067 |
1069 private: | 1068 private: |
1070 ScopedVector<DatagramServerSocket> sockets_; | 1069 ScopedVector<DatagramServerSocket> sockets_; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 | 1152 |
1154 ASSERT_TRUE(InitConnection()); | 1153 ASSERT_TRUE(InitConnection()); |
1155 | 1154 |
1156 EXPECT_CALL(delegate_, OnConnectionError(ERR_SOCKET_NOT_CONNECTED)); | 1155 EXPECT_CALL(delegate_, OnConnectionError(ERR_SOCKET_NOT_CONNECTED)); |
1157 callback.Run(ERR_SOCKET_NOT_CONNECTED); | 1156 callback.Run(ERR_SOCKET_NOT_CONNECTED); |
1158 base::MessageLoop::current()->RunUntilIdle(); | 1157 base::MessageLoop::current()->RunUntilIdle(); |
1159 } | 1158 } |
1160 | 1159 |
1161 class MDnsConnectionSendTest : public MDnsConnectionTest { | 1160 class MDnsConnectionSendTest : public MDnsConnectionTest { |
1162 protected: | 1161 protected: |
1163 virtual void SetUp() override { | 1162 void SetUp() override { |
1164 MDnsConnectionTest::SetUp(); | 1163 MDnsConnectionTest::SetUp(); |
1165 EXPECT_CALL(*socket_ipv4_, RecvFrom(_, _, _, _)) | 1164 EXPECT_CALL(*socket_ipv4_, RecvFrom(_, _, _, _)) |
1166 .WillOnce(Return(ERR_IO_PENDING)); | 1165 .WillOnce(Return(ERR_IO_PENDING)); |
1167 EXPECT_CALL(*socket_ipv6_, RecvFrom(_, _, _, _)) | 1166 EXPECT_CALL(*socket_ipv6_, RecvFrom(_, _, _, _)) |
1168 .WillOnce(Return(ERR_IO_PENDING)); | 1167 .WillOnce(Return(ERR_IO_PENDING)); |
1169 EXPECT_TRUE(InitConnection()); | 1168 EXPECT_TRUE(InitConnection()); |
1170 } | 1169 } |
1171 }; | 1170 }; |
1172 | 1171 |
1173 TEST_F(MDnsConnectionSendTest, Send) { | 1172 TEST_F(MDnsConnectionSendTest, Send) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 // Expect call for the second IPv6 packed. | 1215 // Expect call for the second IPv6 packed. |
1217 EXPECT_CALL(*socket_ipv6_, | 1216 EXPECT_CALL(*socket_ipv6_, |
1218 SendToInternal(sample_packet_, "[ff02::fb]:5353", _)) | 1217 SendToInternal(sample_packet_, "[ff02::fb]:5353", _)) |
1219 .WillOnce(Return(OK)); | 1218 .WillOnce(Return(OK)); |
1220 callback.Run(OK); | 1219 callback.Run(OK); |
1221 } | 1220 } |
1222 | 1221 |
1223 } // namespace | 1222 } // namespace |
1224 | 1223 |
1225 } // namespace net | 1224 } // namespace net |
OLD | NEW |