Chromium Code Reviews| 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 #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, | |
| 41 // false on failure. | |
|
Paweł Hajdan Jr.
2013/01/24 19:31:57
nit: "false on failure" is redundant, please remov
| |
| 40 bool Start() WARN_UNUSED_RESULT; | 42 bool Start() WARN_UNUSED_RESULT; |
| 41 | 43 |
| 44 // Start the test server without blocking. Use this if you need multiple test | |
| 45 // servers (such as WebSockets and HTTP, or HTTP and HTTPS). You must call | |
| 46 // BlockUntilStarted on all servers your test requires before executing the | |
| 47 // test. For example: | |
| 48 // | |
| 49 // // Start the servers in parallel. | |
| 50 // ASSERT_TRUE(http_server.StartInBackground()); | |
| 51 // ASSERT_TRUE(websocket_server.StartInBackground()); | |
| 52 // // Wait for both servers to be ready. | |
| 53 // ASSERT_TRUE(http_server.BlockUntilStarted()); | |
| 54 // ASSERT_TRUE(websocket_server.BlockUntilStarted()); | |
| 55 // RunMyTest(); | |
| 56 // | |
| 57 // Returns true on success, false on failure. | |
|
Paweł Hajdan Jr.
2013/01/24 19:31:57
nit: "false on failure" is redundant, please remov
| |
| 58 bool StartInBackground() WARN_UNUSED_RESULT; | |
| 59 | |
| 60 // Block until ths test server is ready. Returns true on success, false on | |
|
Paweł Hajdan Jr.
2013/01/24 19:31:57
nit: "false on failure" is redundant, please remov
| |
| 61 // failure. Block See StartInBackground() documentation for more information. | |
| 62 bool BlockUntilStarted() WARN_UNUSED_RESULT; | |
| 63 | |
| 42 // Stop the server started by Start(). | 64 // Stop the server started by Start(). |
| 43 bool Stop(); | 65 bool Stop(); |
| 44 | 66 |
| 45 // Modify PYTHONPATH to contain libraries we need. | 67 // Modify PYTHONPATH to contain libraries we need. |
| 46 virtual bool SetPythonPath() const WARN_UNUSED_RESULT; | 68 virtual bool SetPythonPath() const WARN_UNUSED_RESULT; |
| 47 | 69 |
| 48 // This is a static version so that RunSyncTest in run_testserver.cc can use | 70 // This is a static version so that RunSyncTest in run_testserver.cc can use |
| 49 // it. | 71 // it. |
| 50 // TODO(mattm): We should refactor so this isn't necessary (crbug.com/159731). | 72 // TODO(mattm): We should refactor so this isn't necessary (crbug.com/159731). |
| 51 static bool SetPythonPathStatic() WARN_UNUSED_RESULT; | 73 static bool SetPythonPathStatic() WARN_UNUSED_RESULT; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 int child_fd_; | 118 int child_fd_; |
| 97 file_util::ScopedFD child_fd_closer_; | 119 file_util::ScopedFD child_fd_closer_; |
| 98 #endif | 120 #endif |
| 99 | 121 |
| 100 DISALLOW_COPY_AND_ASSIGN(LocalTestServer); | 122 DISALLOW_COPY_AND_ASSIGN(LocalTestServer); |
| 101 }; | 123 }; |
| 102 | 124 |
| 103 } // namespace net | 125 } // namespace net |
| 104 | 126 |
| 105 #endif // NET_TEST_LOCAL_TEST_SERVER_H_ | 127 #endif // NET_TEST_LOCAL_TEST_SERVER_H_ |
| OLD | NEW |