| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 PPAPI_TESTS_TESTING_INSTANCE_H_ | 5 #ifndef PPAPI_TESTS_TESTING_INSTANCE_H_ |
| 6 #define PPAPI_TESTS_TESTING_INSTANCE_H_ | 6 #define PPAPI_TESTS_TESTING_INSTANCE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ppapi/utility/completion_callback_factory.h" | 10 #include "ppapi/utility/completion_callback_factory.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 int websocket_port() { return websocket_port_; } | 85 int websocket_port() { return websocket_port_; } |
| 86 | 86 |
| 87 // Posts a message to the test page to eval() the script. | 87 // Posts a message to the test page to eval() the script. |
| 88 void EvalScript(const std::string& script); | 88 void EvalScript(const std::string& script); |
| 89 | 89 |
| 90 // Sets the given cookie in the current document. | 90 // Sets the given cookie in the current document. |
| 91 void SetCookie(const std::string& name, const std::string& value); | 91 void SetCookie(const std::string& name, const std::string& value); |
| 92 | 92 |
| 93 void ReportProgress(const std::string& progress_value); | 93 void ReportProgress(const std::string& progress_value); |
| 94 | 94 |
| 95 // Add a post-condition to the JavaScript on the test_case.html page. This |
| 96 // JavaScript code will be run after the instance is shut down and must |
| 97 // evaluate to |true| or the test will fail. |
| 98 void AddPostCondition(const std::string& script); |
| 99 |
| 95 private: | 100 private: |
| 96 void ExecuteTests(int32_t unused); | 101 void ExecuteTests(int32_t unused); |
| 97 | 102 |
| 98 // Creates a new TestCase for the give test name, or NULL if there is no such | 103 // Creates a new TestCase for the give test name, or NULL if there is no such |
| 99 // test. Ownership is passed to the caller. The given string is split by '_'. | 104 // test. Ownership is passed to the caller. The given string is split by '_'. |
| 100 // The test case name is the first part. | 105 // The test case name is the first part. |
| 101 TestCase* CaseForTestName(const std::string& name); | 106 TestCase* CaseForTestName(const std::string& name); |
| 102 // Returns the filter (second part) of the given string. If there is no '_', | 107 // Returns the filter (second part) of the given string. If there is no '_', |
| 103 // returns the empty string, which means 'run all tests for this test case'. | 108 // returns the empty string, which means 'run all tests for this test case'. |
| 104 // E.g.: | 109 // E.g.: |
| 105 // http://testserver/test_case.html?testcase=PostMessage | 110 // http://testserver/test_case.html?testcase=PostMessage |
| 106 // Otherwise, the part of the testcase after '_' is returned, and the test | 111 // Otherwise, the part of the testcase after '_' is returned, and the test |
| 107 // whose name matches that string (if any) will be run: | 112 // whose name matches that string (if any) will be run: |
| 108 // http://testserver/test_case.html?testcase=PostMessage_SendingData | 113 // http://testserver/test_case.html?testcase=PostMessage_SendingData |
| 109 // Runs 'PostMessage_SendingData. | 114 // Runs 'PostMessage_SendingData. |
| 110 std::string FilterForTestName(const std::string& name); | 115 std::string FilterForTestName(const std::string& name); |
| 111 | 116 |
| 117 // Sends a test command to the page using PostMessage. |
| 118 void SendTestCommand(const std::string& command); |
| 119 void SendTestCommand(const std::string& command, const std::string& params); |
| 120 |
| 112 // Appends a list of available tests to the console in the document. | 121 // Appends a list of available tests to the console in the document. |
| 113 void LogAvailableTests(); | 122 void LogAvailableTests(); |
| 114 | 123 |
| 115 // Appends the given error test to the console in the document. | 124 // Appends the given error test to the console in the document. |
| 116 void LogError(const std::string& text); | 125 void LogError(const std::string& text); |
| 117 | 126 |
| 118 // Appends the given HTML string to the console in the document. | 127 // Appends the given HTML string to the console in the document. |
| 119 void LogHTML(const std::string& html); | 128 void LogHTML(const std::string& html); |
| 120 | 129 |
| 121 pp::CompletionCallbackFactory<TestingInstance> callback_factory_; | 130 pp::CompletionCallbackFactory<TestingInstance> callback_factory_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 138 | 147 |
| 139 // String representing the protocol. Used for detecting whether we're running | 148 // String representing the protocol. Used for detecting whether we're running |
| 140 // with http. | 149 // with http. |
| 141 std::string protocol_; | 150 std::string protocol_; |
| 142 | 151 |
| 143 // WebSocket port. | 152 // WebSocket port. |
| 144 int websocket_port_; | 153 int websocket_port_; |
| 145 }; | 154 }; |
| 146 | 155 |
| 147 #endif // PPAPI_TESTS_TESTING_INSTANCE_H_ | 156 #endif // PPAPI_TESTS_TESTING_INSTANCE_H_ |
| OLD | NEW |