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