| 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/test/layer_tree_test.h" | 5 #include "cc/test/layer_tree_test.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 7 #include "cc/animation/animation.h" | 8 #include "cc/animation/animation.h" |
| 8 #include "cc/animation/animation_registrar.h" | 9 #include "cc/animation/animation_registrar.h" |
| 9 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
| 10 #include "cc/animation/timing_function.h" | 11 #include "cc/animation/timing_function.h" |
| 11 #include "cc/base/thread_impl.h" | 12 #include "cc/base/thread_impl.h" |
| 12 #include "cc/input/input_handler.h" | 13 #include "cc/input/input_handler.h" |
| 13 #include "cc/layers/content_layer.h" | 14 #include "cc/layers/content_layer.h" |
| 14 #include "cc/layers/layer.h" | 15 #include "cc/layers/layer.h" |
| 15 #include "cc/layers/layer_impl.h" | 16 #include "cc/layers/layer_impl.h" |
| 16 #include "cc/test/animation_test_common.h" | 17 #include "cc/test/animation_test_common.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 }; | 305 }; |
| 305 | 306 |
| 306 LayerTreeTest::LayerTreeTest() | 307 LayerTreeTest::LayerTreeTest() |
| 307 : beginning_(false), | 308 : beginning_(false), |
| 308 end_when_begin_returns_(false), | 309 end_when_begin_returns_(false), |
| 309 timed_out_(false), | 310 timed_out_(false), |
| 310 scheduled_(false), | 311 scheduled_(false), |
| 311 schedule_when_set_visible_true_(false), | 312 schedule_when_set_visible_true_(false), |
| 312 started_(false), | 313 started_(false), |
| 313 ended_(false), | 314 ended_(false), |
| 315 timeout_seconds_(0), |
| 314 impl_thread_(NULL), | 316 impl_thread_(NULL), |
| 315 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 317 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 316 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); | 318 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); |
| 319 |
| 320 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was |
| 321 // specified (for running in a debugger). |
| 322 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 323 if (!command_line->HasSwitch("cc-layer-tree-test-no-timeout")) |
| 324 timeout_seconds_ = 5; |
| 317 } | 325 } |
| 318 | 326 |
| 319 LayerTreeTest::~LayerTreeTest() {} | 327 LayerTreeTest::~LayerTreeTest() {} |
| 320 | 328 |
| 321 void LayerTreeTest::EndTest() { | 329 void LayerTreeTest::EndTest() { |
| 322 // For the case where we EndTest during BeginTest(), set a flag to indicate | 330 // For the case where we EndTest during BeginTest(), set a flag to indicate |
| 323 // that the test should end the second BeginTest regains control. | 331 // that the test should end the second BeginTest regains control. |
| 324 if (beginning_) { | 332 if (beginning_) { |
| 325 end_when_begin_returns_ = true; | 333 end_when_begin_returns_ = true; |
| 326 } else if (proxy()) { | 334 } else if (proxy()) { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 impl_thread_.reset(new base::Thread("LayerTreeTest")); | 528 impl_thread_.reset(new base::Thread("LayerTreeTest")); |
| 521 ASSERT_TRUE(impl_thread_->Start()); | 529 ASSERT_TRUE(impl_thread_->Start()); |
| 522 } | 530 } |
| 523 | 531 |
| 524 main_ccthread_ = cc::ThreadImpl::CreateForCurrentThread(); | 532 main_ccthread_ = cc::ThreadImpl::CreateForCurrentThread(); |
| 525 | 533 |
| 526 InitializeSettings(&settings_); | 534 InitializeSettings(&settings_); |
| 527 | 535 |
| 528 main_ccthread_->PostTask( | 536 main_ccthread_->PostTask( |
| 529 base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this))); | 537 base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this))); |
| 530 timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this))); | 538 |
| 531 main_ccthread_->PostDelayedTask(timeout_.callback(), | 539 if (timeout_seconds_) { |
| 532 base::TimeDelta::FromSeconds(5)); | 540 timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this))); |
| 541 main_ccthread_->PostDelayedTask( |
| 542 timeout_.callback(), |
| 543 base::TimeDelta::FromSeconds(timeout_seconds_)); |
| 544 } |
| 545 |
| 533 MessageLoop::current()->Run(); | 546 MessageLoop::current()->Run(); |
| 534 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 547 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
| 535 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 548 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
| 536 layer_tree_host_.reset(); | 549 layer_tree_host_.reset(); |
| 537 | 550 |
| 538 timeout_.Cancel(); | 551 timeout_.Cancel(); |
| 539 | 552 |
| 540 ASSERT_FALSE(layer_tree_host_.get()); | 553 ASSERT_FALSE(layer_tree_host_.get()); |
| 541 client_.reset(); | 554 client_.reset(); |
| 542 if (timed_out_) { | 555 if (timed_out_) { |
| 543 FAIL() << "Test timed out"; | 556 FAIL() << "Test timed out"; |
| 544 return; | 557 return; |
| 545 } | 558 } |
| 546 AfterTest(); | 559 AfterTest(); |
| 547 } | 560 } |
| 548 | 561 |
| 549 } // namespace cc | 562 } // namespace cc |
| OLD | NEW |