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" |
11 | 11 |
12 #if defined(__native_client__) | 12 #if defined(__native_client__) |
13 #include "ppapi/cpp/instance.h" | 13 #include "ppapi/cpp/instance.h" |
14 #else | 14 #else |
15 #include "ppapi/cpp/private/instance_private.h" | 15 #include "ppapi/cpp/private/instance_private.h" |
16 #endif | 16 #endif |
17 | 17 |
18 class TestCase; | 18 class TestCase; |
19 | 19 |
| 20 // How signaling works: |
| 21 // |
| 22 // We want to signal to the Chrome UI test harness |
| 23 // (chrome/test/ui/ppapi_uitest.cc) that we're making progress and when we're |
| 24 // done. The easiest thing in the UI test infrastructure is to wait for a |
| 25 // cookie to become nonempty. We don't want to have a big wait for all tests in |
| 26 // a TestCase since they can take a while and it might timeout. So we set a |
| 27 // series of cookies with an incrementing number in the name. |
| 28 // |
| 29 // If the value of the cookie is "..." then that tells the test runner that |
| 30 // the test is progressing. It then waits for the next numbered cookie until |
| 31 // it either times out or the value is something other than "...". In this |
| 32 // case, the value will be either "PASS" or "FAIL [optional message]" |
| 33 // corresponding to the outcome of the entire test case. Timeout will be |
| 34 // treated just like a failure of the entire test case and the test will be |
| 35 // terminated. |
| 36 // |
20 // In trusted builds, we use InstancePrivate and allow tests that use | 37 // In trusted builds, we use InstancePrivate and allow tests that use |
21 // synchronous scripting. NaCl does not support synchronous scripting. | 38 // synchronous scripting. NaCl does not support synchronous scripting. |
22 class TestingInstance : public | 39 class TestingInstance : public |
23 #if defined(__native_client__) | 40 #if defined(__native_client__) |
24 pp::Instance { | 41 pp::Instance { |
25 #else | 42 #else |
26 pp::InstancePrivate { | 43 pp::InstancePrivate { |
27 #endif | 44 #endif |
28 public: | 45 public: |
29 explicit TestingInstance(PP_Instance instance); | 46 explicit TestingInstance(PP_Instance instance); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 91 |
75 // Appends a list of available tests to the console in the document. | 92 // Appends a list of available tests to the console in the document. |
76 void LogAvailableTests(); | 93 void LogAvailableTests(); |
77 | 94 |
78 // Appends the given error test to the console in the document. | 95 // Appends the given error test to the console in the document. |
79 void LogError(const std::string& text); | 96 void LogError(const std::string& text); |
80 | 97 |
81 // Appends the given HTML string to the console in the document. | 98 // Appends the given HTML string to the console in the document. |
82 void LogHTML(const std::string& html); | 99 void LogHTML(const std::string& html); |
83 | 100 |
| 101 void ReportProgress(const std::string& progress_value); |
| 102 |
84 // Sets the given cookie in the current document. | 103 // Sets the given cookie in the current document. |
85 void SetCookie(const std::string& name, const std::string& value); | 104 void SetCookie(const std::string& name, const std::string& value); |
86 | 105 |
87 pp::CompletionCallbackFactory<TestingInstance> callback_factory_; | 106 pp::CompletionCallbackFactory<TestingInstance> callback_factory_; |
88 | 107 |
89 // Owning pointer to the current test case. Valid after Init has been called. | 108 // Owning pointer to the current test case. Valid after Init has been called. |
90 TestCase* current_case_; | 109 TestCase* current_case_; |
91 | 110 |
| 111 // The current step we're on starting at 0. This is incremented every time we |
| 112 // report progress via a cookie. See comment above the class. |
| 113 int progress_cookie_number_; |
| 114 |
92 // Set once the tests are run so we know not to re-run when the view is sized. | 115 // Set once the tests are run so we know not to re-run when the view is sized. |
93 bool executed_tests_; | 116 bool executed_tests_; |
94 | 117 |
95 // Collects all errors to send the the browser. Empty indicates no error yet. | 118 // Collects all errors to send the the browser. Empty indicates no error yet. |
96 std::string errors_; | 119 std::string errors_; |
97 | 120 |
98 // True if running in Native Client. | 121 // True if running in Native Client. |
99 bool nacl_mode_; | 122 bool nacl_mode_; |
100 | 123 |
101 // String representing the protocol. Used for detecting whether we're running | 124 // String representing the protocol. Used for detecting whether we're running |
102 // with http. | 125 // with http. |
103 std::string protocol_; | 126 std::string protocol_; |
104 }; | 127 }; |
105 | 128 |
106 #endif // PPAPI_TESTS_TESTING_INSTANCE_H_ | 129 #endif // PPAPI_TESTS_TESTING_INSTANCE_H_ |
107 | 130 |
OLD | NEW |