| 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/cpp/completion_callback.h" | 10 #include "ppapi/cpp/completion_callback.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 virtual void HandleMessage(const pp::Var& message_data); | 80 virtual void HandleMessage(const pp::Var& message_data); |
| 81 | 81 |
| 82 const std::string& protocol() { | 82 const std::string& protocol() { |
| 83 return protocol_; | 83 return protocol_; |
| 84 } | 84 } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 void ExecuteTests(int32_t unused); | 87 void ExecuteTests(int32_t unused); |
| 88 | 88 |
| 89 // Creates a new TestCase for the give test name, or NULL if there is no such | 89 // Creates a new TestCase for the give test name, or NULL if there is no such |
| 90 // test. Ownership is passed to the caller. | 90 // test. Ownership is passed to the caller. The given string is split by '_'. |
| 91 TestCase* CaseForTestName(const char* name); | 91 // The test case name is the first part. |
| 92 TestCase* CaseForTestName(const std::string& name); |
| 93 // Returns the filter (second part) of the given string. If there is no '_', |
| 94 // returns the empty string, which means 'run all tests for this test case'. |
| 95 // E.g.: |
| 96 // http://testserver/test_case.html?testcase=PostMessage |
| 97 // Otherwise, the part of the testcase after '_' is returned, and the test |
| 98 // whose name matches that string (if any) will be run: |
| 99 // http://testserver/test_case.html?testcase=PostMessage_SendingData |
| 100 // Runs 'PostMessage_SendingData. |
| 101 std::string FilterForTestName(const std::string& name); |
| 92 | 102 |
| 93 // Appends a list of available tests to the console in the document. | 103 // Appends a list of available tests to the console in the document. |
| 94 void LogAvailableTests(); | 104 void LogAvailableTests(); |
| 95 | 105 |
| 96 // Appends the given error test to the console in the document. | 106 // Appends the given error test to the console in the document. |
| 97 void LogError(const std::string& text); | 107 void LogError(const std::string& text); |
| 98 | 108 |
| 99 // Appends the given HTML string to the console in the document. | 109 // Appends the given HTML string to the console in the document. |
| 100 void LogHTML(const std::string& html); | 110 void LogHTML(const std::string& html); |
| 101 | 111 |
| 102 void ReportProgress(const std::string& progress_value); | 112 void ReportProgress(const std::string& progress_value); |
| 103 | 113 |
| 104 // Sets the given cookie in the current document. | 114 // Sets the given cookie in the current document. |
| 105 void SetCookie(const std::string& name, const std::string& value); | 115 void SetCookie(const std::string& name, const std::string& value); |
| 106 | 116 |
| 107 pp::CompletionCallbackFactory<TestingInstance> callback_factory_; | 117 pp::CompletionCallbackFactory<TestingInstance> callback_factory_; |
| 108 | 118 |
| 109 // Owning pointer to the current test case. Valid after Init has been called. | 119 // Owning pointer to the current test case. Valid after Init has been called. |
| 110 TestCase* current_case_; | 120 TestCase* current_case_; |
| 111 | 121 |
| 122 // A filter to use when running tests. This is passed to 'RunTests', which |
| 123 // runs only tests whose name contains test_filter_ as a substring. |
| 124 std::string test_filter_; |
| 125 |
| 112 // The current step we're on starting at 0. This is incremented every time we | 126 // The current step we're on starting at 0. This is incremented every time we |
| 113 // report progress via a cookie. See comment above the class. | 127 // report progress via a cookie. See comment above the class. |
| 114 int progress_cookie_number_; | 128 int progress_cookie_number_; |
| 115 | 129 |
| 116 // Set once the tests are run so we know not to re-run when the view is sized. | 130 // Set once the tests are run so we know not to re-run when the view is sized. |
| 117 bool executed_tests_; | 131 bool executed_tests_; |
| 118 | 132 |
| 119 // Collects all errors to send the the browser. Empty indicates no error yet. | 133 // Collects all errors to send the the browser. Empty indicates no error yet. |
| 120 std::string errors_; | 134 std::string errors_; |
| 121 | 135 |
| 122 // True if running in Native Client. | 136 // True if running in Native Client. |
| 123 bool nacl_mode_; | 137 bool nacl_mode_; |
| 124 | 138 |
| 125 // String representing the protocol. Used for detecting whether we're running | 139 // String representing the protocol. Used for detecting whether we're running |
| 126 // with http. | 140 // with http. |
| 127 std::string protocol_; | 141 std::string protocol_; |
| 128 }; | 142 }; |
| 129 | 143 |
| 130 #endif // PPAPI_TESTS_TESTING_INSTANCE_H_ | 144 #endif // PPAPI_TESTS_TESTING_INSTANCE_H_ |
| OLD | NEW |