| 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::WaitForCompositingEnded( | 118     ui::DrawWaiterForTest::Wait(helper_->host()->compositor()); | 
| 119         helper_->host()->compositor()); |  | 
| 120   } | 119   } | 
| 121 | 120 | 
| 122   void SetupTestWindow(const gfx::Rect& window_bounds) { | 121   void SetupTestWindow(const gfx::Rect& window_bounds) { | 
| 123     delegate_.reset(new TestPaintingWindowDelegate(window_bounds.size())); | 122     delegate_.reset(new TestPaintingWindowDelegate(window_bounds.size())); | 
| 124     test_window_.reset(aura::test::CreateTestWindowWithDelegate( | 123     test_window_.reset(aura::test::CreateTestWindowWithDelegate( | 
| 125         delegate_.get(), 0, window_bounds, root_window())); | 124         delegate_.get(), 0, window_bounds, root_window())); | 
| 126   } | 125   } | 
| 127 | 126 | 
| 128   gfx::Image GrabSnapshotForTestWindow() { | 127   gfx::Image GrabSnapshotForTestWindow() { | 
| 129     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... | 
| 285   gfx::SizeF snapshot_size(test_bounds.size()); | 284   gfx::SizeF snapshot_size(test_bounds.size()); | 
| 286   snapshot_size.Scale(2.0f); | 285   snapshot_size.Scale(2.0f); | 
| 287 | 286 | 
| 288   gfx::Image snapshot = GrabSnapshotForTestWindow(); | 287   gfx::Image snapshot = GrabSnapshotForTestWindow(); | 
| 289   EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), | 288   EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), | 
| 290             snapshot.Size().ToString()); | 289             snapshot.Size().ToString()); | 
| 291   EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); | 290   EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); | 
| 292 } | 291 } | 
| 293 | 292 | 
| 294 }  // namespace ui | 293 }  // namespace ui | 
| OLD | NEW | 
|---|