| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "ppapi/tests/test_paint_aggregator.h" | 5 #include "ppapi/tests/test_paint_aggregator.h" |
| 6 | 6 |
| 7 #include "ppapi/cpp/paint_aggregator.h" | 7 #include "ppapi/cpp/paint_aggregator.h" |
| 8 #include "ppapi/tests/testing_instance.h" | 8 #include "ppapi/tests/testing_instance.h" |
| 9 | 9 |
| 10 REGISTER_TEST_CASE(PaintAggregator); | 10 REGISTER_TEST_CASE(PaintAggregator); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 RUN_TEST(ContainedPaintTrimmedByScroll); | 33 RUN_TEST(ContainedPaintTrimmedByScroll); |
| 34 RUN_TEST(ContainedPaintEliminatedByScroll); | 34 RUN_TEST(ContainedPaintEliminatedByScroll); |
| 35 RUN_TEST(ContainedPaintAfterScrollTrimmedByScrollDamage); | 35 RUN_TEST(ContainedPaintAfterScrollTrimmedByScrollDamage); |
| 36 RUN_TEST(ContainedPaintAfterScrollEliminatedByScrollDamage); | 36 RUN_TEST(ContainedPaintAfterScrollEliminatedByScrollDamage); |
| 37 } | 37 } |
| 38 | 38 |
| 39 std::string TestPaintAggregator::TestInitialState() { | 39 std::string TestPaintAggregator::TestInitialState() { |
| 40 pp::PaintAggregator greg; | 40 pp::PaintAggregator greg; |
| 41 if (greg.HasPendingUpdate()) | 41 if (greg.HasPendingUpdate()) |
| 42 return "Pending update invalid"; | 42 return "Pending update invalid"; |
| 43 return std::string(); | 43 PASS(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 std::string TestPaintAggregator::TestSingleInvalidation() { | 46 std::string TestPaintAggregator::TestSingleInvalidation() { |
| 47 pp::PaintAggregator greg; | 47 pp::PaintAggregator greg; |
| 48 | 48 |
| 49 pp::Rect rect(2, 4, 10, 16); | 49 pp::Rect rect(2, 4, 10, 16); |
| 50 greg.InvalidateRect(rect); | 50 greg.InvalidateRect(rect); |
| 51 | 51 |
| 52 ASSERT_TRUE(greg.HasPendingUpdate()); | 52 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 53 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 53 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 54 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); | 54 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); |
| 55 | 55 |
| 56 ASSERT_TRUE(rect == greg.GetPendingUpdate().paint_rects[0]); | 56 ASSERT_TRUE(rect == greg.GetPendingUpdate().paint_rects[0]); |
| 57 | 57 |
| 58 return std::string(); | 58 PASS(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 std::string TestPaintAggregator::TestDoubleDisjointInvalidation() { | 61 std::string TestPaintAggregator::TestDoubleDisjointInvalidation() { |
| 62 pp::PaintAggregator greg; | 62 pp::PaintAggregator greg; |
| 63 | 63 |
| 64 pp::Rect r1(2, 4, 2, 4); | 64 pp::Rect r1(2, 4, 2, 4); |
| 65 pp::Rect r2(4, 2, 4, 2); | 65 pp::Rect r2(4, 2, 4, 2); |
| 66 | 66 |
| 67 greg.InvalidateRect(r1); | 67 greg.InvalidateRect(r1); |
| 68 greg.InvalidateRect(r2); | 68 greg.InvalidateRect(r2); |
| 69 | 69 |
| 70 pp::Rect expected_bounds = r1.Union(r2); | 70 pp::Rect expected_bounds = r1.Union(r2); |
| 71 | 71 |
| 72 ASSERT_TRUE(greg.HasPendingUpdate()); | 72 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 73 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 73 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 74 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); | 74 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); |
| 75 | 75 |
| 76 ASSERT_TRUE(expected_bounds == greg.GetPendingUpdate().paint_bounds); | 76 ASSERT_TRUE(expected_bounds == greg.GetPendingUpdate().paint_bounds); |
| 77 return std::string(); | 77 PASS(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 std::string TestPaintAggregator::TestSingleScroll() { | 80 std::string TestPaintAggregator::TestSingleScroll() { |
| 81 pp::PaintAggregator greg; | 81 pp::PaintAggregator greg; |
| 82 | 82 |
| 83 pp::Rect r1(2, 4, 2, 4); | 83 pp::Rect r1(2, 4, 2, 4); |
| 84 pp::Rect r2(4, 2, 4, 2); | 84 pp::Rect r2(4, 2, 4, 2); |
| 85 | 85 |
| 86 greg.InvalidateRect(r1); | 86 greg.InvalidateRect(r1); |
| 87 greg.InvalidateRect(r2); | 87 greg.InvalidateRect(r2); |
| 88 | 88 |
| 89 pp::Rect expected_bounds = r1.Union(r2); | 89 pp::Rect expected_bounds = r1.Union(r2); |
| 90 | 90 |
| 91 ASSERT_TRUE(greg.HasPendingUpdate()); | 91 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 92 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 92 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 93 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); | 93 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); |
| 94 | 94 |
| 95 ASSERT_TRUE(expected_bounds == greg.GetPendingUpdate().paint_bounds); | 95 ASSERT_TRUE(expected_bounds == greg.GetPendingUpdate().paint_bounds); |
| 96 return std::string(); | 96 PASS(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 std::string TestPaintAggregator::TestDoubleOverlappingScroll() { | 99 std::string TestPaintAggregator::TestDoubleOverlappingScroll() { |
| 100 pp::PaintAggregator greg; | 100 pp::PaintAggregator greg; |
| 101 | 101 |
| 102 pp::Rect rect(1, 2, 3, 4); | 102 pp::Rect rect(1, 2, 3, 4); |
| 103 pp::Point delta1(1, 0); | 103 pp::Point delta1(1, 0); |
| 104 pp::Point delta2(1, 0); | 104 pp::Point delta2(1, 0); |
| 105 greg.ScrollRect(rect, delta1); | 105 greg.ScrollRect(rect, delta1); |
| 106 greg.ScrollRect(rect, delta2); | 106 greg.ScrollRect(rect, delta2); |
| 107 | 107 |
| 108 ASSERT_TRUE(greg.HasPendingUpdate()); | 108 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 109 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); | 109 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); |
| 110 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 110 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 111 | 111 |
| 112 ASSERT_TRUE(rect == greg.GetPendingUpdate().scroll_rect); | 112 ASSERT_TRUE(rect == greg.GetPendingUpdate().scroll_rect); |
| 113 | 113 |
| 114 pp::Point expected_delta(delta1.x() + delta2.x(), | 114 pp::Point expected_delta(delta1.x() + delta2.x(), |
| 115 delta1.y() + delta2.y()); | 115 delta1.y() + delta2.y()); |
| 116 ASSERT_TRUE(expected_delta.x() == greg.GetPendingUpdate().scroll_delta.x()); | 116 ASSERT_TRUE(expected_delta.x() == greg.GetPendingUpdate().scroll_delta.x()); |
| 117 ASSERT_TRUE(expected_delta.y() == greg.GetPendingUpdate().scroll_delta.y()); | 117 ASSERT_TRUE(expected_delta.y() == greg.GetPendingUpdate().scroll_delta.y()); |
| 118 | 118 |
| 119 pp::Rect resulting_damage = greg.GetPendingUpdate().paint_rects[0]; | 119 pp::Rect resulting_damage = greg.GetPendingUpdate().paint_rects[0]; |
| 120 pp::Rect expected_damage(1, 2, 2, 4); | 120 pp::Rect expected_damage(1, 2, 2, 4); |
| 121 ASSERT_TRUE(expected_damage == resulting_damage); | 121 ASSERT_TRUE(expected_damage == resulting_damage); |
| 122 return std::string(); | 122 PASS(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 std::string TestPaintAggregator::TestNegatingScroll() { | 125 std::string TestPaintAggregator::TestNegatingScroll() { |
| 126 pp::PaintAggregator greg; | 126 pp::PaintAggregator greg; |
| 127 | 127 |
| 128 // Scroll twice in opposite directions by equal amounts. The result | 128 // Scroll twice in opposite directions by equal amounts. The result |
| 129 // should be no scrolling. | 129 // should be no scrolling. |
| 130 | 130 |
| 131 pp::Rect rect(1, 2, 3, 4); | 131 pp::Rect rect(1, 2, 3, 4); |
| 132 pp::Point delta1(1, 0); | 132 pp::Point delta1(1, 0); |
| 133 pp::Point delta2(-1, 0); | 133 pp::Point delta2(-1, 0); |
| 134 greg.ScrollRect(rect, delta1); | 134 greg.ScrollRect(rect, delta1); |
| 135 greg.ScrollRect(rect, delta2); | 135 greg.ScrollRect(rect, delta2); |
| 136 | 136 |
| 137 ASSERT_FALSE(greg.HasPendingUpdate()); | 137 ASSERT_FALSE(greg.HasPendingUpdate()); |
| 138 return std::string(); | 138 PASS(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 std::string TestPaintAggregator::TestDiagonalScroll() { | 141 std::string TestPaintAggregator::TestDiagonalScroll() { |
| 142 pp::PaintAggregator greg; | 142 pp::PaintAggregator greg; |
| 143 | 143 |
| 144 // We don't support optimized diagonal scrolling, so this should result in | 144 // We don't support optimized diagonal scrolling, so this should result in |
| 145 // repainting. | 145 // repainting. |
| 146 | 146 |
| 147 pp::Rect rect(1, 2, 3, 4); | 147 pp::Rect rect(1, 2, 3, 4); |
| 148 pp::Point delta(1, 1); | 148 pp::Point delta(1, 1); |
| 149 greg.ScrollRect(rect, delta); | 149 greg.ScrollRect(rect, delta); |
| 150 | 150 |
| 151 ASSERT_TRUE(greg.HasPendingUpdate()); | 151 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 152 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 152 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 153 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); | 153 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); |
| 154 | 154 |
| 155 ASSERT_TRUE(rect == greg.GetPendingUpdate().paint_rects[0]); | 155 ASSERT_TRUE(rect == greg.GetPendingUpdate().paint_rects[0]); |
| 156 return std::string(); | 156 PASS(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 std::string TestPaintAggregator::TestContainedPaintAfterScroll() { | 159 std::string TestPaintAggregator::TestContainedPaintAfterScroll() { |
| 160 pp::PaintAggregator greg; | 160 pp::PaintAggregator greg; |
| 161 | 161 |
| 162 pp::Rect scroll_rect(0, 0, 10, 10); | 162 pp::Rect scroll_rect(0, 0, 10, 10); |
| 163 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); | 163 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); |
| 164 | 164 |
| 165 pp::Rect paint_rect(4, 4, 2, 2); | 165 pp::Rect paint_rect(4, 4, 2, 2); |
| 166 greg.InvalidateRect(paint_rect); | 166 greg.InvalidateRect(paint_rect); |
| 167 | 167 |
| 168 ASSERT_TRUE(greg.HasPendingUpdate()); | 168 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 169 | 169 |
| 170 // Expecting a paint rect inside the scroll rect. The last paint rect is the | 170 // Expecting a paint rect inside the scroll rect. The last paint rect is the |
| 171 // scroll dirty rect. | 171 // scroll dirty rect. |
| 172 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 172 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 173 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); | 173 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); |
| 174 | 174 |
| 175 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); | 175 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); |
| 176 ASSERT_TRUE(paint_rect == greg.GetPendingUpdate().paint_rects[0]); | 176 ASSERT_TRUE(paint_rect == greg.GetPendingUpdate().paint_rects[0]); |
| 177 return std::string(); | 177 PASS(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 std::string TestPaintAggregator::TestContainedPaintBeforeScroll() { | 180 std::string TestPaintAggregator::TestContainedPaintBeforeScroll() { |
| 181 pp::PaintAggregator greg; | 181 pp::PaintAggregator greg; |
| 182 | 182 |
| 183 pp::Rect paint_rect(4, 4, 2, 2); | 183 pp::Rect paint_rect(4, 4, 2, 2); |
| 184 greg.InvalidateRect(paint_rect); | 184 greg.InvalidateRect(paint_rect); |
| 185 | 185 |
| 186 pp::Rect scroll_rect(0, 0, 10, 10); | 186 pp::Rect scroll_rect(0, 0, 10, 10); |
| 187 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); | 187 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); |
| 188 | 188 |
| 189 ASSERT_TRUE(greg.HasPendingUpdate()); | 189 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 190 | 190 |
| 191 // Expecting a paint rect inside the scroll rect. The last paint rect is the | 191 // Expecting a paint rect inside the scroll rect. The last paint rect is the |
| 192 // scroll dirty rect. | 192 // scroll dirty rect. |
| 193 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 193 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 194 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); | 194 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); |
| 195 | 195 |
| 196 paint_rect.Offset(2, 0); | 196 paint_rect.Offset(2, 0); |
| 197 | 197 |
| 198 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); | 198 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); |
| 199 ASSERT_TRUE(paint_rect == greg.GetPendingUpdate().paint_rects[0]); | 199 ASSERT_TRUE(paint_rect == greg.GetPendingUpdate().paint_rects[0]); |
| 200 return std::string(); | 200 PASS(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 std::string TestPaintAggregator::TestContainedPaintsBeforeAndAfterScroll() { | 203 std::string TestPaintAggregator::TestContainedPaintsBeforeAndAfterScroll() { |
| 204 pp::PaintAggregator greg; | 204 pp::PaintAggregator greg; |
| 205 | 205 |
| 206 pp::Rect paint_rect1(4, 4, 2, 2); | 206 pp::Rect paint_rect1(4, 4, 2, 2); |
| 207 greg.InvalidateRect(paint_rect1); | 207 greg.InvalidateRect(paint_rect1); |
| 208 | 208 |
| 209 pp::Rect scroll_rect(0, 0, 10, 10); | 209 pp::Rect scroll_rect(0, 0, 10, 10); |
| 210 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); | 210 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); |
| 211 | 211 |
| 212 pp::Rect paint_rect2(6, 4, 2, 2); | 212 pp::Rect paint_rect2(6, 4, 2, 2); |
| 213 greg.InvalidateRect(paint_rect2); | 213 greg.InvalidateRect(paint_rect2); |
| 214 | 214 |
| 215 pp::Rect expected_paint_rect = paint_rect2; | 215 pp::Rect expected_paint_rect = paint_rect2; |
| 216 | 216 |
| 217 ASSERT_TRUE(greg.HasPendingUpdate()); | 217 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 218 | 218 |
| 219 // Expecting a paint rect inside the scroll rect | 219 // Expecting a paint rect inside the scroll rect |
| 220 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 220 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 221 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); | 221 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); |
| 222 | 222 |
| 223 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); | 223 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); |
| 224 ASSERT_TRUE(expected_paint_rect == greg.GetPendingUpdate().paint_rects[0]); | 224 ASSERT_TRUE(expected_paint_rect == greg.GetPendingUpdate().paint_rects[0]); |
| 225 return std::string(); | 225 PASS(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 std::string TestPaintAggregator::TestLargeContainedPaintAfterScroll() { | 228 std::string TestPaintAggregator::TestLargeContainedPaintAfterScroll() { |
| 229 pp::PaintAggregator greg; | 229 pp::PaintAggregator greg; |
| 230 | 230 |
| 231 pp::Rect scroll_rect(0, 0, 10, 10); | 231 pp::Rect scroll_rect(0, 0, 10, 10); |
| 232 greg.ScrollRect(scroll_rect, pp::Point(0, 1)); | 232 greg.ScrollRect(scroll_rect, pp::Point(0, 1)); |
| 233 | 233 |
| 234 pp::Rect paint_rect(0, 0, 10, 9); // Repaint 90% | 234 pp::Rect paint_rect(0, 0, 10, 9); // Repaint 90% |
| 235 greg.InvalidateRect(paint_rect); | 235 greg.InvalidateRect(paint_rect); |
| 236 | 236 |
| 237 ASSERT_TRUE(greg.HasPendingUpdate()); | 237 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 238 | 238 |
| 239 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 239 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 240 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); | 240 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); |
| 241 | 241 |
| 242 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().paint_rects[0]); | 242 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().paint_rects[0]); |
| 243 return std::string(); | 243 PASS(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 std::string TestPaintAggregator::TestLargeContainedPaintBeforeScroll() { | 246 std::string TestPaintAggregator::TestLargeContainedPaintBeforeScroll() { |
| 247 pp::PaintAggregator greg; | 247 pp::PaintAggregator greg; |
| 248 | 248 |
| 249 pp::Rect paint_rect(0, 0, 10, 9); // Repaint 90% | 249 pp::Rect paint_rect(0, 0, 10, 9); // Repaint 90% |
| 250 greg.InvalidateRect(paint_rect); | 250 greg.InvalidateRect(paint_rect); |
| 251 | 251 |
| 252 pp::Rect scroll_rect(0, 0, 10, 10); | 252 pp::Rect scroll_rect(0, 0, 10, 10); |
| 253 greg.ScrollRect(scroll_rect, pp::Point(0, 1)); | 253 greg.ScrollRect(scroll_rect, pp::Point(0, 1)); |
| 254 | 254 |
| 255 ASSERT_TRUE(greg.HasPendingUpdate()); | 255 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 256 | 256 |
| 257 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 257 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 258 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); | 258 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); |
| 259 | 259 |
| 260 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().paint_rects[0]); | 260 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().paint_rects[0]); |
| 261 return std::string(); | 261 PASS(); |
| 262 } | 262 } |
| 263 | 263 |
| 264 std::string TestPaintAggregator::TestOverlappingPaintBeforeScroll() { | 264 std::string TestPaintAggregator::TestOverlappingPaintBeforeScroll() { |
| 265 pp::PaintAggregator greg; | 265 pp::PaintAggregator greg; |
| 266 | 266 |
| 267 pp::Rect paint_rect(4, 4, 10, 2); | 267 pp::Rect paint_rect(4, 4, 10, 2); |
| 268 greg.InvalidateRect(paint_rect); | 268 greg.InvalidateRect(paint_rect); |
| 269 | 269 |
| 270 pp::Rect scroll_rect(0, 0, 10, 10); | 270 pp::Rect scroll_rect(0, 0, 10, 10); |
| 271 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); | 271 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); |
| 272 | 272 |
| 273 pp::Rect expected_paint_rect = scroll_rect.Union(paint_rect); | 273 pp::Rect expected_paint_rect = scroll_rect.Union(paint_rect); |
| 274 | 274 |
| 275 ASSERT_TRUE(greg.HasPendingUpdate()); | 275 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 276 | 276 |
| 277 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 277 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 278 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); | 278 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); |
| 279 | 279 |
| 280 ASSERT_TRUE(expected_paint_rect == greg.GetPendingUpdate().paint_rects[0]); | 280 ASSERT_TRUE(expected_paint_rect == greg.GetPendingUpdate().paint_rects[0]); |
| 281 return std::string(); | 281 PASS(); |
| 282 } | 282 } |
| 283 | 283 |
| 284 std::string TestPaintAggregator::TestOverlappingPaintAfterScroll() { | 284 std::string TestPaintAggregator::TestOverlappingPaintAfterScroll() { |
| 285 pp::PaintAggregator greg; | 285 pp::PaintAggregator greg; |
| 286 | 286 |
| 287 pp::Rect scroll_rect(0, 0, 10, 10); | 287 pp::Rect scroll_rect(0, 0, 10, 10); |
| 288 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); | 288 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); |
| 289 | 289 |
| 290 pp::Rect paint_rect(4, 4, 10, 2); | 290 pp::Rect paint_rect(4, 4, 10, 2); |
| 291 greg.InvalidateRect(paint_rect); | 291 greg.InvalidateRect(paint_rect); |
| 292 | 292 |
| 293 pp::Rect expected_paint_rect = scroll_rect.Union(paint_rect); | 293 pp::Rect expected_paint_rect = scroll_rect.Union(paint_rect); |
| 294 | 294 |
| 295 ASSERT_TRUE(greg.HasPendingUpdate()); | 295 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 296 | 296 |
| 297 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 297 ASSERT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 298 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); | 298 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); |
| 299 | 299 |
| 300 ASSERT_TRUE(expected_paint_rect == greg.GetPendingUpdate().paint_rects[0]); | 300 ASSERT_TRUE(expected_paint_rect == greg.GetPendingUpdate().paint_rects[0]); |
| 301 return std::string(); | 301 PASS(); |
| 302 } | 302 } |
| 303 | 303 |
| 304 std::string TestPaintAggregator::TestDisjointPaintBeforeScroll() { | 304 std::string TestPaintAggregator::TestDisjointPaintBeforeScroll() { |
| 305 pp::PaintAggregator greg; | 305 pp::PaintAggregator greg; |
| 306 | 306 |
| 307 pp::Rect paint_rect(4, 4, 10, 2); | 307 pp::Rect paint_rect(4, 4, 10, 2); |
| 308 greg.InvalidateRect(paint_rect); | 308 greg.InvalidateRect(paint_rect); |
| 309 | 309 |
| 310 pp::Rect scroll_rect(0, 0, 2, 10); | 310 pp::Rect scroll_rect(0, 0, 2, 10); |
| 311 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); | 311 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); |
| 312 | 312 |
| 313 ASSERT_TRUE(greg.HasPendingUpdate()); | 313 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 314 | 314 |
| 315 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 315 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 316 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); | 316 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); |
| 317 | 317 |
| 318 ASSERT_TRUE(paint_rect == greg.GetPendingUpdate().paint_rects[0]); | 318 ASSERT_TRUE(paint_rect == greg.GetPendingUpdate().paint_rects[0]); |
| 319 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); | 319 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); |
| 320 return std::string(); | 320 PASS(); |
| 321 } | 321 } |
| 322 | 322 |
| 323 std::string TestPaintAggregator::TestDisjointPaintAfterScroll() { | 323 std::string TestPaintAggregator::TestDisjointPaintAfterScroll() { |
| 324 pp::PaintAggregator greg; | 324 pp::PaintAggregator greg; |
| 325 | 325 |
| 326 pp::Rect scroll_rect(0, 0, 2, 10); | 326 pp::Rect scroll_rect(0, 0, 2, 10); |
| 327 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); | 327 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); |
| 328 | 328 |
| 329 pp::Rect paint_rect(4, 4, 10, 2); | 329 pp::Rect paint_rect(4, 4, 10, 2); |
| 330 greg.InvalidateRect(paint_rect); | 330 greg.InvalidateRect(paint_rect); |
| 331 | 331 |
| 332 ASSERT_TRUE(greg.HasPendingUpdate()); | 332 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 333 | 333 |
| 334 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 334 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 335 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); | 335 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); |
| 336 | 336 |
| 337 ASSERT_TRUE(paint_rect == greg.GetPendingUpdate().paint_rects[0]); | 337 ASSERT_TRUE(paint_rect == greg.GetPendingUpdate().paint_rects[0]); |
| 338 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); | 338 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); |
| 339 return std::string(); | 339 PASS(); |
| 340 } | 340 } |
| 341 | 341 |
| 342 std::string TestPaintAggregator::TestContainedPaintTrimmedByScroll() { | 342 std::string TestPaintAggregator::TestContainedPaintTrimmedByScroll() { |
| 343 pp::PaintAggregator greg; | 343 pp::PaintAggregator greg; |
| 344 | 344 |
| 345 pp::Rect paint_rect(4, 4, 6, 6); | 345 pp::Rect paint_rect(4, 4, 6, 6); |
| 346 greg.InvalidateRect(paint_rect); | 346 greg.InvalidateRect(paint_rect); |
| 347 | 347 |
| 348 pp::Rect scroll_rect(0, 0, 10, 10); | 348 pp::Rect scroll_rect(0, 0, 10, 10); |
| 349 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); | 349 greg.ScrollRect(scroll_rect, pp::Point(2, 0)); |
| 350 | 350 |
| 351 // The paint rect should have become narrower. | 351 // The paint rect should have become narrower. |
| 352 pp::Rect expected_paint_rect(6, 4, 4, 6); | 352 pp::Rect expected_paint_rect(6, 4, 4, 6); |
| 353 | 353 |
| 354 ASSERT_TRUE(greg.HasPendingUpdate()); | 354 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 355 | 355 |
| 356 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 356 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 357 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); | 357 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); |
| 358 | 358 |
| 359 ASSERT_TRUE(expected_paint_rect == greg.GetPendingUpdate().paint_rects[0]); | 359 ASSERT_TRUE(expected_paint_rect == greg.GetPendingUpdate().paint_rects[0]); |
| 360 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); | 360 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); |
| 361 return std::string(); | 361 PASS(); |
| 362 } | 362 } |
| 363 | 363 |
| 364 std::string TestPaintAggregator::TestContainedPaintEliminatedByScroll() { | 364 std::string TestPaintAggregator::TestContainedPaintEliminatedByScroll() { |
| 365 pp::PaintAggregator greg; | 365 pp::PaintAggregator greg; |
| 366 | 366 |
| 367 pp::Rect paint_rect(4, 4, 6, 6); | 367 pp::Rect paint_rect(4, 4, 6, 6); |
| 368 greg.InvalidateRect(paint_rect); | 368 greg.InvalidateRect(paint_rect); |
| 369 | 369 |
| 370 pp::Rect scroll_rect(0, 0, 10, 10); | 370 pp::Rect scroll_rect(0, 0, 10, 10); |
| 371 greg.ScrollRect(scroll_rect, pp::Point(6, 0)); | 371 greg.ScrollRect(scroll_rect, pp::Point(6, 0)); |
| 372 | 372 |
| 373 ASSERT_TRUE(greg.HasPendingUpdate()); | 373 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 374 | 374 |
| 375 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 375 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 376 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); | 376 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); |
| 377 | 377 |
| 378 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); | 378 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); |
| 379 return std::string(); | 379 PASS(); |
| 380 } | 380 } |
| 381 | 381 |
| 382 std::string | 382 std::string |
| 383 TestPaintAggregator::TestContainedPaintAfterScrollTrimmedByScrollDamage() { | 383 TestPaintAggregator::TestContainedPaintAfterScrollTrimmedByScrollDamage() { |
| 384 pp::PaintAggregator greg; | 384 pp::PaintAggregator greg; |
| 385 | 385 |
| 386 pp::Rect scroll_rect(0, 0, 10, 10); | 386 pp::Rect scroll_rect(0, 0, 10, 10); |
| 387 greg.ScrollRect(scroll_rect, pp::Point(4, 0)); | 387 greg.ScrollRect(scroll_rect, pp::Point(4, 0)); |
| 388 | 388 |
| 389 pp::Rect paint_rect(2, 0, 4, 10); | 389 pp::Rect paint_rect(2, 0, 4, 10); |
| 390 greg.InvalidateRect(paint_rect); | 390 greg.InvalidateRect(paint_rect); |
| 391 | 391 |
| 392 pp::Rect expected_scroll_damage(0, 0, 4, 10); | 392 pp::Rect expected_scroll_damage(0, 0, 4, 10); |
| 393 pp::Rect expected_paint_rect(4, 0, 2, 10); | 393 pp::Rect expected_paint_rect(4, 0, 2, 10); |
| 394 | 394 |
| 395 ASSERT_TRUE(greg.HasPendingUpdate()); | 395 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 396 | 396 |
| 397 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 397 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 398 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); | 398 ASSERT_TRUE(2U == greg.GetPendingUpdate().paint_rects.size()); |
| 399 | 399 |
| 400 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); | 400 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); |
| 401 ASSERT_TRUE(expected_scroll_damage == greg.GetPendingUpdate().paint_rects[1]); | 401 ASSERT_TRUE(expected_scroll_damage == greg.GetPendingUpdate().paint_rects[1]); |
| 402 ASSERT_TRUE(expected_paint_rect == greg.GetPendingUpdate().paint_rects[0]); | 402 ASSERT_TRUE(expected_paint_rect == greg.GetPendingUpdate().paint_rects[0]); |
| 403 return std::string(); | 403 PASS(); |
| 404 } | 404 } |
| 405 | 405 |
| 406 std::string | 406 std::string |
| 407 TestPaintAggregator::TestContainedPaintAfterScrollEliminatedByScrollDamage() { | 407 TestPaintAggregator::TestContainedPaintAfterScrollEliminatedByScrollDamage() { |
| 408 pp::PaintAggregator greg; | 408 pp::PaintAggregator greg; |
| 409 | 409 |
| 410 pp::Rect scroll_rect(0, 0, 10, 10); | 410 pp::Rect scroll_rect(0, 0, 10, 10); |
| 411 greg.ScrollRect(scroll_rect, pp::Point(4, 0)); | 411 greg.ScrollRect(scroll_rect, pp::Point(4, 0)); |
| 412 | 412 |
| 413 pp::Rect paint_rect(2, 0, 2, 10); | 413 pp::Rect paint_rect(2, 0, 2, 10); |
| 414 greg.InvalidateRect(paint_rect); | 414 greg.InvalidateRect(paint_rect); |
| 415 | 415 |
| 416 pp::Rect expected_scroll_damage(0, 0, 4, 10); | 416 pp::Rect expected_scroll_damage(0, 0, 4, 10); |
| 417 | 417 |
| 418 ASSERT_TRUE(greg.HasPendingUpdate()); | 418 ASSERT_TRUE(greg.HasPendingUpdate()); |
| 419 | 419 |
| 420 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 420 ASSERT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 421 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); | 421 ASSERT_TRUE(1U == greg.GetPendingUpdate().paint_rects.size()); |
| 422 | 422 |
| 423 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); | 423 ASSERT_TRUE(scroll_rect == greg.GetPendingUpdate().scroll_rect); |
| 424 ASSERT_TRUE(expected_scroll_damage == greg.GetPendingUpdate().paint_rects[0]); | 424 ASSERT_TRUE(expected_scroll_damage == greg.GetPendingUpdate().paint_rects[0]); |
| 425 return std::string(); | 425 PASS(); |
| 426 } | 426 } |
| OLD | NEW |