| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 class PortServerTest : public testing::Test { | 122 class PortServerTest : public testing::Test { |
| 123 public: | 123 public: |
| 124 PortServerTest() : thread_("server") { | 124 PortServerTest() : thread_("server") { |
| 125 EXPECT_TRUE(thread_.Start()); | 125 EXPECT_TRUE(thread_.Start()); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void RunServer(const std::string& path, | 128 void RunServer(const std::string& path, |
| 129 const std::string& response, | 129 const std::string& response, |
| 130 std::string* request) { | 130 std::string* request) { |
| 131 base::WaitableEvent listen_event(false, false); | 131 base::WaitableEvent listen_event( |
| 132 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 133 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 132 thread_.task_runner()->PostTask( | 134 thread_.task_runner()->PostTask( |
| 133 FROM_HERE, | 135 FROM_HERE, |
| 134 base::Bind(&RunServerOnThread, path, response, &listen_event, request)); | 136 base::Bind(&RunServerOnThread, path, response, &listen_event, request)); |
| 135 ASSERT_TRUE(listen_event.TimedWait(base::TimeDelta::FromSeconds(5))); | 137 ASSERT_TRUE(listen_event.TimedWait(base::TimeDelta::FromSeconds(5))); |
| 136 } | 138 } |
| 137 | 139 |
| 138 private: | 140 private: |
| 139 base::Thread thread_; | 141 base::Thread thread_; |
| 140 }; | 142 }; |
| 141 | 143 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 Status status = mgr.ReservePortFromPool(&port, &reservation); | 214 Status status = mgr.ReservePortFromPool(&port, &reservation); |
| 213 ASSERT_EQ(kOk, status.code()) << status.message(); | 215 ASSERT_EQ(kOk, status.code()) << status.message(); |
| 214 ASSERT_TRUE(reservation); | 216 ASSERT_TRUE(reservation); |
| 215 ASSERT_GE(port, 15000); | 217 ASSERT_GE(port, 15000); |
| 216 ASSERT_LE(port, 16000); | 218 ASSERT_LE(port, 16000); |
| 217 if (i == 0) | 219 if (i == 0) |
| 218 first_port = port; | 220 first_port = port; |
| 219 ASSERT_EQ(port, first_port); | 221 ASSERT_EQ(port, first_port); |
| 220 } | 222 } |
| 221 } | 223 } |
| OLD | NEW |