Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: ui/snapshot/snapshot_aura_unittest.cc

Issue 209383003: Move wm/public into wm target (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/snapshot/snapshot.gyp ('k') | ui/views/test/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "ui/aura/test/test_screen.h" 10 #include "ui/aura/test/test_screen.h"
12 #include "ui/aura/test/test_window_delegate.h" 11 #include "ui/aura/test/test_window_delegate.h"
13 #include "ui/aura/test/test_windows.h" 12 #include "ui/aura/test/test_windows.h"
14 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
15 #include "ui/aura/window_event_dispatcher.h" 14 #include "ui/aura/window_event_dispatcher.h"
16 #include "ui/compositor/layer.h" 15 #include "ui/compositor/layer.h"
17 #include "ui/compositor/test/context_factories_for_test.h" 16 #include "ui/compositor/test/context_factories_for_test.h"
18 #include "ui/compositor/test/draw_waiter_for_test.h" 17 #include "ui/compositor/test/draw_waiter_for_test.h"
19 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/gfx_paths.h" 19 #include "ui/gfx/gfx_paths.h"
21 #include "ui/gfx/image/image.h" 20 #include "ui/gfx/image/image.h"
22 #include "ui/gfx/rect.h" 21 #include "ui/gfx/rect.h"
23 #include "ui/gfx/size_conversions.h" 22 #include "ui/gfx/size_conversions.h"
24 #include "ui/gfx/transform.h" 23 #include "ui/gfx/transform.h"
25 #include "ui/gl/gl_implementation.h" 24 #include "ui/gl/gl_implementation.h"
25 #include "ui/wm/test/wm_test_helper.h"
26 26
27 namespace ui { 27 namespace ui {
28 namespace { 28 namespace {
29 29
30 SkColor GetExpectedColorForPoint(int x, int y) { 30 SkColor GetExpectedColorForPoint(int x, int y) {
31 return SkColorSetRGB(std::min(x, 255), std::min(y, 255), 0); 31 return SkColorSetRGB(std::min(x, 255), std::min(y, 255), 0);
32 } 32 }
33 33
34 // Paint simple rectangle on the specified aura window. 34 // Paint simple rectangle on the specified aura window.
35 class TestPaintingWindowDelegate : public aura::test::TestWindowDelegate { 35 class TestPaintingWindowDelegate : public aura::test::TestWindowDelegate {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 virtual ~SnapshotAuraTest() {} 83 virtual ~SnapshotAuraTest() {}
84 84
85 virtual void SetUp() OVERRIDE { 85 virtual void SetUp() OVERRIDE {
86 testing::Test::SetUp(); 86 testing::Test::SetUp();
87 87
88 // The ContextFactory must exist before any Compositors are created. 88 // The ContextFactory must exist before any Compositors are created.
89 // Snapshot test tests real drawing and readback, so needs pixel output. 89 // Snapshot test tests real drawing and readback, so needs pixel output.
90 bool enable_pixel_output = true; 90 bool enable_pixel_output = true;
91 ui::InitializeContextFactoryForTests(enable_pixel_output); 91 ui::InitializeContextFactoryForTests(enable_pixel_output);
92 92
93 helper_.reset( 93 helper_.reset(new ::wm::WMTestHelper);
94 new aura::test::AuraTestHelper(base::MessageLoopForUI::current()));
95 helper_->SetUp(); 94 helper_->SetUp();
96 } 95 }
97 96
98 virtual void TearDown() OVERRIDE { 97 virtual void TearDown() OVERRIDE {
99 test_window_.reset(); 98 test_window_.reset();
100 delegate_.reset(); 99 delegate_.reset();
101 helper_->RunAllPendingInMessageLoop(); 100 helper_->RunAllPendingInMessageLoop();
102 helper_->TearDown(); 101 helper_->TearDown();
103 ui::TerminateContextFactoryForTests(); 102 ui::TerminateContextFactoryForTests();
104 testing::Test::TearDown(); 103 testing::Test::TearDown();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 164
166 private: 165 private:
167 friend class base::RefCountedThreadSafe<SnapshotHolder>; 166 friend class base::RefCountedThreadSafe<SnapshotHolder>;
168 167
169 virtual ~SnapshotHolder() {} 168 virtual ~SnapshotHolder() {}
170 169
171 gfx::Image image_; 170 gfx::Image image_;
172 bool completed_; 171 bool completed_;
173 }; 172 };
174 173
175 scoped_ptr<aura::test::AuraTestHelper> helper_; 174 scoped_ptr< ::wm::WMTestHelper> helper_;
176 scoped_ptr<aura::Window> test_window_; 175 scoped_ptr<aura::Window> test_window_;
177 scoped_ptr<TestPaintingWindowDelegate> delegate_; 176 scoped_ptr<TestPaintingWindowDelegate> delegate_;
178 std::vector<unsigned char> png_representation_; 177 std::vector<unsigned char> png_representation_;
179 178
180 DISALLOW_COPY_AND_ASSIGN(SnapshotAuraTest); 179 DISALLOW_COPY_AND_ASSIGN(SnapshotAuraTest);
181 }; 180 };
182 181
183 TEST_F(SnapshotAuraTest, FullScreenWindow) { 182 TEST_F(SnapshotAuraTest, FullScreenWindow) {
184 SetupTestWindow(root_window()->bounds()); 183 SetupTestWindow(root_window()->bounds());
185 WaitForDraw(); 184 WaitForDraw();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 gfx::SizeF snapshot_size(test_bounds.size()); 277 gfx::SizeF snapshot_size(test_bounds.size());
279 snapshot_size.Scale(2.0f); 278 snapshot_size.Scale(2.0f);
280 279
281 gfx::Image snapshot = GrabSnapshotForTestWindow(); 280 gfx::Image snapshot = GrabSnapshotForTestWindow();
282 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), 281 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(),
283 snapshot.Size().ToString()); 282 snapshot.Size().ToString());
284 EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); 283 EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2));
285 } 284 }
286 285
287 } // namespace ui 286 } // namespace ui
OLDNEW
« no previous file with comments | « ui/snapshot/snapshot.gyp ('k') | ui/views/test/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698