Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 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_TEST_TESTING_INSTANCE_H_ | 5 #ifndef PPAPI_TESTS_TESTING_INSTANCE_H_ |
| 6 #define PPAPI_TEST_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" |
| 11 #include "ppapi/cpp/instance.h" | 11 #include "ppapi/cpp/instance.h" |
| 12 | 12 |
| 13 class TestCase; | 13 class TestCase; |
| 14 | 14 |
| 15 class TestingInstance : public pp::Instance { | 15 class TestingInstance : public pp::Instance { |
| 16 public: | 16 public: |
| 17 TestingInstance(PP_Instance instance); | 17 explicit TestingInstance(PP_Instance instance); |
| 18 | 18 |
| 19 // pp::Instance override. | 19 // pp::Instance override. |
| 20 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); | 20 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); |
| 21 virtual void DidChangeView(const pp::Rect& position, const pp::Rect& clip); | 21 virtual void DidChangeView(const pp::Rect& position, const pp::Rect& clip); |
| 22 virtual pp::Var GetInstanceObject(); | 22 virtual pp::Var GetInstanceObject(); |
| 23 | 23 |
| 24 // Outputs the information from one test run, using the format | 24 // Outputs the information from one test run, using the format |
| 25 // <test_name> [PASS|FAIL <error_message>] | 25 // <test_name> [PASS|FAIL <error_message>] |
| 26 // If error_message is empty, we say the test passed and emit PASS. If | 26 // If error_message is empty, we say the test passed and emit PASS. If |
| 27 // error_message is nonempty, the test failed with that message as the error | 27 // error_message is nonempty, the test failed with that message as the error |
| 28 // string. | 28 // string. |
| 29 // | 29 // |
| 30 // Intended usage: | 30 // Intended usage: |
| 31 // LogTest("Foo", FooTest()); | 31 // LogTest("Foo", FooTest()); |
| 32 // | 32 // |
| 33 // Where FooTest is defined as: | 33 // Where FooTest is defined as: |
| 34 // std::string FooTest() { | 34 // std::string FooTest() { |
| 35 // if (something_horrible_happened) | 35 // if (something_horrible_happened) |
| 36 // return "Something horrible happened"; | 36 // return "Something horrible happened"; |
| 37 // return ""; | 37 // return ""; |
| 38 // } | 38 // } |
| 39 void LogTest(const std::string& test_name, const std::string& error_message); | 39 void LogTest(const std::string& test_name, const std::string& error_message); |
| 40 | 40 |
| 41 // Appends an error message to the log. | 41 // Appends an error message to the log. |
| 42 void AppendError(const std::string& message); | 42 void AppendError(const std::string& message); |
| 43 | 43 |
| 44 // Passes the message_data through to the HandleMessage method on the | |
| 45 // TestClass object that's associated with this instance. | |
| 46 virtual void HandleMessage(const pp::Var& message_data); | |
| 47 | |
| 48 bool nacl_mode() { return nacl_mode_; } | |
|
brettw
2011/03/16 21:34:11
This should be const.
dmichael(do not use this one)
2011/03/21 21:43:35
Nice catch. Turns out I didn't end up using it, s
| |
| 49 | |
| 44 private: | 50 private: |
| 45 void ExecuteTests(int32_t unused); | 51 void ExecuteTests(int32_t unused); |
| 46 | 52 |
| 47 // Creates a new TestCase for the give test name, or NULL if there is no such | 53 // Creates a new TestCase for the give test name, or NULL if there is no such |
| 48 // test. Ownership is passed to the caller. | 54 // test. Ownership is passed to the caller. |
| 49 TestCase* CaseForTestName(const char* name); | 55 TestCase* CaseForTestName(const char* name); |
| 50 | 56 |
| 51 // Appends a list of available tests to the console in the document. | 57 // Appends a list of available tests to the console in the document. |
| 52 void LogAvailableTests(); | 58 void LogAvailableTests(); |
| 53 | 59 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 68 // Set once the tests are run so we know not to re-run when the view is sized. | 74 // Set once the tests are run so we know not to re-run when the view is sized. |
| 69 bool executed_tests_; | 75 bool executed_tests_; |
| 70 | 76 |
| 71 // Collects all errors to send the the browser. Empty indicates no error yet. | 77 // Collects all errors to send the the browser. Empty indicates no error yet. |
| 72 std::string errors_; | 78 std::string errors_; |
| 73 | 79 |
| 74 // True if running in Native Client. | 80 // True if running in Native Client. |
| 75 bool nacl_mode_; | 81 bool nacl_mode_; |
| 76 }; | 82 }; |
| 77 | 83 |
| 78 #endif // PPAPI_TEST_TESTING_INSTANCE_H_ | 84 #endif // PPAPI_TESTS_TESTING_INSTANCE_H_ |
| 85 | |
| OLD | NEW |