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 <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/macros.h" |
8 #include "base/test/test_simple_task_runner.h" | 12 #include "base/test/test_simple_task_runner.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/aura/test/aura_test_helper.h" | 14 #include "ui/aura/test/aura_test_helper.h" |
11 #include "ui/aura/test/test_screen.h" | 15 #include "ui/aura/test/test_screen.h" |
12 #include "ui/aura/test/test_window_delegate.h" | 16 #include "ui/aura/test/test_window_delegate.h" |
13 #include "ui/aura/test/test_windows.h" | 17 #include "ui/aura/test/test_windows.h" |
14 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
15 #include "ui/aura/window_event_dispatcher.h" | 19 #include "ui/aura/window_event_dispatcher.h" |
16 #include "ui/compositor/compositor.h" | 20 #include "ui/compositor/compositor.h" |
17 #include "ui/compositor/layer.h" | 21 #include "ui/compositor/layer.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 59 |
56 private: | 60 private: |
57 gfx::Size window_size_; | 61 gfx::Size window_size_; |
58 | 62 |
59 DISALLOW_COPY_AND_ASSIGN(TestPaintingWindowDelegate); | 63 DISALLOW_COPY_AND_ASSIGN(TestPaintingWindowDelegate); |
60 }; | 64 }; |
61 | 65 |
62 size_t GetFailedPixelsCountWithScaleFactor(const gfx::Image& image, | 66 size_t GetFailedPixelsCountWithScaleFactor(const gfx::Image& image, |
63 int scale_factor) { | 67 int scale_factor) { |
64 const SkBitmap* bitmap = image.ToSkBitmap(); | 68 const SkBitmap* bitmap = image.ToSkBitmap(); |
65 uint32* bitmap_data = reinterpret_cast<uint32*>( | 69 uint32_t* bitmap_data = |
66 bitmap->pixelRef()->pixels()); | 70 reinterpret_cast<uint32_t*>(bitmap->pixelRef()->pixels()); |
67 size_t result = 0; | 71 size_t result = 0; |
68 for (int y = 0; y < bitmap->height(); y += scale_factor) { | 72 for (int y = 0; y < bitmap->height(); y += scale_factor) { |
69 for (int x = 0; x < bitmap->width(); x += scale_factor) { | 73 for (int x = 0; x < bitmap->width(); x += scale_factor) { |
70 if (static_cast<SkColor>(bitmap_data[x + y * bitmap->width()]) != | 74 if (static_cast<SkColor>(bitmap_data[x + y * bitmap->width()]) != |
71 GetExpectedColorForPoint(x / scale_factor, y / scale_factor)) { | 75 GetExpectedColorForPoint(x / scale_factor, y / scale_factor)) { |
72 ++result; | 76 ++result; |
73 } | 77 } |
74 } | 78 } |
75 } | 79 } |
76 return result; | 80 return result; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 gfx::SizeF snapshot_size(test_bounds.size()); | 292 gfx::SizeF snapshot_size(test_bounds.size()); |
289 snapshot_size.Scale(2.0f); | 293 snapshot_size.Scale(2.0f); |
290 | 294 |
291 gfx::Image snapshot = GrabSnapshotForTestWindow(); | 295 gfx::Image snapshot = GrabSnapshotForTestWindow(); |
292 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), | 296 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), |
293 snapshot.Size().ToString()); | 297 snapshot.Size().ToString()); |
294 EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); | 298 EXPECT_EQ(0u, GetFailedPixelsCountWithScaleFactor(snapshot, 2)); |
295 } | 299 } |
296 | 300 |
297 } // namespace ui | 301 } // namespace ui |
OLD | NEW |