| 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 "content/browser/renderer_host/clipboard_message_filter.h" | 5 #include "content/browser/renderer_host/clipboard_message_filter.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 CallCommitWrite(); | 96 CallCommitWrite(); |
| 97 | 97 |
| 98 EXPECT_NE(sequence_number, | 98 EXPECT_NE(sequence_number, |
| 99 clipboard()->GetSequenceNumber(ui::CLIPBOARD_TYPE_COPY_PASTE)); | 99 clipboard()->GetSequenceNumber(ui::CLIPBOARD_TYPE_COPY_PASTE)); |
| 100 EXPECT_FALSE(clipboard()->IsFormatAvailable( | 100 EXPECT_FALSE(clipboard()->IsFormatAvailable( |
| 101 ui::Clipboard::GetPlainTextFormatType(), ui::CLIPBOARD_TYPE_COPY_PASTE)); | 101 ui::Clipboard::GetPlainTextFormatType(), ui::CLIPBOARD_TYPE_COPY_PASTE)); |
| 102 EXPECT_TRUE(clipboard()->IsFormatAvailable( | 102 EXPECT_TRUE(clipboard()->IsFormatAvailable( |
| 103 ui::Clipboard::GetBitmapFormatType(), ui::CLIPBOARD_TYPE_COPY_PASTE)); | 103 ui::Clipboard::GetBitmapFormatType(), ui::CLIPBOARD_TYPE_COPY_PASTE)); |
| 104 | 104 |
| 105 SkBitmap actual = clipboard()->ReadImage(ui::CLIPBOARD_TYPE_COPY_PASTE); | 105 SkBitmap actual = clipboard()->ReadImage(ui::CLIPBOARD_TYPE_COPY_PASTE); |
| 106 SkAutoLockPixels locked(actual); | |
| 107 EXPECT_EQ(sizeof(bitmap_data), actual.getSize()); | 106 EXPECT_EQ(sizeof(bitmap_data), actual.getSize()); |
| 108 EXPECT_EQ(0, | 107 EXPECT_EQ(0, |
| 109 memcmp(bitmap_data, actual.getAddr32(0, 0), sizeof(bitmap_data))); | 108 memcmp(bitmap_data, actual.getAddr32(0, 0), sizeof(bitmap_data))); |
| 110 } | 109 } |
| 111 | 110 |
| 112 // Test with a size that would overflow a naive 32-bit row bytes calculation. | 111 // Test with a size that would overflow a naive 32-bit row bytes calculation. |
| 113 TEST_F(ClipboardMessageFilterTest, ImageSizeOverflows32BitRowBytes) { | 112 TEST_F(ClipboardMessageFilterTest, ImageSizeOverflows32BitRowBytes) { |
| 114 std::unique_ptr<base::SharedMemory> shared_memory = | 113 std::unique_ptr<base::SharedMemory> shared_memory = |
| 115 CreateReadOnlySharedMemory(0x20000000); | 114 CreateReadOnlySharedMemory(0x20000000); |
| 116 | 115 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 127 CallWriteImageDirectly(gfx::Size(5, 5), base::SharedMemory::NULLHandle()); | 126 CallWriteImageDirectly(gfx::Size(5, 5), base::SharedMemory::NULLHandle()); |
| 128 uint64_t sequence_number = | 127 uint64_t sequence_number = |
| 129 clipboard()->GetSequenceNumber(ui::CLIPBOARD_TYPE_COPY_PASTE); | 128 clipboard()->GetSequenceNumber(ui::CLIPBOARD_TYPE_COPY_PASTE); |
| 130 CallCommitWrite(); | 129 CallCommitWrite(); |
| 131 | 130 |
| 132 EXPECT_EQ(sequence_number, | 131 EXPECT_EQ(sequence_number, |
| 133 clipboard()->GetSequenceNumber(ui::CLIPBOARD_TYPE_COPY_PASTE)); | 132 clipboard()->GetSequenceNumber(ui::CLIPBOARD_TYPE_COPY_PASTE)); |
| 134 } | 133 } |
| 135 | 134 |
| 136 } // namespace content | 135 } // namespace content |
| OLD | NEW |