Index: cc/content_layer_unittest.cc |
diff --git a/cc/content_layer_unittest.cc b/cc/content_layer_unittest.cc |
index c7f32bec60fd0d7cf6726a59c3f7f9ac6db5b520..3ed6fcee1561f92a7ae5a85d870c974da80e8932 100644 |
--- a/cc/content_layer_unittest.cc |
+++ b/cc/content_layer_unittest.cc |
@@ -7,6 +7,7 @@ |
#include "cc/bitmap_content_layer_updater.h" |
#include "cc/content_layer_client.h" |
#include "cc/rendering_stats.h" |
+#include "cc/resource_update_queue.h" |
#include "cc/test/geometry_test_utils.h" |
#include "skia/ext/platform_canvas.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -17,6 +18,15 @@ using namespace WebKit; |
namespace cc { |
namespace { |
+class FakeContentLayer : public ContentLayer { |
+public: |
+ explicit FakeContentLayer(ContentLayerClient* client) : ContentLayer(client) { } |
+ |
+protected: |
+ virtual ~FakeContentLayer() { } |
+ virtual void createUpdaterIfNeeded() OVERRIDE { } |
+}; |
+ |
class MockContentLayerClient : public ContentLayerClient { |
public: |
explicit MockContentLayerClient(gfx::Rect opaqueLayerRect) |
@@ -49,5 +59,49 @@ TEST(ContentLayerTest, ContentLayerPainterWithDeviceScale) |
EXPECT_RECT_EQ(gfx::ToEnclosingRect(opaqueRectInContentSpace), resultingOpaqueRect); |
} |
+TEST(ContentLayerTest, CanUseLCDTextEnableCount) |
+{ |
+ scoped_refptr<FakeContentLayer> layer = new FakeContentLayer(NULL); |
+ |
+ // By default LCD text is disabled. |
+ EXPECT_FALSE(layer->canUseLCDText()); |
+ |
+ // LCD text can be enabled once. |
+ layer->setCanUseLCDText(true); |
+ EXPECT_TRUE(layer->canUseLCDText()); |
+ |
+ // LCD text can always be disabled. |
+ layer->setCanUseLCDText(false); |
+ EXPECT_FALSE(layer->canUseLCDText()); |
+ |
+ // LCD text cannot be enabled anymore. |
+ layer->setCanUseLCDText(true); |
+ EXPECT_FALSE(layer->canUseLCDText()); |
+} |
+ |
+TEST(ContentLayerTest, CanUseLCDTextChangeTriggersRepaint) |
+{ |
+ scoped_refptr<FakeContentLayer> layer = new FakeContentLayer(NULL); |
+ layer->setBounds(gfx::Size(100, 100)); |
+ ResourceUpdateQueue queue; |
+ RenderingStats stats; |
+ // Reset needsDisplay bit. |
+ layer->update(queue, NULL, stats); |
+ EXPECT_FALSE(layer->canUseLCDText()); |
+ EXPECT_FALSE(layer->needsDisplay()); |
+ |
+ layer->setCanUseLCDText(true); |
+ EXPECT_TRUE(layer->canUseLCDText()); |
+ EXPECT_TRUE(layer->needsDisplay()); |
+ |
+ // Reset needsDisplay bit. |
+ layer->update(queue, NULL, stats); |
+ EXPECT_FALSE(layer->needsDisplay()); |
+ |
+ layer->setCanUseLCDText(false); |
+ EXPECT_FALSE(layer->canUseLCDText()); |
+ EXPECT_TRUE(layer->needsDisplay()); |
+} |
+ |
} // namespace |
} // namespace cc |