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