OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/snapshot/snapshot.h" | 5 #include "ui/snapshot/snapshot.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/test/test_simple_task_runner.h" | 8 #include "base/test/test_simple_task_runner.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/aura/test/aura_test_helper.h" | 10 #include "ui/aura/test/aura_test_helper.h" |
11 #include "ui/aura/test/test_screen.h" | 11 #include "ui/aura/test/test_screen.h" |
12 #include "ui/aura/test/test_window_delegate.h" | 12 #include "ui/aura/test/test_window_delegate.h" |
13 #include "ui/aura/test/test_windows.h" | 13 #include "ui/aura/test/test_windows.h" |
14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
15 #include "ui/aura/window_event_dispatcher.h" | 15 #include "ui/aura/window_event_dispatcher.h" |
| 16 #include "ui/compositor/compositor.h" |
16 #include "ui/compositor/layer.h" | 17 #include "ui/compositor/layer.h" |
17 #include "ui/compositor/test/context_factories_for_test.h" | 18 #include "ui/compositor/test/context_factories_for_test.h" |
18 #include "ui/compositor/test/draw_waiter_for_test.h" | 19 #include "ui/compositor/test/draw_waiter_for_test.h" |
19 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
20 #include "ui/gfx/gfx_paths.h" | 21 #include "ui/gfx/gfx_paths.h" |
21 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
22 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
23 #include "ui/gfx/size_conversions.h" | 24 #include "ui/gfx/size_conversions.h" |
24 #include "ui/gfx/transform.h" | 25 #include "ui/gfx/transform.h" |
25 #include "ui/gl/gl_implementation.h" | 26 #include "ui/gl/gl_implementation.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 public: | 83 public: |
83 SnapshotAuraTest() {} | 84 SnapshotAuraTest() {} |
84 virtual ~SnapshotAuraTest() {} | 85 virtual ~SnapshotAuraTest() {} |
85 | 86 |
86 virtual void SetUp() OVERRIDE { | 87 virtual void SetUp() OVERRIDE { |
87 testing::Test::SetUp(); | 88 testing::Test::SetUp(); |
88 | 89 |
89 // The ContextFactory must exist before any Compositors are created. | 90 // The ContextFactory must exist before any Compositors are created. |
90 // Snapshot test tests real drawing and readback, so needs pixel output. | 91 // Snapshot test tests real drawing and readback, so needs pixel output. |
91 bool enable_pixel_output = true; | 92 bool enable_pixel_output = true; |
92 ui::InitializeContextFactoryForTests(enable_pixel_output); | 93 ui::ContextFactory* context_factory = |
| 94 ui::InitializeContextFactoryForTests(enable_pixel_output); |
93 | 95 |
94 helper_.reset( | 96 helper_.reset( |
95 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); | 97 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); |
96 helper_->SetUp(); | 98 helper_->SetUp(context_factory); |
97 new ::wm::DefaultActivationClient(helper_->root_window()); | 99 new ::wm::DefaultActivationClient(helper_->root_window()); |
98 } | 100 } |
99 | 101 |
100 virtual void TearDown() OVERRIDE { | 102 virtual void TearDown() OVERRIDE { |
101 test_window_.reset(); | 103 test_window_.reset(); |
102 delegate_.reset(); | 104 delegate_.reset(); |
103 helper_->RunAllPendingInMessageLoop(); | 105 helper_->RunAllPendingInMessageLoop(); |
104 helper_->TearDown(); | 106 helper_->TearDown(); |
105 ui::TerminateContextFactoryForTests(); | 107 ui::TerminateContextFactoryForTests(); |
106 testing::Test::TearDown(); | 108 testing::Test::TearDown(); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 gfx::SizeF snapshot_size(test_bounds.size()); | 282 gfx::SizeF snapshot_size(test_bounds.size()); |
281 snapshot_size.Scale(2.0f); | 283 snapshot_size.Scale(2.0f); |
282 | 284 |
283 gfx::Image snapshot = GrabSnapshotForTestWindow(); | 285 gfx::Image snapshot = GrabSnapshotForTestWindow(); |
284 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), | 286 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), |
285 snapshot.Size().ToString()); | 287 snapshot.Size().ToString()); |
286 EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); | 288 EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); |
287 } | 289 } |
288 | 290 |
289 } // namespace ui | 291 } // namespace ui |
OLD | NEW |