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/message_loop.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 namespace pp { |
| 18 class NetAddress_Dev; |
| 19 } |
| 20 |
17 // Timeout to wait for some action to complete. | 21 // Timeout to wait for some action to complete. |
18 extern const int kActionTimeoutMs; | 22 extern const int kActionTimeoutMs; |
19 | 23 |
20 const PPB_Testing_Dev* GetTestingInterface(); | 24 const PPB_Testing_Dev* GetTestingInterface(); |
21 std::string ReportError(const char* method, int32_t error); | 25 std::string ReportError(const char* method, int32_t error); |
22 void PlatformSleep(int duration_ms); | 26 void PlatformSleep(int duration_ms); |
23 bool GetLocalHostPort(PP_Instance instance, std::string* host, uint16_t* port); | 27 bool GetLocalHostPort(PP_Instance instance, std::string* host, uint16_t* port); |
24 | 28 |
25 uint16_t ConvertFromNetEndian16(uint16_t x); | 29 uint16_t ConvertFromNetEndian16(uint16_t x); |
26 uint16_t ConvertToNetEndian16(uint16_t x); | 30 uint16_t ConvertToNetEndian16(uint16_t x); |
| 31 bool EqualNetAddress(const pp::NetAddress_Dev& addr1, |
| 32 const pp::NetAddress_Dev& addr2); |
| 33 // Only returns the first address if there are more than one available. |
| 34 bool ResolveHost(PP_Instance instance, |
| 35 const std::string& host, |
| 36 uint16_t port, |
| 37 pp::NetAddress_Dev* addr); |
27 | 38 |
28 // NestedEvent allows you to run a nested MessageLoop and wait for a particular | 39 // NestedEvent allows you to run a nested MessageLoop and wait for a particular |
29 // event to complete. For example, you can use it to wait for a callback on a | 40 // event to complete. For example, you can use it to wait for a callback on a |
30 // PPP interface, which will "Signal" the event and make the loop quit. | 41 // PPP interface, which will "Signal" the event and make the loop quit. |
31 // "Wait()" will return immediately if it has already been signalled. Otherwise, | 42 // "Wait()" will return immediately if it has already been signalled. Otherwise, |
32 // it will run a nested message loop (using PPB_Testing.RunMessageLoop) and will | 43 // it will run a nested message loop (using PPB_Testing.RunMessageLoop) and will |
33 // return only after it has been signalled. | 44 // return only after it has been signalled. |
34 // Example: | 45 // Example: |
35 // std::string TestFullscreen::TestNormalToFullscreen() { | 46 // std::string TestFullscreen::TestNormalToFullscreen() { |
36 // pp::Fullscreen screen_mode(instance); | 47 // pp::Fullscreen screen_mode(instance); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 #error Please add support for your platform in ppapi/tests/test_utils.h | 323 #error Please add support for your platform in ppapi/tests/test_utils.h |
313 #endif | 324 #endif |
314 | 325 |
315 /* These are used to determine POSIX-like implementations vs Windows. */ | 326 /* These are used to determine POSIX-like implementations vs Windows. */ |
316 #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ | 327 #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ |
317 defined(__OpenBSD__) || defined(__sun) || defined(__native_client__) | 328 defined(__OpenBSD__) || defined(__sun) || defined(__native_client__) |
318 #define PPAPI_POSIX 1 | 329 #define PPAPI_POSIX 1 |
319 #endif | 330 #endif |
320 | 331 |
321 #endif // PPAPI_TESTS_TEST_UTILS_H_ | 332 #endif // PPAPI_TESTS_TEST_UTILS_H_ |
OLD | NEW |