diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 03:41:02 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 03:41:02 +0000 |
commit | 6ec54c1e86aa5d29c7223a86acbfa850be39c806 (patch) | |
tree | 8c0be0238c2f35646c3545060375a9032c50b04d /webkit/tools | |
parent | 89f580b14355e7342cff030747d12ec18f8ca012 (diff) | |
download | chromium_src-6ec54c1e86aa5d29c7223a86acbfa850be39c806.zip chromium_src-6ec54c1e86aa5d29c7223a86acbfa850be39c806.tar.gz chromium_src-6ec54c1e86aa5d29c7223a86acbfa850be39c806.tar.bz2 |
Revert wstring patch (r29078 and follow up commits). It is causing failures on the buildbots.
TBR=nsylvain
Review URL: http://codereview.chromium.org/280004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29085 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools')
5 files changed, 57 insertions, 66 deletions
diff --git a/webkit/tools/test_shell/image_decoder_unittest.cc b/webkit/tools/test_shell/image_decoder_unittest.cc index 87af6df..0c73ebd 100644 --- a/webkit/tools/test_shell/image_decoder_unittest.cc +++ b/webkit/tools/test_shell/image_decoder_unittest.cc @@ -6,7 +6,6 @@ #include "webkit/tools/test_shell/image_decoder_unittest.h" -#include "base/file_path.h" #include "base/file_util.h" #include "base/md5.h" #include "base/path_service.h" @@ -20,7 +19,7 @@ namespace { // Determine if we should test with file specified by |path| based // on |file_selection| and the |threshold| for the file size. -bool ShouldSkipFile(const FilePath& path, +bool ShouldSkipFile(const std::wstring& path, ImageDecoderTestFileSelection file_selection, const int64 threshold) { if (file_selection == TEST_ALL) @@ -33,17 +32,16 @@ bool ShouldSkipFile(const FilePath& path, } // anonymous namespace -void ReadFileToVector(const FilePath& path, Vector<char>* contents) { +void ReadFileToVector(const std::wstring& path, Vector<char>* contents) { std::string contents_str; file_util::ReadFileToString(path, &contents_str); contents->resize(contents_str.size()); memcpy(&contents->first(), contents_str.data(), contents_str.size()); } -FilePath GetMD5SumPath(const FilePath& path) { - static const FilePath::StringType kDecodedDataExtension( - FILE_PATH_LITERAL(".md5sum")); - return FilePath(path.value() + kDecodedDataExtension); +std::wstring GetMD5SumPath(const std::wstring& path) { + static const std::wstring kDecodedDataExtension(L".md5sum"); + return path + kDecodedDataExtension; } #ifdef CALCULATE_MD5_SUMS @@ -65,19 +63,18 @@ void SaveMD5Sum(const std::wstring& path, WebCore::RGBA32Buffer* buffer) { } #else void VerifyImage(WebCore::ImageDecoder* decoder, - const FilePath& path, - const FilePath& md5_sum_path, + const std::wstring& path, + const std::wstring& md5_sum_path, size_t frame_index) { // Make sure decoding can complete successfully. - EXPECT_TRUE(decoder->isSizeAvailable()) << path.value(); - EXPECT_GE(decoder->frameCount(), frame_index) << path.value(); + EXPECT_TRUE(decoder->isSizeAvailable()) << path; + EXPECT_GE(decoder->frameCount(), frame_index) << path; WebCore::RGBA32Buffer* image_buffer = decoder->frameBufferAtIndex(frame_index); - ASSERT_NE(static_cast<WebCore::RGBA32Buffer*>(NULL), image_buffer) << - path.value(); + ASSERT_NE(static_cast<WebCore::RGBA32Buffer*>(NULL), image_buffer) << path; EXPECT_EQ(WebCore::RGBA32Buffer::FrameComplete, image_buffer->status()) << - path.value(); - EXPECT_FALSE(decoder->failed()) << path.value(); + path; + EXPECT_FALSE(decoder->failed()) << path; // Calculate MD5 sum. MD5Digest actual_digest; @@ -93,39 +90,36 @@ void VerifyImage(WebCore::ImageDecoder* decoder, std::string file_bytes; file_util::ReadFileToString(md5_sum_path, &file_bytes); MD5Digest expected_digest; - ASSERT_EQ(sizeof expected_digest, file_bytes.size()) << path.value(); + ASSERT_EQ(sizeof expected_digest, file_bytes.size()) << path; memcpy(&expected_digest, file_bytes.data(), sizeof expected_digest); // Verify that the sums are the same. EXPECT_EQ(0, memcmp(&expected_digest, &actual_digest, sizeof(MD5Digest))) << - path.value(); + path; } #endif void ImageDecoderTest::SetUp() { FilePath data_dir; ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir)); - data_dir_ = data_dir.AppendASCII("webkit"). - AppendASCII("data"). - AppendASCII(format_ + "_decoder"); - ASSERT_TRUE(file_util::PathExists(data_dir_)) << data_dir_.value(); + data_dir_ = data_dir.ToWStringHack(); + file_util::AppendToPath(&data_dir_, L"webkit"); + file_util::AppendToPath(&data_dir_, L"data"); + file_util::AppendToPath(&data_dir_, format_ + L"_decoder"); + ASSERT_TRUE(file_util::PathExists(data_dir_)) << data_dir_; } -std::vector<FilePath> ImageDecoderTest::GetImageFiles() const { -#if defined(OS_WIN) - std::wstring pattern = ASCIIToWide("*." + format_); -#else - std::string pattern = "*." + format_; -#endif +std::vector<std::wstring> ImageDecoderTest::GetImageFiles() const { + std::wstring pattern = L"*." + format_; - file_util::FileEnumerator enumerator(data_dir_, + file_util::FileEnumerator enumerator(FilePath::FromWStringHack(data_dir_), false, file_util::FileEnumerator::FILES); - std::vector<FilePath> image_files; - FilePath next_file_name; - while (!(next_file_name = enumerator.Next()).empty()) { - if (!MatchPattern(next_file_name.value(), pattern)) { + std::vector<std::wstring> image_files; + std::wstring next_file_name; + while ((next_file_name = enumerator.Next().ToWStringHack()) != L"") { + if (!MatchPattern(next_file_name, pattern)) { continue; } image_files.push_back(next_file_name); @@ -134,16 +128,15 @@ std::vector<FilePath> ImageDecoderTest::GetImageFiles() const { return image_files; } -bool ImageDecoderTest::ShouldImageFail(const FilePath& path) const { - static const FilePath::StringType kBadSuffix(FILE_PATH_LITERAL(".bad.")); - return (path.value().length() > (kBadSuffix.length() + format_.length()) && - !path.value().compare(path.value().length() - format_.length() - - kBadSuffix.length(), - kBadSuffix.length(), kBadSuffix)); +bool ImageDecoderTest::ShouldImageFail(const std::wstring& path) const { + static const std::wstring kBadSuffix(L".bad."); + return (path.length() > (kBadSuffix.length() + format_.length()) && + !path.compare(path.length() - format_.length() - kBadSuffix.length(), + kBadSuffix.length(), kBadSuffix)); } WebCore::ImageDecoder* ImageDecoderTest::SetupDecoder( - const FilePath& path, + const std::wstring& path, bool split_at_random) const { Vector<char> image_contents; ReadFileToVector(path, &image_contents); @@ -161,7 +154,7 @@ WebCore::ImageDecoder* ImageDecoderTest::SetupDecoder( // Make sure the image decoder doesn't fail when we ask for the frame buffer // for this partial image. decoder->setData(shared_contents.get(), false); - EXPECT_FALSE(decoder->failed()) << path.value(); + EXPECT_FALSE(decoder->failed()) << path; // NOTE: We can't check that frame 0 is non-NULL, because if this is an ICO // and we haven't yet supplied enough data to read the directory, there is // no framecount and thus no first frame. @@ -182,8 +175,8 @@ WebCore::ImageDecoder* ImageDecoderTest::SetupDecoder( void ImageDecoderTest::TestDecoding( ImageDecoderTestFileSelection file_selection, const int64 threshold) const { - const std::vector<FilePath> image_files(GetImageFiles()); - for (std::vector<FilePath>::const_iterator i = image_files.begin(); + const std::vector<std::wstring> image_files(GetImageFiles()); + for (std::vector<std::wstring>::const_iterator i(image_files.begin()); i != image_files.end(); ++i) { if (ShouldSkipFile(*i, file_selection, threshold)) continue; @@ -196,9 +189,9 @@ void ImageDecoderTest::TestDecoding( decoder->frameBufferAtIndex(0); if (image_buffer) { EXPECT_NE(image_buffer->status(), - WebCore::RGBA32Buffer::FrameComplete) << i->value(); + WebCore::RGBA32Buffer::FrameComplete) << (*i); } - EXPECT_TRUE(decoder->failed()) << i->value(); + EXPECT_TRUE(decoder->failed()) << (*i); continue; } @@ -219,8 +212,8 @@ void ImageDecoderTest::TestChunkedDecoding( const Time today = Time::Now().LocalMidnight(); srand(static_cast<unsigned int>(today.ToInternalValue())); - const std::vector<FilePath> image_files(GetImageFiles()); - for (std::vector<FilePath>::const_iterator i = image_files.begin(); + const std::vector<std::wstring> image_files(GetImageFiles()); + for (std::vector<std::wstring>::const_iterator i(image_files.begin()); i != image_files.end(); ++i) { if (ShouldSkipFile(*i, file_selection, threshold)) continue; diff --git a/webkit/tools/test_shell/image_decoder_unittest.h b/webkit/tools/test_shell/image_decoder_unittest.h index 760ac2c..4b1a5d9 100644 --- a/webkit/tools/test_shell/image_decoder_unittest.h +++ b/webkit/tools/test_shell/image_decoder_unittest.h @@ -5,7 +5,6 @@ #ifndef WEBKIT_TOOLS_TEST_SHELL_IMAGE_DECODER_UNITTEST_H_ #define WEBKIT_TOOLS_TEST_SHELL_IMAGE_DECODER_UNITTEST_H_ -#include <string> #include <vector> #include "Vector.h" @@ -14,7 +13,6 @@ #undef LOG #include "base/basictypes.h" -#include "base/file_path.h" #include "testing/gtest/include/gtest/gtest.h" // If CALCULATE_MD5_SUMS is not defined, then this test decodes a handful of @@ -38,40 +36,40 @@ enum ImageDecoderTestFileSelection { }; // Reads the contents of the specified file into the specified vector. -void ReadFileToVector(const FilePath& path, Vector<char>* contents); +void ReadFileToVector(const std::wstring& path, Vector<char>* contents); // Returns the path the decoded data is saved at. -FilePath GetMD5SumPath(const FilePath& path); +std::wstring GetMD5SumPath(const std::wstring& path); #ifdef CALCULATE_MD5_SUMS // Saves the MD5 sum to the specified file. -void SaveMD5Sum(const FilePath& path, WebCore::RGBA32Buffer* buffer); +void SaveMD5Sum(const std::wstring& path, WebCore::RGBA32Buffer* buffer); #else // Verifies the image. |path| identifies the path the image was loaded from. // |frame_index| indicates which index from the decoder we should examine. void VerifyImage(WebCore::ImageDecoder* decoder, - const FilePath& path, - const FilePath& md5_sum_path, + const std::wstring& path, + const std::wstring& md5_sum_path, size_t frame_index); #endif class ImageDecoderTest : public testing::Test { public: - explicit ImageDecoderTest(const std::string& format) : format_(format) { } + explicit ImageDecoderTest(const std::wstring& format) : format_(format) { } protected: virtual void SetUp(); // Returns the vector of image files for testing. - std::vector<FilePath> GetImageFiles() const; + std::vector<std::wstring> GetImageFiles() const; // Returns true if the image is bogus and should not be successfully decoded. - bool ShouldImageFail(const FilePath& path) const; + bool ShouldImageFail(const std::wstring& path) const; // Creates and returns an ImageDecoder for the file at the given |path|. If // |split_at_random| is true, also verifies that breaking the data supplied to // the decoder into two random pieces does not cause problems. - WebCore::ImageDecoder* SetupDecoder(const FilePath& path, + WebCore::ImageDecoder* SetupDecoder(const std::wstring& path, bool split_at_random) const; // Verifies each of the test image files is decoded correctly and matches the @@ -101,14 +99,14 @@ class ImageDecoderTest : public testing::Test { virtual WebCore::ImageDecoder* CreateDecoder() const = 0; // The format to be decoded, like "bmp" or "ico". - std::string format_; + std::wstring format_; protected: // Path to the test files. - FilePath data_dir_; + std::wstring data_dir_; private: - DISALLOW_COPY_AND_ASSIGN(ImageDecoderTest); + DISALLOW_EVIL_CONSTRUCTORS(ImageDecoderTest); }; #endif // WEBKIT_TOOLS_TEST_SHELL_IMAGE_DECODER_UNITTEST_H_ diff --git a/webkit/tools/webcore_unit_tests/BMPImageDecoder_unittest.cpp b/webkit/tools/webcore_unit_tests/BMPImageDecoder_unittest.cpp index aa99023a..bc3c681 100644 --- a/webkit/tools/webcore_unit_tests/BMPImageDecoder_unittest.cpp +++ b/webkit/tools/webcore_unit_tests/BMPImageDecoder_unittest.cpp @@ -34,7 +34,7 @@ class BMPImageDecoderTest : public ImageDecoderTest { public: - BMPImageDecoderTest() : ImageDecoderTest("bmp") { } + BMPImageDecoderTest() : ImageDecoderTest(L"bmp") { } protected: virtual WebCore::ImageDecoder* CreateDecoder() const { diff --git a/webkit/tools/webcore_unit_tests/ICOImageDecoder_unittest.cpp b/webkit/tools/webcore_unit_tests/ICOImageDecoder_unittest.cpp index 95c5b15..0203ddf 100644 --- a/webkit/tools/webcore_unit_tests/ICOImageDecoder_unittest.cpp +++ b/webkit/tools/webcore_unit_tests/ICOImageDecoder_unittest.cpp @@ -37,7 +37,7 @@ class ICOImageDecoderTest : public ImageDecoderTest { public: - ICOImageDecoderTest() : ImageDecoderTest("ico") { } + ICOImageDecoderTest() : ImageDecoderTest(L"ico") { } protected: virtual WebCore::ImageDecoder* CreateDecoder() const { @@ -59,13 +59,13 @@ TEST_F(ICOImageDecoderTest, FaviconSize) { // Test that the decoder decodes multiple sizes of icons which have them. // Load an icon that has both favicon-size and larger entries. - FilePath multisize_icon_path(data_dir_.AppendASCII("yahoo.ico")); + std::wstring multisize_icon_path(data_dir_); + file_util::AppendToPath(&multisize_icon_path, L"yahoo.ico"); scoped_ptr<WebCore::ImageDecoder> decoder(SetupDecoder(multisize_icon_path, false)); // Verify the decoding. - const FilePath md5_sum_path( - GetMD5SumPath(multisize_icon_path).value() + FILE_PATH_LITERAL("2")); + const std::wstring md5_sum_path(GetMD5SumPath(multisize_icon_path) + L"2"); static const int kDesiredFrameIndex = 3; #ifdef CALCULATE_MD5_SUMS SaveMD5Sum(md5_sum_path, decoder->frameBufferAtIndex(kDesiredFrameIndex)); diff --git a/webkit/tools/webcore_unit_tests/XBMImageDecoder_unittest.cpp b/webkit/tools/webcore_unit_tests/XBMImageDecoder_unittest.cpp index a84b8ce..0f34238 100644 --- a/webkit/tools/webcore_unit_tests/XBMImageDecoder_unittest.cpp +++ b/webkit/tools/webcore_unit_tests/XBMImageDecoder_unittest.cpp @@ -34,7 +34,7 @@ class XBMImageDecoderTest : public ImageDecoderTest { public: - XBMImageDecoderTest() : ImageDecoderTest("xbm") { } + XBMImageDecoderTest() : ImageDecoderTest(L"xbm") { } protected: virtual WebCore::ImageDecoder* CreateDecoder() const { |