| 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 <map> | 5 #include <map> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "cc/resources/picture_pile.h" | 8 #include "cc/resources/picture_pile.h" |
| 9 #include "cc/test/fake_content_layer_client.h" | 9 #include "cc/test/fake_content_layer_client.h" |
| 10 #include "cc/test/fake_picture_pile.h" | 10 #include "cc/test/fake_picture_pile.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/gfx/geometry/rect_conversions.h" | 12 #include "ui/gfx/geometry/rect_conversions.h" |
| 13 #include "ui/gfx/geometry/size_conversions.h" | 13 #include "ui/gfx/geometry/size_conversions.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 class PicturePileTestBase { | 18 class PicturePileTestBase { |
| 19 public: | 19 public: |
| 20 PicturePileTestBase() | 20 PicturePileTestBase() : min_scale_(0.125), frame_number_(0) {} |
| 21 : min_scale_(0.125), | |
| 22 pile_(min_scale_, gfx::Size(1000, 1000)), | |
| 23 frame_number_(0) {} | |
| 24 | 21 |
| 25 void InitializeData() { | 22 void InitializeData() { |
| 26 pile_.SetTileGridSize(gfx::Size(1000, 1000)); | 23 pile_.SetTileGridSize(gfx::Size(1000, 1000)); |
| 27 pile_.SetMinContentsScale(min_scale_); | 24 pile_.SetMinContentsScale(min_scale_); |
| 28 client_ = FakeContentLayerClient(); | 25 client_ = FakeContentLayerClient(); |
| 29 SetTilingSize(pile_.tiling().max_texture_size()); | 26 SetTilingSize(pile_.tiling().max_texture_size()); |
| 30 } | 27 } |
| 31 | 28 |
| 32 void SetTilingSize(const gfx::Size& tiling_size) { | 29 void SetTilingSize(const gfx::Size& tiling_size) { |
| 33 Region invalidation; | 30 Region invalidation; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 48 } | 45 } |
| 49 | 46 |
| 50 bool UpdateWholePile() { | 47 bool UpdateWholePile() { |
| 51 Region invalidation = tiling_rect(); | 48 Region invalidation = tiling_rect(); |
| 52 bool result = UpdateAndExpandInvalidation(&invalidation, tiling_size(), | 49 bool result = UpdateAndExpandInvalidation(&invalidation, tiling_size(), |
| 53 tiling_rect()); | 50 tiling_rect()); |
| 54 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); | 51 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); |
| 55 return result; | 52 return result; |
| 56 } | 53 } |
| 57 | 54 |
| 58 float min_scale_; | |
| 59 FakeContentLayerClient client_; | 55 FakeContentLayerClient client_; |
| 60 FakePicturePile pile_; | 56 FakePicturePile pile_; |
| 57 float min_scale_; |
| 61 int frame_number_; | 58 int frame_number_; |
| 62 }; | 59 }; |
| 63 | 60 |
| 64 class PicturePileTest : public PicturePileTestBase, public testing::Test { | 61 class PicturePileTest : public PicturePileTestBase, public testing::Test { |
| 65 public: | 62 public: |
| 66 void SetUp() override { InitializeData(); } | 63 void SetUp() override { InitializeData(); } |
| 67 }; | 64 }; |
| 68 | 65 |
| 69 TEST_F(PicturePileTest, InvalidationOnTileBorderOutsideInterestRect) { | 66 TEST_F(PicturePileTest, InvalidationOnTileBorderOutsideInterestRect) { |
| 70 // Don't expand the interest rect past what we invalidate. | 67 // Don't expand the interest rect past what we invalidate. |
| (...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 EXPECT_TRUE(pile_.HasRecordings()); | 1535 EXPECT_TRUE(pile_.HasRecordings()); |
| 1539 pile_.SetEmptyBounds(); | 1536 pile_.SetEmptyBounds(); |
| 1540 EXPECT_FALSE(pile_.is_solid_color()); | 1537 EXPECT_FALSE(pile_.is_solid_color()); |
| 1541 EXPECT_TRUE(pile_.GetSize().IsEmpty()); | 1538 EXPECT_TRUE(pile_.GetSize().IsEmpty()); |
| 1542 EXPECT_TRUE(pile_.picture_map().empty()); | 1539 EXPECT_TRUE(pile_.picture_map().empty()); |
| 1543 EXPECT_FALSE(pile_.HasRecordings()); | 1540 EXPECT_FALSE(pile_.HasRecordings()); |
| 1544 } | 1541 } |
| 1545 | 1542 |
| 1546 } // namespace | 1543 } // namespace |
| 1547 } // namespace cc | 1544 } // namespace cc |
| OLD | NEW |