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