| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef PlatformUtilities_h | 26 #ifndef PlatformUtilities_h |
| 27 #define PlatformUtilities_h | 27 #define PlatformUtilities_h |
| 28 | 28 |
| 29 #include <WebKit2/WKRetainPtr.h> | 29 #include <WebKit2/WKRetainPtr.h> |
| 30 #include <string> | 30 #include <string> |
| 31 | 31 |
| 32 #if PLATFORM(MAC) | |
| 33 #if __OBJC__ | |
| 34 @class NSString; | |
| 35 #else | |
| 36 class NSString; | |
| 37 #endif | |
| 38 #endif | |
| 39 | |
| 40 namespace TestWebKitAPI { | 32 namespace TestWebKitAPI { |
| 41 namespace Util { | 33 namespace Util { |
| 42 | 34 |
| 43 // Runs a platform runloop until the 'done' is true. | 35 // Runs a platform runloop until the 'done' is true. |
| 44 void run(bool* done); | 36 void run(bool* done); |
| 45 | 37 |
| 46 #if PLATFORM(WIN) | |
| 47 bool shouldTranslateMessage(const MSG&); | |
| 48 #endif | |
| 49 | |
| 50 void sleep(double seconds); | 38 void sleep(double seconds); |
| 51 | 39 |
| 52 WKContextRef createContextWithInjectedBundle(); | 40 WKContextRef createContextWithInjectedBundle(); |
| 53 WKContextRef createContextForInjectedBundleTest(const std::string&, WKTypeRef us
erData = 0); | 41 WKContextRef createContextForInjectedBundleTest(const std::string&, WKTypeRef us
erData = 0); |
| 54 WKDictionaryRef createInitializationDictionaryForInjectedBundleTest(const std::s
tring&, WKTypeRef userData); | 42 WKDictionaryRef createInitializationDictionaryForInjectedBundleTest(const std::s
tring&, WKTypeRef userData); |
| 55 | 43 |
| 56 WKStringRef createInjectedBundlePath(); | 44 WKStringRef createInjectedBundlePath(); |
| 57 WKURLRef createURLForResource(const char* resource, const char* extension); | 45 WKURLRef createURLForResource(const char* resource, const char* extension); |
| 58 WKURLRef URLForNonExistentResource(); | 46 WKURLRef URLForNonExistentResource(); |
| 59 WKRetainPtr<WKStringRef> MIMETypeForWKURLResponse(WKURLResponseRef); | 47 WKRetainPtr<WKStringRef> MIMETypeForWKURLResponse(WKURLResponseRef); |
| 60 | 48 |
| 61 bool isKeyDown(WKNativeEventPtr); | 49 bool isKeyDown(WKNativeEventPtr); |
| 62 | 50 |
| 63 std::string toSTD(WKStringRef); | 51 std::string toSTD(WKStringRef); |
| 64 std::string toSTD(WKRetainPtr<WKStringRef>); | 52 std::string toSTD(WKRetainPtr<WKStringRef>); |
| 65 std::string toSTD(const char*); | 53 std::string toSTD(const char*); |
| 66 #if PLATFORM(MAC) | |
| 67 std::string toSTD(NSString *); | |
| 68 #endif | |
| 69 | 54 |
| 70 WKRetainPtr<WKStringRef> toWK(const char* utf8String); | 55 WKRetainPtr<WKStringRef> toWK(const char* utf8String); |
| 71 | 56 |
| 72 template<typename T, typename U> | 57 template<typename T, typename U> |
| 73 static inline ::testing::AssertionResult assertWKStringEqual(const char* expecte
d_expression, const char* actual_expression, T expected, U actual) | 58 static inline ::testing::AssertionResult assertWKStringEqual(const char* expecte
d_expression, const char* actual_expression, T expected, U actual) |
| 74 { | 59 { |
| 75 return ::testing::internal::CmpHelperSTREQ(expected_expression, actual_expre
ssion, Util::toSTD(expected).c_str(), Util::toSTD(actual).c_str()); | 60 return ::testing::internal::CmpHelperSTREQ(expected_expression, actual_expre
ssion, Util::toSTD(expected).c_str(), Util::toSTD(actual).c_str()); |
| 76 } | 61 } |
| 77 | 62 |
| 78 #define EXPECT_WK_STREQ(expected, actual) \ | 63 #define EXPECT_WK_STREQ(expected, actual) \ |
| 79 EXPECT_PRED_FORMAT2(TestWebKitAPI::Util::assertWKStringEqual, expected, actu
al) | 64 EXPECT_PRED_FORMAT2(TestWebKitAPI::Util::assertWKStringEqual, expected, actu
al) |
| 80 | 65 |
| 81 } // namespace Util | 66 } // namespace Util |
| 82 } // namespace TestWebKitAPI | 67 } // namespace TestWebKitAPI |
| 83 | 68 |
| 84 #endif // PlatformUtilities_h | 69 #endif // PlatformUtilities_h |
| OLD | NEW |