| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 testing::Test::TearDown(); | 108 testing::Test::TearDown(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 protected: | 111 protected: |
| 112 aura::Window* test_window() { return test_window_.get(); } | 112 aura::Window* test_window() { return test_window_.get(); } |
| 113 aura::Window* root_window() { return helper_->root_window(); } | 113 aura::Window* root_window() { return helper_->root_window(); } |
| 114 aura::TestScreen* test_screen() { return helper_->test_screen(); } | 114 aura::TestScreen* test_screen() { return helper_->test_screen(); } |
| 115 | 115 |
| 116 void WaitForDraw() { | 116 void WaitForDraw() { |
| 117 helper_->host()->compositor()->ScheduleDraw(); | 117 helper_->host()->compositor()->ScheduleDraw(); |
| 118 ui::DrawWaiterForTest::Wait(helper_->host()->compositor()); | 118 ui::DrawWaiterForTest::WaitForCompositingEnded( |
| 119 helper_->host()->compositor()); |
| 119 } | 120 } |
| 120 | 121 |
| 121 void SetupTestWindow(const gfx::Rect& window_bounds) { | 122 void SetupTestWindow(const gfx::Rect& window_bounds) { |
| 122 delegate_.reset(new TestPaintingWindowDelegate(window_bounds.size())); | 123 delegate_.reset(new TestPaintingWindowDelegate(window_bounds.size())); |
| 123 test_window_.reset(aura::test::CreateTestWindowWithDelegate( | 124 test_window_.reset(aura::test::CreateTestWindowWithDelegate( |
| 124 delegate_.get(), 0, window_bounds, root_window())); | 125 delegate_.get(), 0, window_bounds, root_window())); |
| 125 } | 126 } |
| 126 | 127 |
| 127 gfx::Image GrabSnapshotForTestWindow() { | 128 gfx::Image GrabSnapshotForTestWindow() { |
| 128 gfx::Rect source_rect(test_window_->bounds().size()); | 129 gfx::Rect source_rect(test_window_->bounds().size()); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 gfx::SizeF snapshot_size(test_bounds.size()); | 285 gfx::SizeF snapshot_size(test_bounds.size()); |
| 285 snapshot_size.Scale(2.0f); | 286 snapshot_size.Scale(2.0f); |
| 286 | 287 |
| 287 gfx::Image snapshot = GrabSnapshotForTestWindow(); | 288 gfx::Image snapshot = GrabSnapshotForTestWindow(); |
| 288 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), | 289 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), |
| 289 snapshot.Size().ToString()); | 290 snapshot.Size().ToString()); |
| 290 EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); | 291 EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); |
| 291 } | 292 } |
| 292 | 293 |
| 293 } // namespace ui | 294 } // namespace ui |
| OLD | NEW |