summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorweiliangc <weiliangc@chromium.org>2015-03-10 12:00:07 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-10 19:00:57 +0000
commitd048acf227321848bc9652c393b94ea80833fe14 (patch)
treeafa15e44b4a3e396b7533506e220fcd2af49f753
parent006770b2660d67edb61de77053b2c0117a6d6810 (diff)
downloadchromium_src-d048acf227321848bc9652c393b94ea80833fe14.zip
chromium_src-d048acf227321848bc9652c393b94ea80833fe14.tar.gz
chromium_src-d048acf227321848bc9652c393b94ea80833fe14.tar.bz2
Remove unittests based on wrong assumption of compositor
Once impl-side-painting is on, assumptions on |ui::LayerDelegate| regarding canvas size and scale reflecting exact damage rect and scale would no longer hold true. This removes unittests that are based on these assumptions. R=enne BUG=314185 Review URL: https://codereview.chromium.org/974603002 Cr-Commit-Position: refs/heads/master@{#319933}
-rw-r--r--ui/compositor/layer_unittest.cc71
1 files changed, 15 insertions, 56 deletions
diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc
index d64ac74..9ab5a14 100644
--- a/ui/compositor/layer_unittest.cc
+++ b/ui/compositor/layer_unittest.cc
@@ -218,26 +218,16 @@ class TestLayerDelegate : public LayerDelegate {
colors_.push_back(color);
}
- const gfx::Size& paint_size() const { return paint_size_; }
int color_index() const { return color_index_; }
- std::string ToScaleString() const {
- return base::StringPrintf("%.1f %.1f", scale_x_, scale_y_);
- }
-
float device_scale_factor() const {
return device_scale_factor_;
}
// Overridden from LayerDelegate:
void OnPaintLayer(gfx::Canvas* canvas) override {
- SkISize size = canvas->sk_canvas()->getBaseLayerSize();
- paint_size_ = gfx::Size(size.width(), size.height());
canvas->DrawColor(colors_[color_index_]);
color_index_ = (color_index_ + 1) % static_cast<int>(colors_.size());
- const SkMatrix& matrix = canvas->sk_canvas()->getTotalMatrix();
- scale_x_ = matrix.getScaleX();
- scale_y_ = matrix.getScaleY();
}
void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {}
@@ -252,17 +242,12 @@ class TestLayerDelegate : public LayerDelegate {
void reset() {
color_index_ = 0;
- paint_size_.SetSize(0, 0);
- scale_x_ = scale_y_ = 0.0f;
device_scale_factor_ = 0.0f;
}
private:
std::vector<SkColor> colors_;
int color_index_;
- gfx::Size paint_size_;
- float scale_x_;
- float scale_y_;
float device_scale_factor_;
DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate);
@@ -509,8 +494,11 @@ TEST_F(LayerWithDelegateTest, ConvertPointToLayer_Medium) {
}
TEST_F(LayerWithRealCompositorTest, Delegate) {
- scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorBLACK,
- gfx::Rect(20, 20, 400, 400)));
+ // This test makes sure that whenever paint happens at a layer, its layer
+ // delegate gets the paint, which in this test update its color and
+ // |color_index|.
+ scoped_ptr<Layer> l1(
+ CreateColorLayer(SK_ColorBLACK, gfx::Rect(20, 20, 400, 400)));
GetCompositor()->SetRootLayer(l1.get());
WaitForDraw();
@@ -522,19 +510,18 @@ TEST_F(LayerWithRealCompositorTest, Delegate) {
l1->SchedulePaint(gfx::Rect(0, 0, 400, 400));
WaitForDraw();
-
- EXPECT_EQ(delegate.color_index(), 1);
- EXPECT_EQ(delegate.paint_size(), l1->bounds().size());
+ // Test that paint happened at layer delegate.
+ EXPECT_EQ(1, delegate.color_index());
l1->SchedulePaint(gfx::Rect(10, 10, 200, 200));
WaitForDraw();
- EXPECT_EQ(delegate.color_index(), 2);
- EXPECT_EQ(delegate.paint_size(), gfx::Size(200, 200));
+ // Test that paint happened at layer delegate.
+ EXPECT_EQ(2, delegate.color_index());
l1->SchedulePaint(gfx::Rect(5, 5, 50, 50));
WaitForDraw();
- EXPECT_EQ(delegate.color_index(), 0);
- EXPECT_EQ(delegate.paint_size(), gfx::Size(50, 50));
+ // Test that paint happened at layer delegate.
+ EXPECT_EQ(0, delegate.color_index());
}
TEST_F(LayerWithRealCompositorTest, DrawTree) {
@@ -1308,9 +1295,6 @@ TEST_F(LayerWithRealCompositorTest, ScaleUpDown) {
EXPECT_EQ(0.0f, root_delegate.device_scale_factor());
EXPECT_EQ(0.0f, l1_delegate.device_scale_factor());
- EXPECT_EQ("200x220", root_delegate.paint_size().ToString());
- EXPECT_EQ("140x180", l1_delegate.paint_size().ToString());
-
// Scale up to 2.0. Changing scale doesn't change the bounds in DIP.
GetCompositor()->SetScaleAndSize(2.0f, gfx::Size(500, 500));
EXPECT_EQ("10,20 200x220", root->bounds().ToString());
@@ -1320,17 +1304,11 @@ TEST_F(LayerWithRealCompositorTest, ScaleUpDown) {
EXPECT_EQ("200x220", cc_bounds_size.ToString());
cc_bounds_size = l1->cc_layer()->bounds();
EXPECT_EQ("140x180", cc_bounds_size.ToString());
- // New scale factor must have been notified.
+ // New scale factor must have been notified. Make sure painting happens at
+ // right scale.
EXPECT_EQ(2.0f, root_delegate.device_scale_factor());
EXPECT_EQ(2.0f, l1_delegate.device_scale_factor());
- // Canvas size must have been scaled down up.
- WaitForDraw();
- EXPECT_EQ("400x440", root_delegate.paint_size().ToString());
- EXPECT_EQ("2.0 2.0", root_delegate.ToScaleString());
- EXPECT_EQ("280x360", l1_delegate.paint_size().ToString());
- EXPECT_EQ("2.0 2.0", l1_delegate.ToScaleString());
-
// Scale down back to 1.0f.
GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(500, 500));
EXPECT_EQ("10,20 200x220", root->bounds().ToString());
@@ -1340,17 +1318,11 @@ TEST_F(LayerWithRealCompositorTest, ScaleUpDown) {
EXPECT_EQ("200x220", cc_bounds_size.ToString());
cc_bounds_size = l1->cc_layer()->bounds();
EXPECT_EQ("140x180", cc_bounds_size.ToString());
- // New scale factor must have been notified.
+ // New scale factor must have been notified. Make sure painting happens at
+ // right scale.
EXPECT_EQ(1.0f, root_delegate.device_scale_factor());
EXPECT_EQ(1.0f, l1_delegate.device_scale_factor());
- // Canvas size must have been scaled down too.
- WaitForDraw();
- EXPECT_EQ("200x220", root_delegate.paint_size().ToString());
- EXPECT_EQ("1.0 1.0", root_delegate.ToScaleString());
- EXPECT_EQ("140x180", l1_delegate.paint_size().ToString());
- EXPECT_EQ("1.0 1.0", l1_delegate.ToScaleString());
-
root_delegate.reset();
l1_delegate.reset();
// Just changing the size shouldn't notify the scale change nor
@@ -1359,11 +1331,6 @@ TEST_F(LayerWithRealCompositorTest, ScaleUpDown) {
// No scale change, so no scale notification.
EXPECT_EQ(0.0f, root_delegate.device_scale_factor());
EXPECT_EQ(0.0f, l1_delegate.device_scale_factor());
- WaitForDraw();
- EXPECT_EQ("0x0", root_delegate.paint_size().ToString());
- EXPECT_EQ("0.0 0.0", root_delegate.ToScaleString());
- EXPECT_EQ("0x0", l1_delegate.paint_size().ToString());
- EXPECT_EQ("0.0 0.0", l1_delegate.ToScaleString());
}
TEST_F(LayerWithRealCompositorTest, ScaleReparent) {
@@ -1377,7 +1344,6 @@ TEST_F(LayerWithRealCompositorTest, ScaleReparent) {
GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(500, 500));
GetCompositor()->SetRootLayer(root.get());
- WaitForDraw();
root->Add(l1.get());
EXPECT_EQ("10,20 140x180", l1->bounds().ToString());
@@ -1385,10 +1351,6 @@ TEST_F(LayerWithRealCompositorTest, ScaleReparent) {
EXPECT_EQ("140x180", cc_bounds_size.ToString());
EXPECT_EQ(0.0f, l1_delegate.device_scale_factor());
- WaitForDraw();
- EXPECT_EQ("140x180", l1_delegate.paint_size().ToString());
- EXPECT_EQ("1.0 1.0", l1_delegate.ToScaleString());
-
// Remove l1 from root and change the scale.
root->Remove(l1.get());
EXPECT_EQ(NULL, l1->parent());
@@ -1404,9 +1366,6 @@ TEST_F(LayerWithRealCompositorTest, ScaleReparent) {
cc_bounds_size = l1->cc_layer()->bounds();
EXPECT_EQ("140x180", cc_bounds_size.ToString());
EXPECT_EQ(2.0f, l1_delegate.device_scale_factor());
- WaitForDraw();
- EXPECT_EQ("280x360", l1_delegate.paint_size().ToString());
- EXPECT_EQ("2.0 2.0", l1_delegate.ToScaleString());
}
// Verifies that when changing bounds on a layer that is invisible, and then