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 #include "webkit/support/test_webkit_platform_support.h" | 5 #include "webkit/support/test_webkit_platform_support.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/memory/scoped_handle.h" |
10 #include "base/metrics/stats_counters.h" | 11 #include "base/metrics/stats_counters.h" |
11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
14 #include "cc/thread_impl.h" | 15 #include "cc/thread_impl.h" |
15 #include "media/base/media.h" | 16 #include "media/base/media.h" |
16 #include "net/cookies/cookie_monster.h" | 17 #include "net/cookies/cookie_monster.h" |
17 #include "net/http/http_cache.h" | 18 #include "net/http/http_cache.h" |
18 #include "net/test/test_server.h" | 19 #include "net/test/test_server.h" |
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebAudioDevice.h" | 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebAudioDevice.h" |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 size_t length, | 480 size_t length, |
480 size_t before_index, | 481 size_t before_index, |
481 const WebKit::WebString& locale) { | 482 const WebKit::WebString& locale) { |
482 DCHECK(locale.isEmpty() || locale.equals("en") || locale.equals("en_US") || | 483 DCHECK(locale.isEmpty() || locale.equals("en") || locale.equals("en_US") || |
483 locale.equals("en_GB")); | 484 locale.equals("en_GB")); |
484 if (!hyphen_dictionary_) { | 485 if (!hyphen_dictionary_) { |
485 // Initialize the hyphen library with a sample dictionary. To avoid test | 486 // Initialize the hyphen library with a sample dictionary. To avoid test |
486 // flakiness, this code synchronously loads the dictionary. | 487 // flakiness, this code synchronously loads the dictionary. |
487 base::FilePath path = webkit_support::GetChromiumRootDirFilePath(); | 488 base::FilePath path = webkit_support::GetChromiumRootDirFilePath(); |
488 path = path.Append(FILE_PATH_LITERAL("third_party/hyphen/hyph_en_US.dic")); | 489 path = path.Append(FILE_PATH_LITERAL("third_party/hyphen/hyph_en_US.dic")); |
489 std::string dictionary; | 490 base::PlatformFile dict_file = base::CreatePlatformFile( |
490 if (!file_util::ReadFileToString(path, &dictionary)) | 491 path, |
| 492 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, |
| 493 NULL, NULL); |
| 494 if (dict_file == base::kInvalidPlatformFileValue) |
491 return 0; | 495 return 0; |
492 hyphen_dictionary_ = hnj_hyphen_load( | 496 ScopedStdioHandle dict_handle(base::FdopenPlatformFile(dict_file, "r")); |
493 reinterpret_cast<const unsigned char*>(dictionary.data()), | 497 if (!dict_handle.get()) { |
494 dictionary.length()); | 498 base::ClosePlatformFile(dict_file); |
| 499 return 0; |
| 500 } |
| 501 hyphen_dictionary_ = hnj_hyphen_load_file(dict_handle.get()); |
495 if (!hyphen_dictionary_) | 502 if (!hyphen_dictionary_) |
496 return 0; | 503 return 0; |
497 } | 504 } |
498 // Retrieve the positions where we can insert hyphens. This function assumes | 505 // Retrieve the positions where we can insert hyphens. This function assumes |
499 // the input word is an English word so it can use the position returned by | 506 // the input word is an English word so it can use the position returned by |
500 // the hyphen library without conversion. | 507 // the hyphen library without conversion. |
501 string16 word_utf16(characters, length); | 508 string16 word_utf16(characters, length); |
502 if (!IsStringASCII(word_utf16)) | 509 if (!IsStringASCII(word_utf16)) |
503 return 0; | 510 return 0; |
504 std::string word = StringToLowerASCII(UTF16ToASCII(word_utf16)); | 511 std::string word = StringToLowerASCII(UTF16ToASCII(word_utf16)); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 return view.release(); | 603 return view.release(); |
597 } | 604 } |
598 | 605 |
599 WebKit::WebLayerTreeView* | 606 WebKit::WebLayerTreeView* |
600 TestWebKitPlatformSupport::createLayerTreeViewForTesting( | 607 TestWebKitPlatformSupport::createLayerTreeViewForTesting( |
601 TestViewType type) { | 608 TestViewType type) { |
602 DCHECK_EQ(TestViewTypeUnitTest, type); | 609 DCHECK_EQ(TestViewTypeUnitTest, type); |
603 return createLayerTreeViewForTesting(); | 610 return createLayerTreeViewForTesting(); |
604 } | 611 } |
605 | 612 |
OLD | NEW |