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

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

Issue 126373002: Make ChromeOS screenshots use async readback path (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix rebase error Created 6 years, 11 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_aura.cc ('k') | ui/snapshot/snapshot_gtk.cc » ('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/root_window.h" 10 #include "ui/aura/root_window.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // Callback never called. 132 // Callback never called.
133 NOTREACHED(); 133 NOTREACHED();
134 return gfx::Image(); 134 return gfx::Image();
135 } 135 }
136 136
137 private: 137 private:
138 class SnapshotHolder : public base::RefCountedThreadSafe<SnapshotHolder> { 138 class SnapshotHolder : public base::RefCountedThreadSafe<SnapshotHolder> {
139 public: 139 public:
140 SnapshotHolder() : completed_(false) {} 140 SnapshotHolder() : completed_(false) {}
141 141
142 void SnapshotCallback(const gfx::Image& image) { 142 void SnapshotCallback(scoped_refptr<base::RefCountedBytes> png_data) {
143 DCHECK(!completed_); 143 DCHECK(!completed_);
144 image_ = image; 144 image_ = gfx::Image::CreateFrom1xPNGBytes(&(png_data->data()[0]),
145 png_data->size());
145 completed_ = true; 146 completed_ = true;
146 } 147 }
147 bool completed() const { 148 bool completed() const {
148 return completed_; 149 return completed_;
149 }; 150 };
150 const gfx::Image& image() const { return image_; } 151 const gfx::Image& image() const { return image_; }
151 152
152 private: 153 private:
153 friend class base::RefCountedThreadSafe<SnapshotHolder>; 154 friend class base::RefCountedThreadSafe<SnapshotHolder>;
154 155
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 gfx::SizeF snapshot_size(test_bounds.size()); 271 gfx::SizeF snapshot_size(test_bounds.size());
271 snapshot_size.Scale(2.0f / kUIScale); 272 snapshot_size.Scale(2.0f / kUIScale);
272 273
273 gfx::Image snapshot = GrabSnapshotForTestWindow(); 274 gfx::Image snapshot = GrabSnapshotForTestWindow();
274 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(), 275 EXPECT_EQ(gfx::ToRoundedSize(snapshot_size).ToString(),
275 snapshot.Size().ToString()); 276 snapshot.Size().ToString());
276 EXPECT_EQ(0u, GetFailedPixelsCount(snapshot)); 277 EXPECT_EQ(0u, GetFailedPixelsCount(snapshot));
277 } 278 }
278 279
279 } // namespace ui 280 } // namespace ui
OLDNEW
« no previous file with comments | « ui/snapshot/snapshot_aura.cc ('k') | ui/snapshot/snapshot_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698