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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 delegate_.reset(); | 100 delegate_.reset(); |
101 helper_->RunAllPendingInMessageLoop(); | 101 helper_->RunAllPendingInMessageLoop(); |
102 helper_->TearDown(); | 102 helper_->TearDown(); |
103 ui::TerminateContextFactoryForTests(); | 103 ui::TerminateContextFactoryForTests(); |
104 testing::Test::TearDown(); | 104 testing::Test::TearDown(); |
105 } | 105 } |
106 | 106 |
107 protected: | 107 protected: |
108 aura::Window* test_window() { return test_window_.get(); } | 108 aura::Window* test_window() { return test_window_.get(); } |
109 aura::Window* root_window() { return helper_->root_window(); } | 109 aura::Window* root_window() { return helper_->root_window(); } |
110 aura::WindowEventDispatcher* dispatcher() { return helper_->dispatcher(); } | |
111 aura::TestScreen* test_screen() { return helper_->test_screen(); } | 110 aura::TestScreen* test_screen() { return helper_->test_screen(); } |
112 | 111 |
113 void WaitForDraw() { | 112 void WaitForDraw() { |
114 dispatcher()->host()->compositor()->ScheduleDraw(); | 113 helper_->host()->compositor()->ScheduleDraw(); |
115 ui::DrawWaiterForTest::Wait(dispatcher()->host()->compositor()); | 114 ui::DrawWaiterForTest::Wait(helper_->host()->compositor()); |
116 } | 115 } |
117 | 116 |
118 void SetupTestWindow(const gfx::Rect& window_bounds) { | 117 void SetupTestWindow(const gfx::Rect& window_bounds) { |
119 delegate_.reset(new TestPaintingWindowDelegate(window_bounds.size())); | 118 delegate_.reset(new TestPaintingWindowDelegate(window_bounds.size())); |
120 test_window_.reset(aura::test::CreateTestWindowWithDelegate( | 119 test_window_.reset(aura::test::CreateTestWindowWithDelegate( |
121 delegate_.get(), 0, window_bounds, root_window())); | 120 delegate_.get(), 0, window_bounds, root_window())); |
122 } | 121 } |
123 | 122 |
124 gfx::Image GrabSnapshotForTestWindow() { | 123 gfx::Image GrabSnapshotForTestWindow() { |
125 gfx::Rect source_rect(test_window_->bounds().size()); | 124 gfx::Rect source_rect(test_window_->bounds().size()); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 gfx::SizeF snapshot_size(test_bounds.size()); | 278 gfx::SizeF snapshot_size(test_bounds.size()); |
280 snapshot_size.Scale(2.0f); | 279 snapshot_size.Scale(2.0f); |
281 | 280 |
282 gfx::Image snapshot = GrabSnapshotForTestWindow(); | 281 gfx::Image snapshot = GrabSnapshotForTestWindow(); |
283 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), | 282 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), |
284 snapshot.Size().ToString()); | 283 snapshot.Size().ToString()); |
285 EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); | 284 EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); |
286 } | 285 } |
287 | 286 |
288 } // namespace ui | 287 } // namespace ui |
OLD | NEW |