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 /skia | |
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 'skia')
-rw-r--r-- | skia/ext/vector_canvas_unittest.cc | 127 |
1 files changed, 63 insertions, 64 deletions
diff --git a/skia/ext/vector_canvas_unittest.cc b/skia/ext/vector_canvas_unittest.cc index 2d5d728..59c6d0b 100644 --- a/skia/ext/vector_canvas_unittest.cc +++ b/skia/ext/vector_canvas_unittest.cc @@ -84,7 +84,7 @@ class Bitmap { class Image { public: // Creates the image from the given filename on disk. - explicit Image(const FilePath& filename) : ignore_alpha_(true) { + Image(const std::wstring& filename) : ignore_alpha_(true) { Vector<char> compressed; ReadFileToVector(filename, &compressed); EXPECT_TRUE(compressed.size()); @@ -123,7 +123,7 @@ class Image { int row_length() const { return row_length_; } // Save the image to a png file. Used to create the initial test files. - void SaveToFile(const FilePath& filename) { + void SaveToFile(const std::wstring& filename) { std::vector<unsigned char> compressed; ASSERT_TRUE(gfx::PNGCodec::Encode(&*data_.begin(), gfx::PNGCodec::FORMAT_BGRA, @@ -229,17 +229,18 @@ class ImageTest : public testing::Test { const testing::TestInfo& test_info = *testing::UnitTest::GetInstance()->current_test_info(); PathService::Get(base::DIR_SOURCE_ROOT, &test_dir_); - test_dir_ = test_dir_.AppendASCII("skia"). - AppendASCII("ext"). - AppendASCII("data"). - AppendASCII(test_info.test_case_name()). - AppendASCII(test_info.name()); + file_util::AppendToPath(&test_dir_, L"skia"); + file_util::AppendToPath(&test_dir_, L"ext"); + file_util::AppendToPath(&test_dir_, L"data"); + file_util::AppendToPath(&test_dir_, + ASCIIToWide(test_info.test_case_name())); + file_util::AppendToPath(&test_dir_, ASCIIToWide(test_info.name())); // Hack for a quick lowercase. We assume all the tests names are ASCII. - std::string tmp(WideToASCII(test_dir_.ToWStringHack())); + std::string tmp(WideToASCII(test_dir_)); for (size_t i = 0; i < tmp.size(); ++i) tmp[i] = ToLowerASCII(tmp[i]); - test_dir_ = FilePath::FromWStringHack(ASCIIToWide(tmp)); + test_dir_ = ASCIIToWide(tmp); if (action_ == GENERATE) { // Make sure the directory exist. @@ -248,18 +249,16 @@ class ImageTest : public testing::Test { } // Returns the fully qualified path of a data file. - FilePath test_file(const FilePath::StringType& filename) const { + std::wstring test_file(const std::wstring& filename) const { // Hack for a quick lowercase. We assume all the test data file names are // ASCII. -#if defined(OS_WIN) - std::string tmp = WideToASCII(filename); -#else - std::string tmp(filename); -#endif + std::string tmp(WideToASCII(filename)); for (size_t i = 0; i < tmp.size(); ++i) tmp[i] = ToLowerASCII(tmp[i]); - return test_dir_.AppendASCII(tmp); + std::wstring path(test_dir_); + file_util::AppendToPath(&path, ASCIIToWide(tmp)); + return path; } // Compares or saves the bitmap currently loaded in the context, depending on @@ -267,8 +266,8 @@ class ImageTest : public testing::Test { // 100] on failure. The return value is the percentage of difference between // the image in the file and the image in the canvas. double ProcessCanvas(const skia::PlatformCanvas& canvas, - FilePath::StringType filename) const { - filename = filename + FILE_PATH_LITERAL(".png"); + std::wstring filename) const { + filename += L".png"; switch (action_) { case GENERATE: SaveImage(canvas, filename); @@ -286,7 +285,7 @@ class ImageTest : public testing::Test { // Compares the bitmap currently loaded in the context with the file. Returns // the percentage of pixel difference between both images, between 0 and 100. double CompareImage(const skia::PlatformCanvas& canvas, - const FilePath::StringType& filename) const { + const std::wstring& filename) const { Image image1(canvas); Image image2(test_file(filename)); double diff = image1.PercentageDifferent(image2); @@ -295,14 +294,14 @@ class ImageTest : public testing::Test { // Saves the bitmap currently loaded in the context into the file. void SaveImage(const skia::PlatformCanvas& canvas, - const FilePath::StringType& filename) const { + const std::wstring& filename) const { Image(canvas).SaveToFile(test_file(filename)); } ProcessAction action_; // Path to directory used to contain the test data. - FilePath test_dir_; + std::wstring test_dir_; DISALLOW_COPY_AND_ASSIGN(ImageTest); }; @@ -329,7 +328,7 @@ void Premultiply(SkBitmap bitmap) { } } -void LoadPngFileToSkBitmap(const FilePath& filename, +void LoadPngFileToSkBitmap(const std::wstring& filename, SkBitmap* bitmap, bool is_opaque) { Vector<char> compressed; @@ -398,7 +397,7 @@ class VectorCanvasTest : public ImageTest { // Compares both canvas and returns the pixel difference in percentage between // both images. 0 on success and ]0, 100] on failure. - double ProcessImage(const FilePath::StringType& filename) { + double ProcessImage(const std::wstring& filename) { std::wstring number(StringPrintf(L"%02d_", number_++)); double diff1 = parent::ProcessCanvas(*vcanvas_, number + L"vc_" + filename); double diff2 = parent::ProcessCanvas(*pcanvas_, number + L"pc_" + filename); @@ -461,20 +460,20 @@ TEST_F(VectorCanvasTest, Uninitialized) { // PlatformCanvas default initialization is almost white 0x01FFFEFD (invalid // Skia color) in both Debug and Release. See magicTransparencyColor in // platform_device.cc - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("empty"))); + EXPECT_EQ(0., ProcessImage(L"empty")); } TEST_F(VectorCanvasTest, BasicDrawing) { EXPECT_EQ(Image(*vcanvas_).PercentageDifferent(Image(*pcanvas_)), 0.) << L"clean"; - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("clean"))); + EXPECT_EQ(0., ProcessImage(L"clean")); // Clear white. { vcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); pcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawARGB"))); + EXPECT_EQ(0., ProcessImage(L"drawARGB")); // Diagonal line top-left to bottom-right. { @@ -483,7 +482,7 @@ TEST_F(VectorCanvasTest, BasicDrawing) { vcanvas_->drawLine(10, 10, 90, 90, paint); pcanvas_->drawLine(10, 10, 90, 90, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawLine_black"))); + EXPECT_EQ(0., ProcessImage(L"drawLine_black")); // Rect. { @@ -492,7 +491,7 @@ TEST_F(VectorCanvasTest, BasicDrawing) { vcanvas_->drawRectCoords(25, 25, 75, 75, paint); pcanvas_->drawRectCoords(25, 25, 75, 75, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawRect_green"))); + EXPECT_EQ(0., ProcessImage(L"drawRect_green")); // A single-point rect doesn't leave any mark. { @@ -501,7 +500,7 @@ TEST_F(VectorCanvasTest, BasicDrawing) { vcanvas_->drawRectCoords(5, 5, 5, 5, paint); pcanvas_->drawRectCoords(5, 5, 5, 5, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawRect_noop"))); + EXPECT_EQ(0., ProcessImage(L"drawRect_noop")); // Rect. { @@ -510,14 +509,14 @@ TEST_F(VectorCanvasTest, BasicDrawing) { vcanvas_->drawRectCoords(75, 50, 80, 55, paint); pcanvas_->drawRectCoords(75, 50, 80, 55, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawRect_noop"))); + EXPECT_EQ(0., ProcessImage(L"drawRect_noop")); // Empty again { vcanvas_->drawPaint(SkPaint()); pcanvas_->drawPaint(SkPaint()); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawPaint_black"))); + EXPECT_EQ(0., ProcessImage(L"drawPaint_black")); // Horizontal line left to right. { @@ -526,7 +525,7 @@ TEST_F(VectorCanvasTest, BasicDrawing) { vcanvas_->drawLine(10, 20, 90, 20, paint); pcanvas_->drawLine(10, 20, 90, 20, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawLine_left_to_right"))); + EXPECT_EQ(0., ProcessImage(L"drawLine_left_to_right")); // Vertical line downward. { @@ -535,7 +534,7 @@ TEST_F(VectorCanvasTest, BasicDrawing) { vcanvas_->drawLine(30, 10, 30, 90, paint); pcanvas_->drawLine(30, 10, 30, 90, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawLine_red"))); + EXPECT_EQ(0., ProcessImage(L"drawLine_red")); } TEST_F(VectorCanvasTest, Circles) { @@ -553,7 +552,7 @@ TEST_F(VectorCanvasTest, Circles) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle_stroke"))); + EXPECT_EQ(0., ProcessImage(L"circle_stroke")); // Filled Circle. { @@ -564,7 +563,7 @@ TEST_F(VectorCanvasTest, Circles) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle_fill"))); + EXPECT_EQ(0., ProcessImage(L"circle_fill")); // Stroked Circle over. { @@ -576,7 +575,7 @@ TEST_F(VectorCanvasTest, Circles) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle_over_strike"))); + EXPECT_EQ(0., ProcessImage(L"circle_over_strike")); // Stroke and Fill Circle. { @@ -588,7 +587,7 @@ TEST_F(VectorCanvasTest, Circles) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle_stroke_and_fill"))); + EXPECT_EQ(0., ProcessImage(L"circle_stroke_and_fill")); // Line + Quad + Cubic. { @@ -607,7 +606,7 @@ TEST_F(VectorCanvasTest, Circles) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("mixed_stroke"))); + EXPECT_EQ(0., ProcessImage(L"mixed_stroke")); } TEST_F(VectorCanvasTest, LineOrientation) { @@ -626,7 +625,7 @@ TEST_F(VectorCanvasTest, LineOrientation) { vcanvas_->drawLine(90, 30, 10, 30, paint); pcanvas_->drawLine(90, 30, 10, 30, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("horizontal"))); + EXPECT_EQ(0., ProcessImage(L"horizontal")); // Vertical lines. { @@ -639,7 +638,7 @@ TEST_F(VectorCanvasTest, LineOrientation) { vcanvas_->drawLine(30, 90, 30, 10, paint); pcanvas_->drawLine(30, 90, 30, 10, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("vertical"))); + EXPECT_EQ(0., ProcessImage(L"vertical")); // Try again with a 180 degres rotation. vcanvas_->rotate(180); @@ -654,7 +653,7 @@ TEST_F(VectorCanvasTest, LineOrientation) { vcanvas_->drawLine(-90, -35, -10, -35, paint); pcanvas_->drawLine(-90, -35, -10, -35, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("horizontal_180"))); + EXPECT_EQ(0., ProcessImage(L"horizontal_180")); // Vertical lines (rotated). { @@ -665,7 +664,7 @@ TEST_F(VectorCanvasTest, LineOrientation) { vcanvas_->drawLine(-35, -90, -35, -10, paint); pcanvas_->drawLine(-35, -90, -35, -10, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("vertical_180"))); + EXPECT_EQ(0., ProcessImage(L"vertical_180")); } TEST_F(VectorCanvasTest, PathOrientation) { @@ -688,7 +687,7 @@ TEST_F(VectorCanvasTest, PathOrientation) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawPath_ltr"))); + EXPECT_EQ(0., ProcessImage(L"drawPath_ltr")); // Horizontal lines. { @@ -705,7 +704,7 @@ TEST_F(VectorCanvasTest, PathOrientation) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawPath_rtl"))); + EXPECT_EQ(0., ProcessImage(L"drawPath_rtl")); } TEST_F(VectorCanvasTest, DiagonalLines) { @@ -714,7 +713,7 @@ TEST_F(VectorCanvasTest, DiagonalLines) { vcanvas_->drawLine(10, 10, 90, 90, paint); pcanvas_->drawLine(10, 10, 90, 90, paint); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("nw-se"))); + EXPECT_EQ(0., ProcessImage(L"nw-se")); // Starting here, there is NO WAY to make them agree. At least verify that the // output doesn't change across versions. This test is disabled. See bug @@ -723,15 +722,15 @@ TEST_F(VectorCanvasTest, DiagonalLines) { vcanvas_->drawLine(10, 95, 90, 15, paint); pcanvas_->drawLine(10, 95, 90, 15, paint); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("sw-ne"))); + EXPECT_EQ(0., ProcessImage(L"sw-ne")); vcanvas_->drawLine(90, 10, 10, 90, paint); pcanvas_->drawLine(90, 10, 10, 90, paint); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("ne-sw"))); + EXPECT_EQ(0., ProcessImage(L"ne-sw")); vcanvas_->drawLine(95, 90, 15, 10, paint); pcanvas_->drawLine(95, 90, 15, 10, paint); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("se-nw"))); + EXPECT_EQ(0., ProcessImage(L"se-nw")); } TEST_F(VectorCanvasTest, PathEffects) { @@ -747,7 +746,7 @@ TEST_F(VectorCanvasTest, PathEffects) { vcanvas_->drawLine(10, 10, 90, 10, paint); pcanvas_->drawLine(10, 10, 90, 10, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("dash_line"))); + EXPECT_EQ(0., ProcessImage(L"dash_line")); // Starting here, there is NO WAY to make them agree. At least verify that the @@ -771,7 +770,7 @@ TEST_F(VectorCanvasTest, PathEffects) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("dash_path"))); + EXPECT_EQ(0., ProcessImage(L"dash_path")); { SkPaint paint; @@ -785,7 +784,7 @@ TEST_F(VectorCanvasTest, PathEffects) { vcanvas_->drawRectCoords(20, 20, 30, 30, paint); pcanvas_->drawRectCoords(20, 20, 30, 30, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("dash_rect"))); + EXPECT_EQ(0., ProcessImage(L"dash_rect")); // This thing looks like it has been drawn by a 3 years old kid. I haven't // filed a bug on this since I guess nobody is expecting this to look nice. @@ -802,7 +801,7 @@ TEST_F(VectorCanvasTest, PathEffects) { path.addCircle(50, 75, 10); vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle"))); + EXPECT_EQ(0., ProcessImage(L"circle")); } } @@ -812,7 +811,7 @@ TEST_F(VectorCanvasTest, Bitmaps) { LoadPngFileToSkBitmap(test_file(L"bitmap_opaque.png"), &bitmap, true); vcanvas_->drawBitmap(bitmap, 13, 3, NULL); pcanvas_->drawBitmap(bitmap, 13, 3, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("opaque"))); + EXPECT_EQ(0., ProcessImage(L"opaque")); } { @@ -820,7 +819,7 @@ TEST_F(VectorCanvasTest, Bitmaps) { LoadPngFileToSkBitmap(test_file(L"bitmap_alpha.png"), &bitmap, false); vcanvas_->drawBitmap(bitmap, 5, 15, NULL); pcanvas_->drawBitmap(bitmap, 5, 15, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("alpha"))); + EXPECT_EQ(0., ProcessImage(L"alpha")); } } @@ -838,7 +837,7 @@ TEST_F(VectorCanvasTest, ClippingRect) { vcanvas_->drawBitmap(bitmap, 13, 3, NULL); pcanvas_->drawBitmap(bitmap, 13, 3, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rect"))); + EXPECT_EQ(0., ProcessImage(L"rect")); } TEST_F(VectorCanvasTest, ClippingPath) { @@ -852,7 +851,7 @@ TEST_F(VectorCanvasTest, ClippingPath) { vcanvas_->drawBitmap(bitmap, 14, 3, NULL); pcanvas_->drawBitmap(bitmap, 14, 3, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("path"))); + EXPECT_EQ(0., ProcessImage(L"path")); } TEST_F(VectorCanvasTest, ClippingCombined) { @@ -874,7 +873,7 @@ TEST_F(VectorCanvasTest, ClippingCombined) { vcanvas_->drawBitmap(bitmap, 15, 3, NULL); pcanvas_->drawBitmap(bitmap, 15, 3, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("combined"))); + EXPECT_EQ(0., ProcessImage(L"combined")); } TEST_F(VectorCanvasTest, ClippingIntersect) { @@ -896,7 +895,7 @@ TEST_F(VectorCanvasTest, ClippingIntersect) { vcanvas_->drawBitmap(bitmap, 15, 3, NULL); pcanvas_->drawBitmap(bitmap, 15, 3, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("intersect"))); + EXPECT_EQ(0., ProcessImage(L"intersect")); } TEST_F(VectorCanvasTest, ClippingClean) { @@ -915,7 +914,7 @@ TEST_F(VectorCanvasTest, ClippingClean) { vcanvas_->drawBitmap(bitmap, 15, 3, NULL); pcanvas_->drawBitmap(bitmap, 15, 3, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("clipped"))); + EXPECT_EQ(0., ProcessImage(L"clipped")); vcanvas_->clipRegion(old_region, SkRegion::kReplace_Op); pcanvas_->clipRegion(old_region, SkRegion::kReplace_Op); } @@ -923,7 +922,7 @@ TEST_F(VectorCanvasTest, ClippingClean) { // Verify that the clipping region has been fixed back. vcanvas_->drawBitmap(bitmap, 55, 3, NULL); pcanvas_->drawBitmap(bitmap, 55, 3, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("unclipped"))); + EXPECT_EQ(0., ProcessImage(L"unclipped")); } } @@ -936,14 +935,14 @@ TEST_F(VectorCanvasTest, DISABLED_Matrix) { pcanvas_->translate(15, 3); vcanvas_->drawBitmap(bitmap, 0, 0, NULL); pcanvas_->drawBitmap(bitmap, 0, 0, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("translate1"))); + EXPECT_EQ(0., ProcessImage(L"translate1")); } { vcanvas_->translate(-30, -23); pcanvas_->translate(-30, -23); vcanvas_->drawBitmap(bitmap, 0, 0, NULL); pcanvas_->drawBitmap(bitmap, 0, 0, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("translate2"))); + EXPECT_EQ(0., ProcessImage(L"translate2")); } vcanvas_->resetMatrix(); pcanvas_->resetMatrix(); @@ -958,7 +957,7 @@ TEST_F(VectorCanvasTest, DISABLED_Matrix) { pcanvas_->scale(SkDoubleToScalar(1.9), SkDoubleToScalar(1.5)); vcanvas_->drawBitmap(bitmap, 1, 1, NULL); pcanvas_->drawBitmap(bitmap, 1, 1, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("scale"))); + EXPECT_EQ(0., ProcessImage(L"scale")); } vcanvas_->resetMatrix(); pcanvas_->resetMatrix(); @@ -968,7 +967,7 @@ TEST_F(VectorCanvasTest, DISABLED_Matrix) { pcanvas_->rotate(67); vcanvas_->drawBitmap(bitmap, 20, -50, NULL); pcanvas_->drawBitmap(bitmap, 20, -50, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rotate"))); + EXPECT_EQ(0., ProcessImage(L"rotate")); } } |