OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 6 #include <string> |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 void GenerateBody(string* body, int length) { | 47 void GenerateBody(string* body, int length) { |
48 body->clear(); | 48 body->clear(); |
49 body->reserve(length); | 49 body->reserve(length); |
50 for (int i = 0; i < length; ++i) { | 50 for (int i = 0; i < length; ++i) { |
51 body->append(1, static_cast<char>(32 + i % (126 - 32))); | 51 body->append(1, static_cast<char>(32 + i % (126 - 32))); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 | 55 |
56 // Simple wrapper class to run GFE in a thread. | 56 // Simple wrapper class to run server in a thread. |
57 class ServerThread : public base::SimpleThread { | 57 class ServerThread : public base::SimpleThread { |
58 public: | 58 public: |
59 explicit ServerThread(IPEndPoint address) | 59 explicit ServerThread(IPEndPoint address) |
60 : SimpleThread("server_thread"), | 60 : SimpleThread("server_thread"), |
61 listening_(true, false), | 61 listening_(true, false), |
62 quit_(true, false), | 62 quit_(true, false), |
63 address_(address), | 63 address_(address), |
64 port_(0) { | 64 port_(0) { |
65 } | 65 } |
66 virtual ~ServerThread() { | 66 virtual ~ServerThread() { |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 EXPECT_EQ(200ul, client_->response_headers()->parsed_response_code()); | 522 EXPECT_EQ(200ul, client_->response_headers()->parsed_response_code()); |
523 client_->ResetConnection(); | 523 client_->ResetConnection(); |
524 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); | 524 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); |
525 EXPECT_EQ(200ul, client_->response_headers()->parsed_response_code()); | 525 EXPECT_EQ(200ul, client_->response_headers()->parsed_response_code()); |
526 } | 526 } |
527 | 527 |
528 } // namespace | 528 } // namespace |
529 } // namespace test | 529 } // namespace test |
530 } // namespace tools | 530 } // namespace tools |
531 } // namespace net | 531 } // namespace net |
OLD | NEW |