Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Unified Diff: cc/layers/picture_image_layer_impl_unittest.cc

Issue 12954006: Let AreVisibleResourcesReady return correct value for PictureImageLayerImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layers/picture_image_layer_impl.cc ('k') | cc/layers/picture_layer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/picture_image_layer_impl_unittest.cc
diff --git a/cc/layers/picture_image_layer_impl_unittest.cc b/cc/layers/picture_image_layer_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5e8b1d82fd601634acd3bf9740df2c2a14420b84
--- /dev/null
+++ b/cc/layers/picture_image_layer_impl_unittest.cc
@@ -0,0 +1,81 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/layers/picture_image_layer_impl.h"
+
+#include "cc/test/fake_impl_proxy.h"
+#include "cc/test/fake_layer_tree_host_impl.h"
+#include "cc/test/fake_output_surface.h"
+#include "cc/test/fake_picture_layer_tiling_client.h"
+#include "cc/test/impl_side_painting_settings.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cc {
+namespace {
+
+class TestablePictureImageLayerImpl : public PictureImageLayerImpl {
+ public:
+ TestablePictureImageLayerImpl(LayerTreeImpl* tree_impl, int id)
+ : PictureImageLayerImpl(tree_impl, id) {
+ }
+ friend class PictureImageLayerImplTest;
+};
+
+class PictureImageLayerImplTest : public testing::Test {
+ public:
+ PictureImageLayerImplTest()
+ : host_impl_(ImplSidePaintingSettings(), &proxy_) {
+ tiling_client_.SetTileSize(ImplSidePaintingSettings().default_tile_size);
+ host_impl_.CreatePendingTree();
+ host_impl_.InitializeRenderer(CreateFakeOutputSurface());
+ }
+
+ scoped_ptr<TestablePictureImageLayerImpl> CreateLayer(int id) {
+ TestablePictureImageLayerImpl* layer =
+ new TestablePictureImageLayerImpl(host_impl_.pending_tree(), id);
+ layer->SetBounds(gfx::Size(100, 200));
+ layer->tilings_.reset(new PictureLayerTilingSet(&tiling_client_));
+ layer->tilings_->SetLayerBounds(layer->bounds());
+ layer->pile_ = tiling_client_.pile();
+ return make_scoped_ptr(layer);
+ }
+
+ private:
+ FakeImplProxy proxy_;
+ FakeLayerTreeHostImpl host_impl_;
+ FakePictureLayerTilingClient tiling_client_;
+};
+
+TEST_F(PictureImageLayerImplTest, CalculateContentsScale) {
+ scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1));
+ layer->SetDrawsContent(true);
+
+ float contents_scale_x;
+ float contents_scale_y;
+ gfx::Size content_bounds;
+ layer->CalculateContentsScale(2.f, false,
+ &contents_scale_x, &contents_scale_y,
+ &content_bounds);
+ EXPECT_FLOAT_EQ(1.f, contents_scale_x);
+ EXPECT_FLOAT_EQ(1.f, contents_scale_y);
+ EXPECT_EQ(layer->bounds(), content_bounds);
+}
+
+TEST_F(PictureImageLayerImplTest, AreVisibleResourcesReady) {
+ scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1));
+ layer->SetBounds(gfx::Size(100, 200));
+ layer->SetDrawsContent(true);
+
+ float contents_scale_x;
+ float contents_scale_y;
+ gfx::Size content_bounds;
+ layer->CalculateContentsScale(2.f, false,
+ &contents_scale_x, &contents_scale_y,
+ &content_bounds);
+
+ EXPECT_TRUE(layer->AreVisibleResourcesReady());
+}
+
+} // namespace
+} // namespace cc
« no previous file with comments | « cc/layers/picture_image_layer_impl.cc ('k') | cc/layers/picture_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698