| 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/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "cc/layers/delegated_frame_provider.h" | 15 #include "cc/layers/delegated_frame_provider.h" |
| 16 #include "cc/layers/delegated_frame_resource_collection.h" | 16 #include "cc/layers/delegated_frame_resource_collection.h" |
| 17 #include "cc/layers/layer.h" | 17 #include "cc/layers/layer.h" |
| 18 #include "cc/output/delegated_frame_data.h" | 18 #include "cc/output/delegated_frame_data.h" |
| 19 #include "cc/test/pixel_test_utils.h" | 19 #include "cc/test/pixel_test_utils.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/compositor/compositor_observer.h" | 21 #include "ui/compositor/compositor_observer.h" |
| 22 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
| 23 #include "ui/compositor/layer_animation_sequence.h" | 23 #include "ui/compositor/layer_animation_sequence.h" |
| 24 #include "ui/compositor/layer_animator.h" | 24 #include "ui/compositor/layer_animator.h" |
| 25 #include "ui/compositor/test/context_factories_for_test.h" |
| 25 #include "ui/compositor/test/test_compositor_host.h" | 26 #include "ui/compositor/test/test_compositor_host.h" |
| 26 #include "ui/compositor/test/test_layers.h" | 27 #include "ui/compositor/test/test_layers.h" |
| 27 #include "ui/gfx/canvas.h" | 28 #include "ui/gfx/canvas.h" |
| 28 #include "ui/gfx/codec/png_codec.h" | 29 #include "ui/gfx/codec/png_codec.h" |
| 29 #include "ui/gfx/gfx_paths.h" | 30 #include "ui/gfx/gfx_paths.h" |
| 30 #include "ui/gfx/skia_util.h" | 31 #include "ui/gfx/skia_util.h" |
| 31 | 32 |
| 32 using cc::MatchesPNGFile; | 33 using cc::MatchesPNGFile; |
| 33 | 34 |
| 34 namespace ui { | 35 namespace ui { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 test_data_directory_ = test_data_directory_.AppendASCII("compositor"); | 78 test_data_directory_ = test_data_directory_.AppendASCII("compositor"); |
| 78 } else { | 79 } else { |
| 79 LOG(ERROR) << "Could not open test data directory."; | 80 LOG(ERROR) << "Could not open test data directory."; |
| 80 } | 81 } |
| 81 } | 82 } |
| 82 virtual ~LayerWithRealCompositorTest() {} | 83 virtual ~LayerWithRealCompositorTest() {} |
| 83 | 84 |
| 84 // Overridden from testing::Test: | 85 // Overridden from testing::Test: |
| 85 virtual void SetUp() OVERRIDE { | 86 virtual void SetUp() OVERRIDE { |
| 86 bool allow_test_contexts = false; | 87 bool allow_test_contexts = false; |
| 87 Compositor::InitializeContextFactoryForTests(allow_test_contexts); | 88 InitializeContextFactoryForTests(allow_test_contexts); |
| 88 Compositor::Initialize(); | 89 Compositor::Initialize(); |
| 89 | 90 |
| 90 const gfx::Rect host_bounds(10, 10, 500, 500); | 91 const gfx::Rect host_bounds(10, 10, 500, 500); |
| 91 window_.reset(TestCompositorHost::Create(host_bounds)); | 92 window_.reset(TestCompositorHost::Create(host_bounds)); |
| 92 window_->Show(); | 93 window_->Show(); |
| 93 } | 94 } |
| 94 | 95 |
| 95 virtual void TearDown() OVERRIDE { | 96 virtual void TearDown() OVERRIDE { |
| 96 window_.reset(); | 97 window_.reset(); |
| 98 TerminateContextFactoryForTests(); |
| 97 Compositor::Terminate(); | 99 Compositor::Terminate(); |
| 98 } | 100 } |
| 99 | 101 |
| 100 Compositor* GetCompositor() { | 102 Compositor* GetCompositor() { |
| 101 return window_->GetCompositor(); | 103 return window_->GetCompositor(); |
| 102 } | 104 } |
| 103 | 105 |
| 104 Layer* CreateLayer(LayerType type) { | 106 Layer* CreateLayer(LayerType type) { |
| 105 return new Layer(type); | 107 return new Layer(type); |
| 106 } | 108 } |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 } | 346 } |
| 345 | 347 |
| 346 class LayerWithDelegateTest : public testing::Test { | 348 class LayerWithDelegateTest : public testing::Test { |
| 347 public: | 349 public: |
| 348 LayerWithDelegateTest() {} | 350 LayerWithDelegateTest() {} |
| 349 virtual ~LayerWithDelegateTest() {} | 351 virtual ~LayerWithDelegateTest() {} |
| 350 | 352 |
| 351 // Overridden from testing::Test: | 353 // Overridden from testing::Test: |
| 352 virtual void SetUp() OVERRIDE { | 354 virtual void SetUp() OVERRIDE { |
| 353 bool allow_test_contexts = true; | 355 bool allow_test_contexts = true; |
| 354 Compositor::InitializeContextFactoryForTests(allow_test_contexts); | 356 InitializeContextFactoryForTests(allow_test_contexts); |
| 355 Compositor::Initialize(); | 357 Compositor::Initialize(); |
| 356 compositor_.reset(new Compositor(gfx::kNullAcceleratedWidget)); | 358 compositor_.reset(new Compositor(gfx::kNullAcceleratedWidget)); |
| 357 compositor_->SetScaleAndSize(1.0f, gfx::Size(1000, 1000)); | 359 compositor_->SetScaleAndSize(1.0f, gfx::Size(1000, 1000)); |
| 358 } | 360 } |
| 359 | 361 |
| 360 virtual void TearDown() OVERRIDE { | 362 virtual void TearDown() OVERRIDE { |
| 361 compositor_.reset(); | 363 compositor_.reset(); |
| 364 TerminateContextFactoryForTests(); |
| 362 Compositor::Terminate(); | 365 Compositor::Terminate(); |
| 363 } | 366 } |
| 364 | 367 |
| 365 Compositor* compositor() { return compositor_.get(); } | 368 Compositor* compositor() { return compositor_.get(); } |
| 366 | 369 |
| 367 virtual Layer* CreateLayer(LayerType type) { | 370 virtual Layer* CreateLayer(LayerType type) { |
| 368 return new Layer(type); | 371 return new Layer(type); |
| 369 } | 372 } |
| 370 | 373 |
| 371 Layer* CreateColorLayer(SkColor color, const gfx::Rect& bounds) { | 374 Layer* CreateColorLayer(SkColor color, const gfx::Rect& bounds) { |
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1443 l1->SetOpacity(0.5f); | 1446 l1->SetOpacity(0.5f); |
| 1444 | 1447 |
| 1445 // Change l1's cc::Layer. | 1448 // Change l1's cc::Layer. |
| 1446 l1->SwitchCCLayerForTest(); | 1449 l1->SwitchCCLayerForTest(); |
| 1447 | 1450 |
| 1448 // Ensure that the opacity animation completed. | 1451 // Ensure that the opacity animation completed. |
| 1449 EXPECT_FLOAT_EQ(l1->opacity(), 0.5f); | 1452 EXPECT_FLOAT_EQ(l1->opacity(), 0.5f); |
| 1450 } | 1453 } |
| 1451 | 1454 |
| 1452 } // namespace ui | 1455 } // namespace ui |
| OLD | NEW |