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

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: Rebase. 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
« no previous file with comments | « ui/base/clipboard/clipboard_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 int32_t height = 101; 51 int32_t height = 101;
52 scoped_refptr<ui::UniquePasteboard> pasteboard = new ui::UniquePasteboard; 52 scoped_refptr<ui::UniquePasteboard> pasteboard = new ui::UniquePasteboard;
53 base::scoped_nsobject<NSImage> image = CreateImage(width, height, true); 53 base::scoped_nsobject<NSImage> image = CreateImage(width, height, true);
54 [pasteboard->get() writeObjects:@[ image.get() ]]; 54 [pasteboard->get() writeObjects:@[ image.get() ]];
55 55
56 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 56 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
57 ui::ClipboardMac* clipboard_mac = static_cast<ui::ClipboardMac*>(clipboard); 57 ui::ClipboardMac* clipboard_mac = static_cast<ui::ClipboardMac*>(clipboard);
58 58
59 SkBitmap bitmap = clipboard_mac->ReadImage(ui::CLIPBOARD_TYPE_COPY_PASTE, 59 SkBitmap bitmap = clipboard_mac->ReadImage(ui::CLIPBOARD_TYPE_COPY_PASTE,
60 pasteboard->get()); 60 pasteboard->get());
61 EXPECT_EQ(width, bitmap.width()); 61 EXPECT_EQ(2 * width, bitmap.width());
62 EXPECT_EQ(height, bitmap.height()); 62 EXPECT_EQ(2 * height, bitmap.height());
63 } 63 }
64 64
65 TEST_F(ClipboardMacTest, ReadImageNonRetina) { 65 TEST_F(ClipboardMacTest, ReadImageNonRetina) {
66 int32_t width = 99; 66 int32_t width = 99;
67 int32_t height = 101; 67 int32_t height = 101;
68 scoped_refptr<ui::UniquePasteboard> pasteboard = new ui::UniquePasteboard; 68 scoped_refptr<ui::UniquePasteboard> pasteboard = new ui::UniquePasteboard;
69 base::scoped_nsobject<NSImage> image = CreateImage(width, height, false); 69 base::scoped_nsobject<NSImage> image = CreateImage(width, height, false);
70 [pasteboard->get() writeObjects:@[ image.get() ]]; 70 [pasteboard->get() writeObjects:@[ image.get() ]];
71 71
72 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 72 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
73 ui::ClipboardMac* clipboard_mac = static_cast<ui::ClipboardMac*>(clipboard); 73 ui::ClipboardMac* clipboard_mac = static_cast<ui::ClipboardMac*>(clipboard);
74 74
75 SkBitmap bitmap = clipboard_mac->ReadImage(ui::CLIPBOARD_TYPE_COPY_PASTE, 75 SkBitmap bitmap = clipboard_mac->ReadImage(ui::CLIPBOARD_TYPE_COPY_PASTE,
76 pasteboard->get()); 76 pasteboard->get());
77 EXPECT_EQ(width, bitmap.width()); 77 EXPECT_EQ(width, bitmap.width());
78 EXPECT_EQ(height, bitmap.height()); 78 EXPECT_EQ(height, bitmap.height());
79 } 79 }
80 80
81 } // namespace ui 81 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698