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_TEST_UTILS_H_ | 5 #ifndef PPAPI_TESTS_TEST_UTILS_H_ |
6 #define PPAPI_TESTS_TEST_UTILS_H_ | 6 #define PPAPI_TESTS_TEST_UTILS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ppapi/c/dev/ppb_testing_dev.h" | 10 #include "ppapi/c/dev/ppb_testing_dev.h" |
11 #include "ppapi/c/pp_instance.h" | 11 #include "ppapi/c/pp_instance.h" |
12 #include "ppapi/c/pp_stdint.h" | 12 #include "ppapi/c/pp_stdint.h" |
13 #include "ppapi/cpp/completion_callback.h" | 13 #include "ppapi/cpp/completion_callback.h" |
14 #include "ppapi/cpp/dev/message_loop_dev.h" | 14 #include "ppapi/cpp/message_loop.h" |
15 #include "ppapi/utility/completion_callback_factory.h" | 15 #include "ppapi/utility/completion_callback_factory.h" |
16 | 16 |
17 // Timeout to wait for some action to complete. | 17 // Timeout to wait for some action to complete. |
18 extern const int kActionTimeoutMs; | 18 extern const int kActionTimeoutMs; |
19 | 19 |
20 const PPB_Testing_Dev* GetTestingInterface(); | 20 const PPB_Testing_Dev* GetTestingInterface(); |
21 std::string ReportError(const char* method, int32_t error); | 21 std::string ReportError(const char* method, int32_t error); |
22 void PlatformSleep(int duration_ms); | 22 void PlatformSleep(int duration_ms); |
23 bool GetLocalHostPort(PP_Instance instance, std::string* host, uint16_t* port); | 23 bool GetLocalHostPort(PP_Instance instance, std::string* host, uint16_t* port); |
24 | 24 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // Indicates whether we have already been invoked. | 162 // Indicates whether we have already been invoked. |
163 bool have_result_; | 163 bool have_result_; |
164 // The last result received (or PP_OK_COMPLETIONCALLBACK if none). | 164 // The last result received (or PP_OK_COMPLETIONCALLBACK if none). |
165 int32_t result_; | 165 int32_t result_; |
166 CallbackType callback_type_; | 166 CallbackType callback_type_; |
167 bool post_quit_task_; | 167 bool post_quit_task_; |
168 std::string errors_; | 168 std::string errors_; |
169 unsigned run_count_; | 169 unsigned run_count_; |
170 PP_Instance instance_; | 170 PP_Instance instance_; |
171 Delegate* delegate_; | 171 Delegate* delegate_; |
172 pp::MessageLoop_Dev target_loop_; | 172 pp::MessageLoop target_loop_; |
173 }; | 173 }; |
174 | 174 |
175 // Verifies that the callback didn't record any errors. If the callback is run | 175 // Verifies that the callback didn't record any errors. If the callback is run |
176 // in an unexpected way (e.g., if it's invoked asynchronously when the call | 176 // in an unexpected way (e.g., if it's invoked asynchronously when the call |
177 // should have blocked), this returns an appropriate error string. | 177 // should have blocked), this returns an appropriate error string. |
178 #define CHECK_CALLBACK_BEHAVIOR(callback) \ | 178 #define CHECK_CALLBACK_BEHAVIOR(callback) \ |
179 do { \ | 179 do { \ |
180 if ((callback).failed()) \ | 180 if ((callback).failed()) \ |
181 return (callback).errors(); \ | 181 return (callback).errors(); \ |
182 } while (false) | 182 } while (false) |
(...skipping 22 matching lines...) Expand all Loading... |
205 #error Please add support for your platform in ppapi/tests/test_utils.h | 205 #error Please add support for your platform in ppapi/tests/test_utils.h |
206 #endif | 206 #endif |
207 | 207 |
208 /* These are used to determine POSIX-like implementations vs Windows. */ | 208 /* These are used to determine POSIX-like implementations vs Windows. */ |
209 #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ | 209 #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ |
210 defined(__OpenBSD__) || defined(__sun) || defined(__native_client__) | 210 defined(__OpenBSD__) || defined(__sun) || defined(__native_client__) |
211 #define PPAPI_POSIX 1 | 211 #define PPAPI_POSIX 1 |
212 #endif | 212 #endif |
213 | 213 |
214 #endif // PPAPI_TESTS_TEST_UTILS_H_ | 214 #endif // PPAPI_TESTS_TEST_UTILS_H_ |
OLD | NEW |