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 class QuitTask : public WebTaskRunner::Task { | 45 class QuitTask : public WebTaskRunner::Task { |
(...skipping 14 matching lines...) Expand all Loading... |
58 { | 60 { |
59 base::FilePath path; | 61 base::FilePath path; |
60 base::PathService::Get(base::DIR_SOURCE_ROOT, &path); | 62 base::PathService::Get(base::DIR_SOURCE_ROOT, &path); |
61 path = path.Append(FILE_PATH_LITERAL("third_party/WebKit")); | 63 path = path.Append(FILE_PATH_LITERAL("third_party/WebKit")); |
62 path = base::MakeAbsoluteFilePath(path); | 64 path = base::MakeAbsoluteFilePath(path); |
63 return String::fromUTF8(path.MaybeAsASCII().c_str()); | 65 return String::fromUTF8(path.MaybeAsASCII().c_str()); |
64 } | 66 } |
65 | 67 |
66 PassRefPtr<SharedBuffer> readFromFile(const String& path) | 68 PassRefPtr<SharedBuffer> readFromFile(const String& path) |
67 { | 69 { |
68 StringUTF8Adaptor utf8(path); | 70 base::FilePath filePath = blink::WebStringToFilePath(path); |
69 base::FilePath file_path = base::FilePath::FromUTF8Unsafe( | |
70 std::string(utf8.data(), utf8.length())); | |
71 std::string buffer; | 71 std::string buffer; |
72 base::ReadFileToString(file_path, &buffer); | 72 base::ReadFileToString(filePath, &buffer); |
73 return SharedBuffer::create(buffer.data(), buffer.size()); | 73 return SharedBuffer::create(buffer.data(), buffer.size()); |
74 } | 74 } |
75 | 75 |
76 void enterRunLoop() | 76 void enterRunLoop() |
77 { | 77 { |
78 base::MessageLoop::current()->Run(); | 78 base::MessageLoop::current()->Run(); |
79 } | 79 } |
80 | 80 |
81 void exitRunLoop() | 81 void exitRunLoop() |
82 { | 82 { |
83 base::MessageLoop::current()->QuitWhenIdle(); | 83 base::MessageLoop::current()->QuitWhenIdle(); |
84 } | 84 } |
85 | 85 |
86 void yieldCurrentThread() | 86 void yieldCurrentThread() |
87 { | 87 { |
88 base::PlatformThread::YieldCurrentThread(); | 88 base::PlatformThread::YieldCurrentThread(); |
89 } | 89 } |
90 | 90 |
91 } // namespace testing | 91 } // namespace testing |
92 } // namespace blink | 92 } // namespace blink |
OLD | NEW |