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

Unified Diff: components/open_from_clipboard/clipboard_recent_content_ios_unittest.mm

Issue 1804143005: Reverts a temporary fix for UIPasteboard on iOS 9 beta 5. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added test Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/open_from_clipboard/clipboard_recent_content_ios.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
+}
« no previous file with comments | « components/open_from_clipboard/clipboard_recent_content_ios.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698