Index: components/open_from_clipboard/clipboard_recent_content_ios_unittest.mm |
diff --git a/components/open_from_clipboard/clipboard_recent_content_ios_unittest.mm b/components/open_from_clipboard/clipboard_recent_content_ios_unittest.mm |
index 8f47b4513c312a9b59a48e94423309aaa2c4c238..39f127e7c3e36a1b02bca844b4fada507af88446 100644 |
--- a/components/open_from_clipboard/clipboard_recent_content_ios_unittest.mm |
+++ b/components/open_from_clipboard/clipboard_recent_content_ios_unittest.mm |
@@ -4,6 +4,7 @@ |
#include "components/open_from_clipboard/clipboard_recent_content_ios.h" |
+#import <CoreGraphics/CoreGraphics.h> |
#import <UIKit/UIKit.h> |
#include <memory> |
@@ -13,6 +14,20 @@ |
namespace { |
+UIImage* TestUIImage() { |
+ CGRect frame = CGRectMake(0, 0, 1.0, 1.0); |
+ UIGraphicsBeginImageContext(frame.size); |
+ |
+ CGContextRef context = UIGraphicsGetCurrentContext(); |
+ CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor); |
+ CGContextFillRect(context, frame); |
+ |
+ UIImage* image = UIGraphicsGetImageFromCurrentImageContext(); |
+ UIGraphicsEndImageContext(); |
+ |
+ return image; |
+} |
+ |
void SetPasteboardImage(UIImage* image) { |
[[UIPasteboard generalPasteboard] setImage:image]; |
} |
@@ -154,7 +169,7 @@ TEST_F(ClipboardRecentContentIOSTest, AddingNonStringRemovesCachedString) { |
// Overwrite pasteboard with an image. |
base::scoped_nsobject<UIImage> image([[UIImage alloc] init]); |
- SetPasteboardImage(image); |
+ SetPasteboardImage(TestUIImage()); |
// Pasteboard should appear empty. |
EXPECT_FALSE(clipboard_content_->GetRecentURLFromClipboard(&gurl)); |