| 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 7626449fa4533649ccd9be98d1815e3dfe2b0044..391fd7081c640e3e3fa60a9aee0289807668e6da 100644
|
| --- a/components/open_from_clipboard/clipboard_recent_content_ios_unittest.mm
|
| +++ b/components/open_from_clipboard/clipboard_recent_content_ios_unittest.mm
|
| @@ -12,6 +12,11 @@
|
| #include "testing/platform_test.h"
|
|
|
| namespace {
|
| +
|
| +void SetPasteboardImage(UIImage* image) {
|
| + [[UIPasteboard generalPasteboard] setImage:image];
|
| +}
|
| +
|
| void SetPasteboardContent(const char* data) {
|
| [[UIPasteboard generalPasteboard]
|
| setValue:[NSString stringWithUTF8String:data]
|
| @@ -144,3 +149,26 @@ TEST_F(ClipboardRecentContentIOSTest, SupressedPasteboard) {
|
| SetPasteboardContent(kRecognizedURL);
|
| EXPECT_TRUE(clipboard_content_->GetRecentURLFromClipboard(&gurl));
|
| }
|
| +
|
| +// Checks that if user copies something other than a string we don't cache the
|
| +// string in pasteboard.
|
| +TEST_F(ClipboardRecentContentIOSTest, AddingNonStringRemovesCachedString) {
|
| + GURL gurl;
|
| + SetPasteboardContent(kRecognizedURL);
|
| +
|
| + // Test that recent pasteboard data is provided.
|
| + EXPECT_TRUE(clipboard_content_->GetRecentURLFromClipboard(&gurl));
|
| + EXPECT_STREQ(kRecognizedURL, gurl.spec().c_str());
|
| +
|
| + // Overwrite pasteboard with an image.
|
| + base::scoped_nsobject<UIImage> image([[UIImage alloc] init]);
|
| + SetPasteboardImage(image);
|
| +
|
| + // Pasteboard should appear empty.
|
| + EXPECT_FALSE(clipboard_content_->GetRecentURLFromClipboard(&gurl));
|
| +
|
| + // Tests that if URL is added again, pasteboard provides it normally.
|
| + SetPasteboardContent(kRecognizedURL);
|
| + EXPECT_TRUE(clipboard_content_->GetRecentURLFromClipboard(&gurl));
|
| + EXPECT_STREQ(kRecognizedURL, gurl.spec().c_str());
|
| +}
|
|
|