| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "skia/ext/analysis_canvas.h" | 6 #include "skia/ext/analysis_canvas.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "third_party/skia/include/core/SkShader.h" | 8 #include "third_party/skia/include/core/SkShader.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 void SolidColorFill(skia::AnalysisCanvas& canvas) { | 12 void SolidColorFill(skia::AnalysisCanvas& canvas) { |
| 13 canvas.clear(SkColorSetARGB(255, 255, 255, 255)); | 13 canvas.clear(SkColorSetARGB(255, 255, 255, 255)); |
| 14 } | 14 } |
| 15 | 15 |
| 16 void TransparentFill(skia::AnalysisCanvas& canvas) { | 16 void TransparentFill(skia::AnalysisCanvas& canvas) { |
| 17 canvas.clear(SkColorSetARGB(0, 0, 0, 0)); | 17 canvas.clear(SkColorSetARGB(0, 0, 0, 0)); |
| 18 } | 18 } |
| 19 | 19 |
| 20 } // namespace | 20 } // namespace |
| 21 |
| 21 namespace skia { | 22 namespace skia { |
| 22 | 23 |
| 23 TEST(AnalysisCanvasTest, EmptyCanvas) { | 24 TEST(AnalysisCanvasTest, EmptyCanvas) { |
| 24 SkBitmap emptyBitmap; | 25 SkBitmap emptyBitmap; |
| 25 emptyBitmap.setConfig(SkBitmap::kNo_Config, 255, 255); | 26 emptyBitmap.setConfig(SkBitmap::kNo_Config, 255, 255); |
| 26 skia::AnalysisDevice device(emptyBitmap); | 27 skia::AnalysisDevice device(emptyBitmap); |
| 27 skia::AnalysisCanvas canvas(&device); | 28 skia::AnalysisCanvas canvas(&device); |
| 28 | 29 |
| 29 SkColor color; | 30 SkColor color; |
| 30 EXPECT_TRUE(canvas.GetColorIfSolid(&color)); | 31 EXPECT_TRUE(canvas.GetColorIfSolid(&color)); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 canvas.drawText(text, byteLength, point.fX, point.fY, paint); | 398 canvas.drawText(text, byteLength, point.fX, point.fY, paint); |
| 398 // Analysis device does not do any clipping. | 399 // Analysis device does not do any clipping. |
| 399 // So even when text is outside the clip region, | 400 // So even when text is outside the clip region, |
| 400 // it is marked as having the text. | 401 // it is marked as having the text. |
| 401 // TODO(alokp): We may be able to do some trivial rejection. | 402 // TODO(alokp): We may be able to do some trivial rejection. |
| 402 EXPECT_TRUE(canvas.HasText()); | 403 EXPECT_TRUE(canvas.HasText()); |
| 403 } | 404 } |
| 404 } | 405 } |
| 405 | 406 |
| 406 } // namespace skia | 407 } // namespace skia |
| OLD | NEW |