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 #ifndef NET_TEST_LOCAL_TEST_SERVER_H_ | 5 #ifndef NET_TEST_LOCAL_TEST_SERVER_H_ |
6 #define NET_TEST_LOCAL_TEST_SERVER_H_ | 6 #define NET_TEST_LOCAL_TEST_SERVER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 const FilePath& document_root); | 30 const FilePath& document_root); |
31 | 31 |
32 // Initialize a TestServer with a specific set of SSLOptions. | 32 // Initialize a TestServer with a specific set of SSLOptions. |
33 // |document_root| must be a relative path under the root tree. | 33 // |document_root| must be a relative path under the root tree. |
34 LocalTestServer(Type type, | 34 LocalTestServer(Type type, |
35 const SSLOptions& ssl_options, | 35 const SSLOptions& ssl_options, |
36 const FilePath& document_root); | 36 const FilePath& document_root); |
37 | 37 |
38 virtual ~LocalTestServer(); | 38 virtual ~LocalTestServer(); |
39 | 39 |
| 40 // Start the test server and block until it's ready. Returns true on success. |
40 bool Start() WARN_UNUSED_RESULT; | 41 bool Start() WARN_UNUSED_RESULT; |
41 | 42 |
| 43 // Start the test server without blocking. Use this if you need multiple test |
| 44 // servers (such as WebSockets and HTTP, or HTTP and HTTPS). You must call |
| 45 // BlockUntilStarted on all servers your test requires before executing the |
| 46 // test. For example: |
| 47 // |
| 48 // // Start the servers in parallel. |
| 49 // ASSERT_TRUE(http_server.StartInBackground()); |
| 50 // ASSERT_TRUE(websocket_server.StartInBackground()); |
| 51 // // Wait for both servers to be ready. |
| 52 // ASSERT_TRUE(http_server.BlockUntilStarted()); |
| 53 // ASSERT_TRUE(websocket_server.BlockUntilStarted()); |
| 54 // RunMyTest(); |
| 55 // |
| 56 // Returns true on success. |
| 57 bool StartInBackground() WARN_UNUSED_RESULT; |
| 58 |
| 59 // Block until ths test server is ready. Returns true on success. See |
| 60 // StartInBackground() documentation for more information. |
| 61 bool BlockUntilStarted() WARN_UNUSED_RESULT; |
| 62 |
42 // Stop the server started by Start(). | 63 // Stop the server started by Start(). |
43 bool Stop(); | 64 bool Stop(); |
44 | 65 |
45 // Modify PYTHONPATH to contain libraries we need. | 66 // Modify PYTHONPATH to contain libraries we need. |
46 virtual bool SetPythonPath() const WARN_UNUSED_RESULT; | 67 virtual bool SetPythonPath() const WARN_UNUSED_RESULT; |
47 | 68 |
48 // Returns true if the FilePath for the testserver python script is | 69 // Returns true if the FilePath for the testserver python script is |
49 // successfully stored in |*testserver_path|. | 70 // successfully stored in |*testserver_path|. |
50 virtual bool GetTestServerPath(FilePath* testserver_path) const | 71 virtual bool GetTestServerPath(FilePath* testserver_path) const |
51 WARN_UNUSED_RESULT; | 72 WARN_UNUSED_RESULT; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 int child_fd_; | 108 int child_fd_; |
88 file_util::ScopedFD child_fd_closer_; | 109 file_util::ScopedFD child_fd_closer_; |
89 #endif | 110 #endif |
90 | 111 |
91 DISALLOW_COPY_AND_ASSIGN(LocalTestServer); | 112 DISALLOW_COPY_AND_ASSIGN(LocalTestServer); |
92 }; | 113 }; |
93 | 114 |
94 } // namespace net | 115 } // namespace net |
95 | 116 |
96 #endif // NET_TEST_LOCAL_TEST_SERVER_H_ | 117 #endif // NET_TEST_LOCAL_TEST_SERVER_H_ |
OLD | NEW |