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

Side by Side Diff: ui/base/clipboard/clipboard_mac_unittest.mm

Issue 2276183002: mac: Don't lose pixels when copying a retina image from the clipboard. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp85
Patch Set: Export ClipboardMac to fix link error. Created 4 years, 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #import "ui/base/clipboard/clipboard_mac.h" 5 #import "ui/base/clipboard/clipboard_mac.h"
6 6
7 #include "base/mac/scoped_cftyperef.h" 7 #include "base/mac/scoped_cftyperef.h"
8 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
9 #include "base/memory/free_deleter.h" 9 #include "base/memory/free_deleter.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 int32_t height = 101; 46 int32_t height = 101;
47 scoped_refptr<ui::UniquePasteboard> pasteboard = new ui::UniquePasteboard; 47 scoped_refptr<ui::UniquePasteboard> pasteboard = new ui::UniquePasteboard;
48 base::scoped_nsobject<NSImage> image = CreateImage(width, height, true); 48 base::scoped_nsobject<NSImage> image = CreateImage(width, height, true);
49 [pasteboard->get() writeObjects:@[ image.get() ]]; 49 [pasteboard->get() writeObjects:@[ image.get() ]];
50 50
51 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 51 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
52 ui::ClipboardMac* clipboard_mac = static_cast<ui::ClipboardMac*>(clipboard); 52 ui::ClipboardMac* clipboard_mac = static_cast<ui::ClipboardMac*>(clipboard);
53 53
54 SkBitmap bitmap = clipboard_mac->ReadImage(ui::CLIPBOARD_TYPE_COPY_PASTE, 54 SkBitmap bitmap = clipboard_mac->ReadImage(ui::CLIPBOARD_TYPE_COPY_PASTE,
55 pasteboard->get()); 55 pasteboard->get());
56 EXPECT_EQ(width, bitmap.width()); 56 EXPECT_EQ(2 * width, bitmap.width());
57 EXPECT_EQ(height, bitmap.height()); 57 EXPECT_EQ(2 * height, bitmap.height());
58 } 58 }
59 59
60 TEST_F(ClipboardMacTest, ReadImageNonRetina) { 60 TEST_F(ClipboardMacTest, ReadImageNonRetina) {
61 int32_t width = 99; 61 int32_t width = 99;
62 int32_t height = 101; 62 int32_t height = 101;
63 scoped_refptr<ui::UniquePasteboard> pasteboard = new ui::UniquePasteboard; 63 scoped_refptr<ui::UniquePasteboard> pasteboard = new ui::UniquePasteboard;
64 base::scoped_nsobject<NSImage> image = CreateImage(width, height, false); 64 base::scoped_nsobject<NSImage> image = CreateImage(width, height, false);
65 [pasteboard->get() writeObjects:@[ image.get() ]]; 65 [pasteboard->get() writeObjects:@[ image.get() ]];
66 66
67 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 67 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
68 ui::ClipboardMac* clipboard_mac = static_cast<ui::ClipboardMac*>(clipboard); 68 ui::ClipboardMac* clipboard_mac = static_cast<ui::ClipboardMac*>(clipboard);
69 69
70 SkBitmap bitmap = clipboard_mac->ReadImage(ui::CLIPBOARD_TYPE_COPY_PASTE, 70 SkBitmap bitmap = clipboard_mac->ReadImage(ui::CLIPBOARD_TYPE_COPY_PASTE,
71 pasteboard->get()); 71 pasteboard->get());
72 EXPECT_EQ(width, bitmap.width()); 72 EXPECT_EQ(width, bitmap.width());
73 EXPECT_EQ(height, bitmap.height()); 73 EXPECT_EQ(height, bitmap.height());
74 } 74 }
75 75
76 } // namespace ui 76 } // namespace ui
OLDNEW
« ui/base/clipboard/clipboard_mac.mm ('K') | « ui/base/clipboard/clipboard_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698