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 25 matching lines...) Expand all Loading... |
36 // Paint simple rectangle on the specified aura window. | 36 // Paint simple rectangle on the specified aura window. |
37 class TestPaintingWindowDelegate : public aura::test::TestWindowDelegate { | 37 class TestPaintingWindowDelegate : public aura::test::TestWindowDelegate { |
38 public: | 38 public: |
39 explicit TestPaintingWindowDelegate(const gfx::Size& window_size) | 39 explicit TestPaintingWindowDelegate(const gfx::Size& window_size) |
40 : window_size_(window_size) { | 40 : window_size_(window_size) { |
41 } | 41 } |
42 | 42 |
43 virtual ~TestPaintingWindowDelegate() { | 43 virtual ~TestPaintingWindowDelegate() { |
44 } | 44 } |
45 | 45 |
46 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | 46 virtual void OnPaint(gfx::Canvas* canvas) override { |
47 for (int y = 0; y < window_size_.height(); ++y) { | 47 for (int y = 0; y < window_size_.height(); ++y) { |
48 for (int x = 0; x < window_size_.width(); ++x) | 48 for (int x = 0; x < window_size_.width(); ++x) |
49 canvas->FillRect(gfx::Rect(x, y, 1, 1), GetExpectedColorForPoint(x, y)); | 49 canvas->FillRect(gfx::Rect(x, y, 1, 1), GetExpectedColorForPoint(x, y)); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 gfx::Size window_size_; | 54 gfx::Size window_size_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(TestPaintingWindowDelegate); | 56 DISALLOW_COPY_AND_ASSIGN(TestPaintingWindowDelegate); |
(...skipping 20 matching lines...) Expand all Loading... |
77 return GetFailedPixelsCountWithScaleFactor(image, 1); | 77 return GetFailedPixelsCountWithScaleFactor(image, 1); |
78 } | 78 } |
79 | 79 |
80 } // namespace | 80 } // namespace |
81 | 81 |
82 class SnapshotAuraTest : public testing::Test { | 82 class SnapshotAuraTest : public testing::Test { |
83 public: | 83 public: |
84 SnapshotAuraTest() {} | 84 SnapshotAuraTest() {} |
85 virtual ~SnapshotAuraTest() {} | 85 virtual ~SnapshotAuraTest() {} |
86 | 86 |
87 virtual void SetUp() OVERRIDE { | 87 virtual void SetUp() override { |
88 testing::Test::SetUp(); | 88 testing::Test::SetUp(); |
89 | 89 |
90 // The ContextFactory must exist before any Compositors are created. | 90 // The ContextFactory must exist before any Compositors are created. |
91 // Snapshot test tests real drawing and readback, so needs pixel output. | 91 // Snapshot test tests real drawing and readback, so needs pixel output. |
92 bool enable_pixel_output = true; | 92 bool enable_pixel_output = true; |
93 ui::ContextFactory* context_factory = | 93 ui::ContextFactory* context_factory = |
94 ui::InitializeContextFactoryForTests(enable_pixel_output); | 94 ui::InitializeContextFactoryForTests(enable_pixel_output); |
95 | 95 |
96 helper_.reset( | 96 helper_.reset( |
97 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); | 97 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); |
98 helper_->SetUp(context_factory); | 98 helper_->SetUp(context_factory); |
99 new ::wm::DefaultActivationClient(helper_->root_window()); | 99 new ::wm::DefaultActivationClient(helper_->root_window()); |
100 } | 100 } |
101 | 101 |
102 virtual void TearDown() OVERRIDE { | 102 virtual void TearDown() override { |
103 test_window_.reset(); | 103 test_window_.reset(); |
104 delegate_.reset(); | 104 delegate_.reset(); |
105 helper_->RunAllPendingInMessageLoop(); | 105 helper_->RunAllPendingInMessageLoop(); |
106 helper_->TearDown(); | 106 helper_->TearDown(); |
107 ui::TerminateContextFactoryForTests(); | 107 ui::TerminateContextFactoryForTests(); |
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(); } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 gfx::SizeF snapshot_size(test_bounds.size()); | 285 gfx::SizeF snapshot_size(test_bounds.size()); |
286 snapshot_size.Scale(2.0f); | 286 snapshot_size.Scale(2.0f); |
287 | 287 |
288 gfx::Image snapshot = GrabSnapshotForTestWindow(); | 288 gfx::Image snapshot = GrabSnapshotForTestWindow(); |
289 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), | 289 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), |
290 snapshot.Size().ToString()); | 290 snapshot.Size().ToString()); |
291 EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); | 291 EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); |
292 } | 292 } |
293 | 293 |
294 } // namespace ui | 294 } // namespace ui |
OLD | NEW |