| 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" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 119 } |
| 120 | 120 |
| 121 void SetupTestWindow(const gfx::Rect& window_bounds) { | 121 void SetupTestWindow(const gfx::Rect& window_bounds) { |
| 122 delegate_.reset(new TestPaintingWindowDelegate(window_bounds.size())); | 122 delegate_.reset(new TestPaintingWindowDelegate(window_bounds.size())); |
| 123 test_window_.reset(aura::test::CreateTestWindowWithDelegate( | 123 test_window_.reset(aura::test::CreateTestWindowWithDelegate( |
| 124 delegate_.get(), 0, window_bounds, root_window())); | 124 delegate_.get(), 0, window_bounds, root_window())); |
| 125 } | 125 } |
| 126 | 126 |
| 127 gfx::Image GrabSnapshotForTestWindow() { | 127 gfx::Image GrabSnapshotForTestWindow() { |
| 128 gfx::Rect source_rect(test_window_->bounds().size()); | 128 gfx::Rect source_rect(test_window_->bounds().size()); |
| 129 aura::Window::ConvertRectToTarget( |
| 130 test_window(), root_window(), &source_rect); |
| 129 | 131 |
| 130 scoped_refptr<base::TestSimpleTaskRunner> task_runner( | 132 scoped_refptr<base::TestSimpleTaskRunner> task_runner( |
| 131 new base::TestSimpleTaskRunner()); | 133 new base::TestSimpleTaskRunner()); |
| 132 scoped_refptr<SnapshotHolder> holder(new SnapshotHolder); | 134 scoped_refptr<SnapshotHolder> holder(new SnapshotHolder); |
| 133 ui::GrabWindowSnapshotAsync( | 135 ui::GrabWindowSnapshotAsync( |
| 134 test_window(), | 136 root_window(), |
| 135 source_rect, | 137 source_rect, |
| 136 task_runner, | 138 task_runner, |
| 137 base::Bind(&SnapshotHolder::SnapshotCallback, holder)); | 139 base::Bind(&SnapshotHolder::SnapshotCallback, holder)); |
| 138 | 140 |
| 139 // Wait for copy response. | 141 // Wait for copy response. |
| 140 WaitForDraw(); | 142 WaitForDraw(); |
| 141 // Run internal snapshot callback to scale/rotate response image. | 143 // Run internal snapshot callback to scale/rotate response image. |
| 142 task_runner->RunUntilIdle(); | 144 task_runner->RunUntilIdle(); |
| 143 // Run SnapshotHolder callback. | 145 // Run SnapshotHolder callback. |
| 144 helper_->RunAllPendingInMessageLoop(); | 146 helper_->RunAllPendingInMessageLoop(); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 gfx::SizeF snapshot_size(test_bounds.size()); | 284 gfx::SizeF snapshot_size(test_bounds.size()); |
| 283 snapshot_size.Scale(2.0f); | 285 snapshot_size.Scale(2.0f); |
| 284 | 286 |
| 285 gfx::Image snapshot = GrabSnapshotForTestWindow(); | 287 gfx::Image snapshot = GrabSnapshotForTestWindow(); |
| 286 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), | 288 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), |
| 287 snapshot.Size().ToString()); | 289 snapshot.Size().ToString()); |
| 288 EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); | 290 EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); |
| 289 } | 291 } |
| 290 | 292 |
| 291 } // namespace ui | 293 } // namespace ui |
| OLD | NEW |