| 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 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); | 55 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); |
| 56 virtual void DidChangeView(const pp::View& view); | 56 virtual void DidChangeView(const pp::View& view); |
| 57 virtual bool HandleInputEvent(const pp::InputEvent& event); | 57 virtual bool HandleInputEvent(const pp::InputEvent& event); |
| 58 | 58 |
| 59 #if !(defined __native_client__) | 59 #if !(defined __native_client__) |
| 60 virtual pp::Var GetInstanceObject(); | 60 virtual pp::Var GetInstanceObject(); |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 // Outputs the information from one test run, using the format | 63 // Outputs the information from one test run, using the format |
| 64 // <test_name> [PASS|FAIL <error_message>] | 64 // <test_name> [PASS|FAIL <error_message>] |
| 65 // |
| 66 // You should generally use one of the RUN_TEST* macros in test_case.h |
| 67 // instead. |
| 68 // |
| 65 // If error_message is empty, we say the test passed and emit PASS. If | 69 // If error_message is empty, we say the test passed and emit PASS. If |
| 66 // error_message is nonempty, the test failed with that message as the error | 70 // error_message is nonempty, the test failed with that message as the error |
| 67 // string. | 71 // string. |
| 68 // | 72 // |
| 69 // Intended usage: | 73 // Intended usage: |
| 70 // LogTest("Foo", FooTest()); | 74 // PP_TimeTicks start_time(core.GetTimeTicks()); |
| 75 // LogTest("Foo", FooTest(), start_time); |
| 71 // | 76 // |
| 72 // Where FooTest is defined as: | 77 // Where FooTest is defined as: |
| 73 // std::string FooTest() { | 78 // std::string FooTest() { |
| 74 // if (something_horrible_happened) | 79 // if (something_horrible_happened) |
| 75 // return "Something horrible happened"; | 80 // return "Something horrible happened"; |
| 76 // return ""; | 81 // return ""; |
| 77 // } | 82 // } |
| 78 void LogTest(const std::string& test_name, const std::string& error_message); | 83 // |
| 84 // NOTE: It's important to get the start time in the previous line, rather |
| 85 // than calling GetTimeTicks in the LogTestLine. There's no guarantee |
| 86 // that GetTimeTicks will be evaluated before FooTest(). |
| 87 void LogTest(const std::string& test_name, |
| 88 const std::string& error_message, |
| 89 PP_TimeTicks start_time); |
| 79 | 90 |
| 80 // Appends an error message to the log. | 91 // Appends an error message to the log. |
| 81 void AppendError(const std::string& message); | 92 void AppendError(const std::string& message); |
| 82 | 93 |
| 83 // Passes the message_data through to the HandleMessage method on the | 94 // Passes the message_data through to the HandleMessage method on the |
| 84 // TestClass object that's associated with this instance. | 95 // TestClass object that's associated with this instance. |
| 85 virtual void HandleMessage(const pp::Var& message_data); | 96 virtual void HandleMessage(const pp::Var& message_data); |
| 86 | 97 |
| 87 const std::string& protocol() { | 98 const std::string& protocol() { |
| 88 return protocol_; | 99 return protocol_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 108 // See doc for |remove_plugin_|. | 119 // See doc for |remove_plugin_|. |
| 109 void set_remove_plugin(bool remove) { remove_plugin_ = remove; } | 120 void set_remove_plugin(bool remove) { remove_plugin_ = remove; } |
| 110 | 121 |
| 111 private: | 122 private: |
| 112 void ExecuteTests(int32_t unused); | 123 void ExecuteTests(int32_t unused); |
| 113 | 124 |
| 114 // Creates a new TestCase for the give test name, or NULL if there is no such | 125 // Creates a new TestCase for the give test name, or NULL if there is no such |
| 115 // test. Ownership is passed to the caller. The given string is split by '_'. | 126 // test. Ownership is passed to the caller. The given string is split by '_'. |
| 116 // The test case name is the first part. | 127 // The test case name is the first part. |
| 117 TestCase* CaseForTestName(const std::string& name); | 128 TestCase* CaseForTestName(const std::string& name); |
| 118 // Returns the filter (second part) of the given string. If there is no '_', | |
| 119 // returns the empty string, which means 'run all tests for this test case'. | |
| 120 // E.g.: | |
| 121 // http://testserver/test_case.html?testcase=PostMessage | |
| 122 // Otherwise, the part of the testcase after '_' is returned, and the test | |
| 123 // whose name matches that string (if any) will be run: | |
| 124 // http://testserver/test_case.html?testcase=PostMessage_SendingData | |
| 125 // Runs 'PostMessage_SendingData. | |
| 126 std::string FilterForTestName(const std::string& name); | |
| 127 | 129 |
| 128 // Sends a test command to the page using PostMessage. | 130 // Sends a test command to the page using PostMessage. |
| 129 void SendTestCommand(const std::string& command); | 131 void SendTestCommand(const std::string& command); |
| 130 void SendTestCommand(const std::string& command, const std::string& params); | 132 void SendTestCommand(const std::string& command, const std::string& params); |
| 131 | 133 |
| 132 // Appends a list of available tests to the console in the document. | 134 // Appends a list of available tests to the console in the document. |
| 133 void LogAvailableTests(); | 135 void LogAvailableTests(); |
| 134 | 136 |
| 135 // Appends the given error test to the console in the document. | 137 // Appends the given error test to the console in the document. |
| 136 void LogError(const std::string& text); | 138 void LogError(const std::string& text); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // WebSocket port. | 171 // WebSocket port. |
| 170 int websocket_port_; | 172 int websocket_port_; |
| 171 | 173 |
| 172 // At the end of each set of tests, the plugin is removed from the web-page. | 174 // At the end of each set of tests, the plugin is removed from the web-page. |
| 173 // However, for some tests, it is desirable to not remove the plguin from the | 175 // However, for some tests, it is desirable to not remove the plguin from the |
| 174 // page. | 176 // page. |
| 175 bool remove_plugin_; | 177 bool remove_plugin_; |
| 176 }; | 178 }; |
| 177 | 179 |
| 178 #endif // PPAPI_TESTS_TESTING_INSTANCE_H_ | 180 #endif // PPAPI_TESTS_TESTING_INSTANCE_H_ |
| OLD | NEW |