Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 if (PathService::Get(gfx::DIR_TEST_DATA, &test_data_directory_)) { | 80 if (PathService::Get(gfx::DIR_TEST_DATA, &test_data_directory_)) { |
| 81 test_data_directory_ = test_data_directory_.AppendASCII("compositor"); | 81 test_data_directory_ = test_data_directory_.AppendASCII("compositor"); |
| 82 } else { | 82 } else { |
| 83 LOG(ERROR) << "Could not open test data directory."; | 83 LOG(ERROR) << "Could not open test data directory."; |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 virtual ~LayerWithRealCompositorTest() {} | 86 virtual ~LayerWithRealCompositorTest() {} |
| 87 | 87 |
| 88 // Overridden from testing::Test: | 88 // Overridden from testing::Test: |
| 89 virtual void SetUp() OVERRIDE { | 89 virtual void SetUp() OVERRIDE { |
| 90 bool allow_test_contexts = false; | 90 bool enable_pixel_output = true; |
| 91 InitializeContextFactoryForTests(allow_test_contexts); | 91 InitializeContextFactoryForTests(enable_pixel_output); |
| 92 Compositor::Initialize(); | 92 Compositor::Initialize(); |
| 93 | 93 |
| 94 const gfx::Rect host_bounds(10, 10, 500, 500); | 94 const gfx::Rect host_bounds(10, 10, 500, 500); |
| 95 window_.reset(TestCompositorHost::Create(host_bounds)); | 95 window_.reset(TestCompositorHost::Create(host_bounds)); |
| 96 window_->Show(); | 96 window_->Show(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 virtual void TearDown() OVERRIDE { | 99 virtual void TearDown() OVERRIDE { |
| 100 window_.reset(); | 100 window_.reset(); |
| 101 TerminateContextFactoryForTests(); | 101 TerminateContextFactoryForTests(); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 DrawTree(l1.get()); | 347 DrawTree(l1.get()); |
| 348 } | 348 } |
| 349 | 349 |
| 350 class LayerWithDelegateTest : public testing::Test { | 350 class LayerWithDelegateTest : public testing::Test { |
| 351 public: | 351 public: |
| 352 LayerWithDelegateTest() {} | 352 LayerWithDelegateTest() {} |
| 353 virtual ~LayerWithDelegateTest() {} | 353 virtual ~LayerWithDelegateTest() {} |
| 354 | 354 |
| 355 // Overridden from testing::Test: | 355 // Overridden from testing::Test: |
| 356 virtual void SetUp() OVERRIDE { | 356 virtual void SetUp() OVERRIDE { |
| 357 bool allow_test_contexts = true; | 357 bool enable_pixel_output = false; |
| 358 InitializeContextFactoryForTests(allow_test_contexts); | 358 InitializeContextFactoryForTests(enable_pixel_output); |
| 359 Compositor::Initialize(); | 359 Compositor::Initialize(); |
| 360 compositor_.reset(new Compositor(gfx::kNullAcceleratedWidget)); | 360 |
| 361 compositor_->SetScaleAndSize(1.0f, gfx::Size(1000, 1000)); | 361 const gfx::Rect host_bounds(1000, 1000); |
| 362 window_.reset(TestCompositorHost::Create(host_bounds)); | |
|
piman
2014/01/29 01:40:17
nit: s/window_/compositor_host_/ ?
danakj
2014/01/29 20:19:00
Done.
| |
| 363 window_->Show(); | |
| 362 } | 364 } |
| 363 | 365 |
| 364 virtual void TearDown() OVERRIDE { | 366 virtual void TearDown() OVERRIDE { |
| 365 compositor_.reset(); | 367 window_.reset(); |
| 366 TerminateContextFactoryForTests(); | 368 TerminateContextFactoryForTests(); |
| 367 Compositor::Terminate(); | 369 Compositor::Terminate(); |
| 368 } | 370 } |
| 369 | 371 |
| 370 Compositor* compositor() { return compositor_.get(); } | 372 Compositor* compositor() { return window_->GetCompositor(); } |
| 371 | 373 |
| 372 virtual Layer* CreateLayer(LayerType type) { | 374 virtual Layer* CreateLayer(LayerType type) { |
| 373 return new Layer(type); | 375 return new Layer(type); |
| 374 } | 376 } |
| 375 | 377 |
| 376 Layer* CreateColorLayer(SkColor color, const gfx::Rect& bounds) { | 378 Layer* CreateColorLayer(SkColor color, const gfx::Rect& bounds) { |
| 377 Layer* layer = new ColoredLayer(color); | 379 Layer* layer = new ColoredLayer(color); |
| 378 layer->SetBounds(bounds); | 380 layer->SetBounds(bounds); |
| 379 return layer; | 381 return layer; |
| 380 } | 382 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 404 | 406 |
| 405 void WaitForDraw() { | 407 void WaitForDraw() { |
| 406 DrawWaiterForTest::Wait(compositor()); | 408 DrawWaiterForTest::Wait(compositor()); |
| 407 } | 409 } |
| 408 | 410 |
| 409 void WaitForCommit() { | 411 void WaitForCommit() { |
| 410 DrawWaiterForTest::WaitForCommit(compositor()); | 412 DrawWaiterForTest::WaitForCommit(compositor()); |
| 411 } | 413 } |
| 412 | 414 |
| 413 private: | 415 private: |
| 414 scoped_ptr<Compositor> compositor_; | 416 scoped_ptr<TestCompositorHost> window_; |
| 415 | 417 |
| 416 DISALLOW_COPY_AND_ASSIGN(LayerWithDelegateTest); | 418 DISALLOW_COPY_AND_ASSIGN(LayerWithDelegateTest); |
| 417 }; | 419 }; |
| 418 | 420 |
| 419 // L1 | 421 // L1 |
| 420 // +-- L2 | 422 // +-- L2 |
| 421 TEST_F(LayerWithDelegateTest, ConvertPointToLayer_Simple) { | 423 TEST_F(LayerWithDelegateTest, ConvertPointToLayer_Simple) { |
| 422 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED, | 424 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED, |
| 423 gfx::Rect(20, 20, 400, 400))); | 425 gfx::Rect(20, 20, 400, 400))); |
| 424 scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE, | 426 scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE, |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1465 l1->SetOpacity(0.5f); | 1467 l1->SetOpacity(0.5f); |
| 1466 | 1468 |
| 1467 // Change l1's cc::Layer. | 1469 // Change l1's cc::Layer. |
| 1468 l1->SwitchCCLayerForTest(); | 1470 l1->SwitchCCLayerForTest(); |
| 1469 | 1471 |
| 1470 // Ensure that the opacity animation completed. | 1472 // Ensure that the opacity animation completed. |
| 1471 EXPECT_FLOAT_EQ(l1->opacity(), 0.5f); | 1473 EXPECT_FLOAT_EQ(l1->opacity(), 0.5f); |
| 1472 } | 1474 } |
| 1473 | 1475 |
| 1474 } // namespace ui | 1476 } // namespace ui |
| OLD | NEW |