Commit 850dda6b authored by rohitrao's avatar rohitrao Committed by Commit bot

Fixes ClipboardRecentContentIOSTest on iOS 10.

AddingNonStringRemovesCachedString was failing because it is now an error to
copy an empty UIImage to the pasteboard.

BUG=626686

Review-Url: https://codereview.chromium.org/2134853002
Cr-Commit-Position: refs/heads/master@{#404586}
parent 164d0463
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "components/open_from_clipboard/clipboard_recent_content_ios.h" #include "components/open_from_clipboard/clipboard_recent_content_ios.h"
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#include <memory> #include <memory>
...@@ -13,6 +14,20 @@ ...@@ -13,6 +14,20 @@
namespace { 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) { void SetPasteboardImage(UIImage* image) {
[[UIPasteboard generalPasteboard] setImage:image]; [[UIPasteboard generalPasteboard] setImage:image];
} }
...@@ -154,7 +169,7 @@ TEST_F(ClipboardRecentContentIOSTest, AddingNonStringRemovesCachedString) { ...@@ -154,7 +169,7 @@ TEST_F(ClipboardRecentContentIOSTest, AddingNonStringRemovesCachedString) {
// Overwrite pasteboard with an image. // Overwrite pasteboard with an image.
base::scoped_nsobject<UIImage> image([[UIImage alloc] init]); base::scoped_nsobject<UIImage> image([[UIImage alloc] init]);
SetPasteboardImage(image); SetPasteboardImage(TestUIImage());
// Pasteboard should appear empty. // Pasteboard should appear empty.
EXPECT_FALSE(clipboard_content_->GetRecentURLFromClipboard(&gurl)); EXPECT_FALSE(clipboard_content_->GetRecentURLFromClipboard(&gurl));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment