Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 } | 195 } |
| 196 | 196 |
| 197 private: | 197 private: |
| 198 FakeContentLayerClient client_; | 198 FakeContentLayerClient client_; |
| 199 }; | 199 }; |
| 200 | 200 |
| 201 // Multi-thread only because in single thread the commit goes directly to the | 201 // Multi-thread only because in single thread the commit goes directly to the |
| 202 // active tree, so notify ready to activate is skipped. | 202 // active tree, so notify ready to activate is skipped. |
| 203 MULTI_THREAD_TEST_F(LayerTreeHostTestReadyToActivateNonEmpty); | 203 MULTI_THREAD_TEST_F(LayerTreeHostTestReadyToActivateNonEmpty); |
| 204 | 204 |
| 205 // This tests if we get the READY_TO_ACTIVATE signal if we become invisible and | |
| 206 // then become visible again. | |
| 207 class LayerTreeHostTestReadyToActivateVisibility | |
| 208 : public LayerTreeHostTestReadyToActivateNonEmpty { | |
| 209 public: | |
| 210 LayerTreeHostTestReadyToActivateVisibility() | |
| 211 : LayerTreeHostTestReadyToActivateNonEmpty(), | |
| 212 commit_count_(0), | |
| 213 toggled_visibility_(false) {} | |
| 214 | |
| 215 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | |
| 216 LayerTreeHostTestReadyToActivateNonEmpty::CommitCompleteOnThread(host_impl); | |
| 217 commit_count_++; | |
| 218 if (commit_count_ == 1) | |
| 219 PostSetVisibleToMainThread(false); | |
| 220 } | |
| 221 | |
| 222 void DidFinishImplFrameOnThread(LayerTreeHostImpl* host_impl) override { | |
| 223 if (commit_count_ == 1) | |
| 224 PostSetVisibleToMainThread(true); | |
|
brianderson
2015/07/23 02:00:23
I think it's possible this races with the DidSetVi
sunnyps
2015/07/23 22:20:44
That works for the ready to draw test because that
| |
| 225 } | |
| 226 | |
| 227 void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, | |
| 228 bool visible) override { | |
| 229 if (!visible) | |
| 230 toggled_visibility_ = true; | |
| 231 } | |
| 232 | |
| 233 void AfterTest() override { | |
| 234 LayerTreeHostTestReadyToActivateNonEmpty::AfterTest(); | |
| 235 EXPECT_LE(1, commit_count_); | |
|
brianderson
2015/07/23 02:00:23
I'm not sure if this test has a race between READY
sunnyps
2015/07/23 22:20:44
See reply above.
| |
| 236 EXPECT_TRUE(toggled_visibility_); | |
| 237 } | |
| 238 | |
| 239 private: | |
| 240 int commit_count_; | |
| 241 bool toggled_visibility_; | |
| 242 }; | |
| 243 | |
| 244 // Multi-thread only because in single thread the commit goes directly to the | |
| 245 // active tree, so notify ready to activate is skipped. | |
| 246 MULTI_THREAD_TEST_F(LayerTreeHostTestReadyToActivateVisibility); | |
| 247 | |
| 205 // Test if the LTHI receives ReadyToDraw notifications from the TileManager when | 248 // Test if the LTHI receives ReadyToDraw notifications from the TileManager when |
| 206 // no raster tasks get scheduled. | 249 // no raster tasks get scheduled. |
| 207 class LayerTreeHostTestReadyToDrawEmpty : public LayerTreeHostTest { | 250 class LayerTreeHostTestReadyToDrawEmpty : public LayerTreeHostTest { |
| 208 public: | 251 public: |
| 209 LayerTreeHostTestReadyToDrawEmpty() | 252 LayerTreeHostTestReadyToDrawEmpty() |
| 210 : did_notify_ready_to_draw_(false), | 253 : did_notify_ready_to_draw_(false), |
| 211 all_tiles_required_for_draw_are_ready_to_draw_(false), | 254 all_tiles_required_for_draw_are_ready_to_draw_(false), |
| 212 required_for_draw_count_(0) {} | 255 required_for_draw_count_(0) {} |
| 213 | 256 |
| 214 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 257 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 } | 308 } |
| 266 | 309 |
| 267 private: | 310 private: |
| 268 FakeContentLayerClient client_; | 311 FakeContentLayerClient client_; |
| 269 }; | 312 }; |
| 270 | 313 |
| 271 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in | 314 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in |
| 272 // single threaded mode. | 315 // single threaded mode. |
| 273 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawNonEmpty); | 316 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawNonEmpty); |
| 274 | 317 |
| 318 // This tests if we get the READY_TO_DRAW signal if we become invisible and then | |
| 319 // become visible again. | |
| 320 class LayerTreeHostTestReadyToDrawVisibility | |
|
brianderson
2015/07/23 02:00:23
See comments about other test.
| |
| 321 : public LayerTreeHostTestReadyToDrawNonEmpty { | |
| 322 public: | |
| 323 LayerTreeHostTestReadyToDrawVisibility() | |
| 324 : LayerTreeHostTestReadyToDrawNonEmpty(), | |
| 325 commit_count_(0), | |
| 326 toggled_visibility_(false) {} | |
| 327 | |
| 328 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | |
| 329 commit_count_++; | |
| 330 if (commit_count_ == 1) | |
| 331 PostSetVisibleToMainThread(false); | |
| 332 } | |
| 333 | |
| 334 void DidFinishImplFrameOnThread(LayerTreeHostImpl* host_impl) override { | |
| 335 if (commit_count_ == 1) | |
| 336 PostSetVisibleToMainThread(true); | |
| 337 } | |
| 338 | |
| 339 void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, | |
| 340 bool visible) override { | |
| 341 if (!visible) | |
| 342 toggled_visibility_ = true; | |
| 343 } | |
| 344 | |
| 345 void AfterTest() override { | |
| 346 LayerTreeHostTestReadyToDrawNonEmpty::AfterTest(); | |
| 347 EXPECT_LE(1, commit_count_); | |
| 348 EXPECT_TRUE(toggled_visibility_); | |
| 349 } | |
| 350 | |
| 351 private: | |
| 352 int commit_count_; | |
| 353 bool toggled_visibility_; | |
| 354 }; | |
| 355 | |
| 356 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in | |
| 357 // single threaded mode. | |
| 358 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawVisibility); | |
| 359 | |
| 275 class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest { | 360 class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest { |
| 276 public: | 361 public: |
| 277 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | 362 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 278 auto output_surface = make_scoped_ptr(new testing::StrictMock< | 363 auto output_surface = make_scoped_ptr(new testing::StrictMock< |
| 279 MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface>( | 364 MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface>( |
| 280 delegating_renderer())); | 365 delegating_renderer())); |
| 281 | 366 |
| 282 // At init, we expect one call to set visibility to true. | 367 // At init, we expect one call to set visibility to true. |
| 283 testing::Expectation visibility_true = | 368 testing::Expectation visibility_true = |
| 284 EXPECT_CALL(*output_surface, | 369 EXPECT_CALL(*output_surface, |
| (...skipping 5770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6055 void AfterTest() override {} | 6140 void AfterTest() override {} |
| 6056 | 6141 |
| 6057 std::vector<int> affected_by_page_scale_; | 6142 std::vector<int> affected_by_page_scale_; |
| 6058 std::vector<int> not_affected_by_page_scale_; | 6143 std::vector<int> not_affected_by_page_scale_; |
| 6059 }; | 6144 }; |
| 6060 | 6145 |
| 6061 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestPageScaleFlags); | 6146 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestPageScaleFlags); |
| 6062 | 6147 |
| 6063 } // namespace | 6148 } // namespace |
| 6064 } // namespace cc | 6149 } // namespace cc |
| OLD | NEW |