OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/base/test/test_clipboard.h" | 5 #include "ui/base/test/test_clipboard.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 178 } |
179 | 179 |
180 void TestClipboard::WriteWebSmartPaste() { | 180 void TestClipboard::WriteWebSmartPaste() { |
181 // Create a dummy entry. | 181 // Create a dummy entry. |
182 GetDefaultStore().data[GetWebKitSmartPasteFormatType()]; | 182 GetDefaultStore().data[GetWebKitSmartPasteFormatType()]; |
183 } | 183 } |
184 | 184 |
185 void TestClipboard::WriteBitmap(const SkBitmap& bitmap) { | 185 void TestClipboard::WriteBitmap(const SkBitmap& bitmap) { |
186 // Create a dummy entry. | 186 // Create a dummy entry. |
187 GetDefaultStore().data[GetBitmapFormatType()]; | 187 GetDefaultStore().data[GetBitmapFormatType()]; |
188 bitmap.copyTo(&GetDefaultStore().image); | 188 SkBitmap& dst = GetDefaultStore().image; |
| 189 if (dst.tryAllocPixels(bitmap.info())) { |
| 190 bitmap.readPixels(dst.info(), dst.getPixels(), dst.rowBytes(), 0, 0); |
| 191 } |
189 } | 192 } |
190 | 193 |
191 void TestClipboard::WriteData(const FormatType& format, | 194 void TestClipboard::WriteData(const FormatType& format, |
192 const char* data_data, | 195 const char* data_data, |
193 size_t data_len) { | 196 size_t data_len) { |
194 GetDefaultStore().data[format] = std::string(data_data, data_len); | 197 GetDefaultStore().data[format] = std::string(data_data, data_len); |
195 } | 198 } |
196 | 199 |
197 TestClipboard::DataStore::DataStore() : sequence_number(0) { | 200 TestClipboard::DataStore::DataStore() : sequence_number(0) { |
198 } | 201 } |
(...skipping 25 matching lines...) Expand all Loading... |
224 | 227 |
225 const TestClipboard::DataStore& TestClipboard::GetDefaultStore() const { | 228 const TestClipboard::DataStore& TestClipboard::GetDefaultStore() const { |
226 return GetStore(default_store_type_); | 229 return GetStore(default_store_type_); |
227 } | 230 } |
228 | 231 |
229 TestClipboard::DataStore& TestClipboard::GetDefaultStore() { | 232 TestClipboard::DataStore& TestClipboard::GetDefaultStore() { |
230 return GetStore(default_store_type_); | 233 return GetStore(default_store_type_); |
231 } | 234 } |
232 | 235 |
233 } // namespace ui | 236 } // namespace ui |
OLD | NEW |