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