OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 12 matching lines...) Expand all Loading... |
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "platform/testing/UnitTestHelpers.h" | 26 #include "platform/testing/UnitTestHelpers.h" |
27 | 27 |
28 #include "base/files/file_path.h" | 28 #include "base/files/file_path.h" |
29 #include "base/files/file_util.h" | 29 #include "base/files/file_util.h" |
30 #include "base/message_loop/message_loop.h" | 30 #include "base/message_loop/message_loop.h" |
31 #include "base/path_service.h" | 31 #include "base/path_service.h" |
32 #include "platform/SharedBuffer.h" | 32 #include "platform/SharedBuffer.h" |
| 33 #include "public/platform/FilePathConversion.h" |
33 #include "public/platform/Platform.h" | 34 #include "public/platform/Platform.h" |
| 35 #include "public/platform/WebString.h" |
34 #include "public/platform/WebTaskRunner.h" | 36 #include "public/platform/WebTaskRunner.h" |
35 #include "public/platform/WebThread.h" | 37 #include "public/platform/WebThread.h" |
36 #include "public/platform/WebTraceLocation.h" | 38 #include "public/platform/WebTraceLocation.h" |
37 #include "public/platform/WebUnitTestSupport.h" | 39 #include "public/platform/WebUnitTestSupport.h" |
38 #include "wtf/text/StringUTF8Adaptor.h" | 40 #include "wtf/text/StringUTF8Adaptor.h" |
39 | 41 |
40 namespace blink { | 42 namespace blink { |
41 namespace testing { | 43 namespace testing { |
42 | 44 |
43 void runPendingTasks() | 45 void runPendingTasks() |
44 { | 46 { |
45 Platform::current()->currentThread()->taskRunner()->postTask(BLINK_FROM_HERE
, bind(&exitRunLoop)); | 47 Platform::current()->currentThread()->taskRunner()->postTask(BLINK_FROM_HERE
, bind(&exitRunLoop)); |
46 enterRunLoop(); | 48 enterRunLoop(); |
47 } | 49 } |
48 | 50 |
49 String blinkRootDir() | 51 String blinkRootDir() |
50 { | 52 { |
51 base::FilePath path; | 53 base::FilePath path; |
52 base::PathService::Get(base::DIR_SOURCE_ROOT, &path); | 54 base::PathService::Get(base::DIR_SOURCE_ROOT, &path); |
53 path = path.Append(FILE_PATH_LITERAL("third_party/WebKit")); | 55 path = path.Append(FILE_PATH_LITERAL("third_party/WebKit")); |
54 path = base::MakeAbsoluteFilePath(path); | 56 path = base::MakeAbsoluteFilePath(path); |
55 return String::fromUTF8(path.MaybeAsASCII().c_str()); | 57 return String::fromUTF8(path.MaybeAsASCII().c_str()); |
56 } | 58 } |
57 | 59 |
58 PassRefPtr<SharedBuffer> readFromFile(const String& path) | 60 PassRefPtr<SharedBuffer> readFromFile(const String& path) |
59 { | 61 { |
60 StringUTF8Adaptor utf8(path); | 62 base::FilePath filePath = blink::WebStringToFilePath(path); |
61 base::FilePath filePath = base::FilePath::FromUTF8Unsafe( | |
62 std::string(utf8.data(), utf8.length())); | |
63 std::string buffer; | 63 std::string buffer; |
64 base::ReadFileToString(filePath, &buffer); | 64 base::ReadFileToString(filePath, &buffer); |
65 return SharedBuffer::create(buffer.data(), buffer.size()); | 65 return SharedBuffer::create(buffer.data(), buffer.size()); |
66 } | 66 } |
67 | 67 |
68 void enterRunLoop() | 68 void enterRunLoop() |
69 { | 69 { |
70 base::MessageLoop::current()->Run(); | 70 base::MessageLoop::current()->Run(); |
71 } | 71 } |
72 | 72 |
73 void exitRunLoop() | 73 void exitRunLoop() |
74 { | 74 { |
75 base::MessageLoop::current()->QuitWhenIdle(); | 75 base::MessageLoop::current()->QuitWhenIdle(); |
76 } | 76 } |
77 | 77 |
78 void yieldCurrentThread() | 78 void yieldCurrentThread() |
79 { | 79 { |
80 base::PlatformThread::YieldCurrentThread(); | 80 base::PlatformThread::YieldCurrentThread(); |
81 } | 81 } |
82 | 82 |
83 } // namespace testing | 83 } // namespace testing |
84 } // namespace blink | 84 } // namespace blink |
OLD | NEW |