summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 05:09:50 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 05:09:50 +0000
commit66ff7356a381d6c8c6c3272b095938408c4f3188 (patch)
tree9c3ae2fb0d55d1d9650a8071d1c80c557e7f0d93 /webkit
parent2c8088a4452c2c204237ba9f2f3706e7eeaaf35b (diff)
downloadchromium_src-66ff7356a381d6c8c6c3272b095938408c4f3188.zip
chromium_src-66ff7356a381d6c8c6c3272b095938408c4f3188.tar.gz
chromium_src-66ff7356a381d6c8c6c3272b095938408c4f3188.tar.bz2
Re-try r29078: Remove some deprecated file_util wstring functions.
With the previous patch, the try bots failed with mysterious messages, so I ignored them, patched it into my windows box and tested it there manually, and found no problems. As it turns out, the try failures were real :(. But nsylvain and I found the problem: the behavior of file_util::GetDirectoryFromPath() differs from DirName() when the path is empty (officially, GetDirectoryFromPath is not supposed to support non-absolute paths, but that is not enforced). Here is a green win try result: http://build.chromium.org/buildbot/try-server/builders/win/builds/3705 mac: http://build.chromium.org/buildbot/try-server/builders/mac/builds/3491 linux: http://build.chromium.org/buildbot/try-server/builders/linux/builds/3466 I also applied this patch locally in Windows to test that it doesn't break the chrome frame compile or tests, since that's not covered by the trybots yet. Review URL: http://codereview.chromium.org/271099 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29094 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/default_plugin/plugin_database_handler.cc2
-rw-r--r--webkit/tools/test_shell/image_decoder_unittest.cc85
-rw-r--r--webkit/tools/test_shell/image_decoder_unittest.h26
-rw-r--r--webkit/tools/webcore_unit_tests/BMPImageDecoder_unittest.cpp2
-rw-r--r--webkit/tools/webcore_unit_tests/ICOImageDecoder_unittest.cpp8
-rw-r--r--webkit/tools/webcore_unit_tests/XBMImageDecoder_unittest.cpp2
6 files changed, 67 insertions, 58 deletions
diff --git a/webkit/default_plugin/plugin_database_handler.cc b/webkit/default_plugin/plugin_database_handler.cc
index 9e90939..c597d5a 100644
--- a/webkit/default_plugin/plugin_database_handler.cc
+++ b/webkit/default_plugin/plugin_database_handler.cc
@@ -49,7 +49,7 @@ bool PluginDatabaseHandler::DownloadPluginsFileIfNeeded(
plugins_file_ += L"\\chrome_plugins_file.xml";
bool initiate_download = false;
- if (!file_util::PathExists(plugins_file_)) {
+ if (!file_util::PathExists(FilePath::FromWStringHack(plugins_file_))) {
initiate_download = true;
} else {
SYSTEMTIME creation_system_time = {0};
diff --git a/webkit/tools/test_shell/image_decoder_unittest.cc b/webkit/tools/test_shell/image_decoder_unittest.cc
index 0c73ebd..87af6df 100644
--- a/webkit/tools/test_shell/image_decoder_unittest.cc
+++ b/webkit/tools/test_shell/image_decoder_unittest.cc
@@ -6,6 +6,7 @@
#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"
@@ -19,7 +20,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 std::wstring& path,
+bool ShouldSkipFile(const FilePath& path,
ImageDecoderTestFileSelection file_selection,
const int64 threshold) {
if (file_selection == TEST_ALL)
@@ -32,16 +33,17 @@ bool ShouldSkipFile(const std::wstring& path,
} // anonymous namespace
-void ReadFileToVector(const std::wstring& path, Vector<char>* contents) {
+void ReadFileToVector(const FilePath& 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());
}
-std::wstring GetMD5SumPath(const std::wstring& path) {
- static const std::wstring kDecodedDataExtension(L".md5sum");
- return path + kDecodedDataExtension;
+FilePath GetMD5SumPath(const FilePath& path) {
+ static const FilePath::StringType kDecodedDataExtension(
+ FILE_PATH_LITERAL(".md5sum"));
+ return FilePath(path.value() + kDecodedDataExtension);
}
#ifdef CALCULATE_MD5_SUMS
@@ -63,18 +65,19 @@ void SaveMD5Sum(const std::wstring& path, WebCore::RGBA32Buffer* buffer) {
}
#else
void VerifyImage(WebCore::ImageDecoder* decoder,
- const std::wstring& path,
- const std::wstring& md5_sum_path,
+ const FilePath& path,
+ const FilePath& md5_sum_path,
size_t frame_index) {
// Make sure decoding can complete successfully.
- EXPECT_TRUE(decoder->isSizeAvailable()) << path;
- EXPECT_GE(decoder->frameCount(), frame_index) << path;
+ EXPECT_TRUE(decoder->isSizeAvailable()) << path.value();
+ EXPECT_GE(decoder->frameCount(), frame_index) << path.value();
WebCore::RGBA32Buffer* image_buffer =
decoder->frameBufferAtIndex(frame_index);
- ASSERT_NE(static_cast<WebCore::RGBA32Buffer*>(NULL), image_buffer) << path;
+ ASSERT_NE(static_cast<WebCore::RGBA32Buffer*>(NULL), image_buffer) <<
+ path.value();
EXPECT_EQ(WebCore::RGBA32Buffer::FrameComplete, image_buffer->status()) <<
- path;
- EXPECT_FALSE(decoder->failed()) << path;
+ path.value();
+ EXPECT_FALSE(decoder->failed()) << path.value();
// Calculate MD5 sum.
MD5Digest actual_digest;
@@ -90,36 +93,39 @@ 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;
+ ASSERT_EQ(sizeof expected_digest, file_bytes.size()) << path.value();
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;
+ path.value();
}
#endif
void ImageDecoderTest::SetUp() {
FilePath data_dir;
ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir));
- 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_;
+ data_dir_ = data_dir.AppendASCII("webkit").
+ AppendASCII("data").
+ AppendASCII(format_ + "_decoder");
+ ASSERT_TRUE(file_util::PathExists(data_dir_)) << data_dir_.value();
}
-std::vector<std::wstring> ImageDecoderTest::GetImageFiles() const {
- std::wstring pattern = L"*." + format_;
+std::vector<FilePath> ImageDecoderTest::GetImageFiles() const {
+#if defined(OS_WIN)
+ std::wstring pattern = ASCIIToWide("*." + format_);
+#else
+ std::string pattern = "*." + format_;
+#endif
- file_util::FileEnumerator enumerator(FilePath::FromWStringHack(data_dir_),
+ file_util::FileEnumerator enumerator(data_dir_,
false,
file_util::FileEnumerator::FILES);
- 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)) {
+ std::vector<FilePath> image_files;
+ FilePath next_file_name;
+ while (!(next_file_name = enumerator.Next()).empty()) {
+ if (!MatchPattern(next_file_name.value(), pattern)) {
continue;
}
image_files.push_back(next_file_name);
@@ -128,15 +134,16 @@ std::vector<std::wstring> ImageDecoderTest::GetImageFiles() const {
return image_files;
}
-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));
+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));
}
WebCore::ImageDecoder* ImageDecoderTest::SetupDecoder(
- const std::wstring& path,
+ const FilePath& path,
bool split_at_random) const {
Vector<char> image_contents;
ReadFileToVector(path, &image_contents);
@@ -154,7 +161,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;
+ EXPECT_FALSE(decoder->failed()) << path.value();
// 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.
@@ -175,8 +182,8 @@ WebCore::ImageDecoder* ImageDecoderTest::SetupDecoder(
void ImageDecoderTest::TestDecoding(
ImageDecoderTestFileSelection file_selection,
const int64 threshold) const {
- const std::vector<std::wstring> image_files(GetImageFiles());
- for (std::vector<std::wstring>::const_iterator i(image_files.begin());
+ const std::vector<FilePath> image_files(GetImageFiles());
+ for (std::vector<FilePath>::const_iterator i = image_files.begin();
i != image_files.end(); ++i) {
if (ShouldSkipFile(*i, file_selection, threshold))
continue;
@@ -189,9 +196,9 @@ void ImageDecoderTest::TestDecoding(
decoder->frameBufferAtIndex(0);
if (image_buffer) {
EXPECT_NE(image_buffer->status(),
- WebCore::RGBA32Buffer::FrameComplete) << (*i);
+ WebCore::RGBA32Buffer::FrameComplete) << i->value();
}
- EXPECT_TRUE(decoder->failed()) << (*i);
+ EXPECT_TRUE(decoder->failed()) << i->value();
continue;
}
@@ -212,8 +219,8 @@ void ImageDecoderTest::TestChunkedDecoding(
const Time today = Time::Now().LocalMidnight();
srand(static_cast<unsigned int>(today.ToInternalValue()));
- const std::vector<std::wstring> image_files(GetImageFiles());
- for (std::vector<std::wstring>::const_iterator i(image_files.begin());
+ const std::vector<FilePath> image_files(GetImageFiles());
+ for (std::vector<FilePath>::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 4b1a5d9..760ac2c 100644
--- a/webkit/tools/test_shell/image_decoder_unittest.h
+++ b/webkit/tools/test_shell/image_decoder_unittest.h
@@ -5,6 +5,7 @@
#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"
@@ -13,6 +14,7 @@
#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
@@ -36,40 +38,40 @@ enum ImageDecoderTestFileSelection {
};
// Reads the contents of the specified file into the specified vector.
-void ReadFileToVector(const std::wstring& path, Vector<char>* contents);
+void ReadFileToVector(const FilePath& path, Vector<char>* contents);
// Returns the path the decoded data is saved at.
-std::wstring GetMD5SumPath(const std::wstring& path);
+FilePath GetMD5SumPath(const FilePath& path);
#ifdef CALCULATE_MD5_SUMS
// Saves the MD5 sum to the specified file.
-void SaveMD5Sum(const std::wstring& path, WebCore::RGBA32Buffer* buffer);
+void SaveMD5Sum(const FilePath& 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 std::wstring& path,
- const std::wstring& md5_sum_path,
+ const FilePath& path,
+ const FilePath& md5_sum_path,
size_t frame_index);
#endif
class ImageDecoderTest : public testing::Test {
public:
- explicit ImageDecoderTest(const std::wstring& format) : format_(format) { }
+ explicit ImageDecoderTest(const std::string& format) : format_(format) { }
protected:
virtual void SetUp();
// Returns the vector of image files for testing.
- std::vector<std::wstring> GetImageFiles() const;
+ std::vector<FilePath> GetImageFiles() const;
// Returns true if the image is bogus and should not be successfully decoded.
- bool ShouldImageFail(const std::wstring& path) const;
+ bool ShouldImageFail(const FilePath& 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 std::wstring& path,
+ WebCore::ImageDecoder* SetupDecoder(const FilePath& path,
bool split_at_random) const;
// Verifies each of the test image files is decoded correctly and matches the
@@ -99,14 +101,14 @@ class ImageDecoderTest : public testing::Test {
virtual WebCore::ImageDecoder* CreateDecoder() const = 0;
// The format to be decoded, like "bmp" or "ico".
- std::wstring format_;
+ std::string format_;
protected:
// Path to the test files.
- std::wstring data_dir_;
+ FilePath data_dir_;
private:
- DISALLOW_EVIL_CONSTRUCTORS(ImageDecoderTest);
+ DISALLOW_COPY_AND_ASSIGN(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 bc3c681..aa99023a 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(L"bmp") { }
+ BMPImageDecoderTest() : ImageDecoderTest("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 0203ddf..95c5b15 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(L"ico") { }
+ ICOImageDecoderTest() : ImageDecoderTest("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.
- std::wstring multisize_icon_path(data_dir_);
- file_util::AppendToPath(&multisize_icon_path, L"yahoo.ico");
+ FilePath multisize_icon_path(data_dir_.AppendASCII("yahoo.ico"));
scoped_ptr<WebCore::ImageDecoder> decoder(SetupDecoder(multisize_icon_path,
false));
// Verify the decoding.
- const std::wstring md5_sum_path(GetMD5SumPath(multisize_icon_path) + L"2");
+ const FilePath md5_sum_path(
+ GetMD5SumPath(multisize_icon_path).value() + FILE_PATH_LITERAL("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 0f34238..a84b8ce 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(L"xbm") { }
+ XBMImageDecoderTest() : ImageDecoderTest("xbm") { }
protected:
virtual WebCore::ImageDecoder* CreateDecoder() const {