| 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 size_t length, | 489 size_t length, |
| 489 size_t before_index, | 490 size_t before_index, |
| 490 const WebKit::WebString& locale) { | 491 const WebKit::WebString& locale) { |
| 491 DCHECK(locale.isEmpty() || locale.equals("en") || locale.equals("en_US") || | 492 DCHECK(locale.isEmpty() || locale.equals("en") || locale.equals("en_US") || |
| 492 locale.equals("en_GB")); | 493 locale.equals("en_GB")); |
| 493 if (!hyphen_dictionary_) { | 494 if (!hyphen_dictionary_) { |
| 494 // Initialize the hyphen library with a sample dictionary. To avoid test | 495 // Initialize the hyphen library with a sample dictionary. To avoid test |
| 495 // flakiness, this code synchronously loads the dictionary. | 496 // flakiness, this code synchronously loads the dictionary. |
| 496 base::FilePath path = webkit_support::GetChromiumRootDirFilePath(); | 497 base::FilePath path = webkit_support::GetChromiumRootDirFilePath(); |
| 497 path = path.Append(FILE_PATH_LITERAL("third_party/hyphen/hyph_en_US.dic")); | 498 path = path.Append(FILE_PATH_LITERAL("third_party/hyphen/hyph_en_US.dic")); |
| 498 std::string dictionary; | 499 base::PlatformFile dict_file = base::CreatePlatformFile( |
| 499 if (!file_util::ReadFileToString(path, &dictionary)) | 500 path, |
| 501 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, |
| 502 NULL, NULL); |
| 503 if (dict_file == base::kInvalidPlatformFileValue) |
| 500 return 0; | 504 return 0; |
| 501 hyphen_dictionary_ = hnj_hyphen_load( | 505 ScopedStdioHandle dict_handle(base::FdopenPlatformFile(dict_file, "r")); |
| 502 reinterpret_cast<const unsigned char*>(dictionary.data()), | 506 if (!dict_handle.get()) { |
| 503 dictionary.length()); | 507 base::ClosePlatformFile(dict_file); |
| 508 return 0; |
| 509 } |
| 510 hyphen_dictionary_ = hnj_hyphen_load_file(dict_handle.get()); |
| 504 if (!hyphen_dictionary_) | 511 if (!hyphen_dictionary_) |
| 505 return 0; | 512 return 0; |
| 506 } | 513 } |
| 507 // Retrieve the positions where we can insert hyphens. This function assumes | 514 // Retrieve the positions where we can insert hyphens. This function assumes |
| 508 // the input word is an English word so it can use the position returned by | 515 // the input word is an English word so it can use the position returned by |
| 509 // the hyphen library without conversion. | 516 // the hyphen library without conversion. |
| 510 string16 word_utf16(characters, length); | 517 string16 word_utf16(characters, length); |
| 511 if (!IsStringASCII(word_utf16)) | 518 if (!IsStringASCII(word_utf16)) |
| 512 return 0; | 519 return 0; |
| 513 std::string word = StringToLowerASCII(UTF16ToASCII(word_utf16)); | 520 std::string word = StringToLowerASCII(UTF16ToASCII(word_utf16)); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 return view.release(); | 612 return view.release(); |
| 606 } | 613 } |
| 607 | 614 |
| 608 WebKit::WebLayerTreeView* | 615 WebKit::WebLayerTreeView* |
| 609 TestWebKitPlatformSupport::createLayerTreeViewForTesting( | 616 TestWebKitPlatformSupport::createLayerTreeViewForTesting( |
| 610 TestViewType type) { | 617 TestViewType type) { |
| 611 DCHECK_EQ(TestViewTypeUnitTest, type); | 618 DCHECK_EQ(TestViewTypeUnitTest, type); |
| 612 return createLayerTreeViewForTesting(); | 619 return createLayerTreeViewForTesting(); |
| 613 } | 620 } |
| 614 | 621 |
| OLD | NEW |