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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "components/open_from_clipboard/clipboard_recent_content_ios.h" 5 #include "components/open_from_clipboard/clipboard_recent_content_ios.h"
6 6
7 #import <UIKit/UIKit.h> 7 #import <UIKit/UIKit.h>
8 8
9 #include "base/ios/ios_util.h" 9 #include "base/ios/ios_util.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/platform_test.h" 12 #include "testing/platform_test.h"
13 13
14 namespace { 14 namespace {
15
16 void SetPasteboardImage(UIImage* image) {
17 [[UIPasteboard generalPasteboard] setImage:image];
18 }
19
15 void SetPasteboardContent(const char* data) { 20 void SetPasteboardContent(const char* data) {
16 [[UIPasteboard generalPasteboard] 21 [[UIPasteboard generalPasteboard]
17 setValue:[NSString stringWithUTF8String:data] 22 setValue:[NSString stringWithUTF8String:data]
18 forPasteboardType:@"public.plain-text"]; 23 forPasteboardType:@"public.plain-text"];
19 } 24 }
20 const char kUnrecognizedURL[] = "ftp://foo/"; 25 const char kUnrecognizedURL[] = "ftp://foo/";
21 const char kRecognizedURL[] = "http://bar/"; 26 const char kRecognizedURL[] = "http://bar/";
22 const char kAppSpecificURL[] = "test://qux/"; 27 const char kAppSpecificURL[] = "test://qux/";
23 const char kAppSpecificScheme[] = "test"; 28 const char kAppSpecificScheme[] = "test";
24 NSTimeInterval kSevenHours = 60 * 60 * 7; 29 NSTimeInterval kSevenHours = 60 * 60 * 7;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Check that the even if the device is restarted, pasteboard content is 142 // Check that the even if the device is restarted, pasteboard content is
138 // still suppressed. 143 // still suppressed.
139 SimulateDeviceRestart(); 144 SimulateDeviceRestart();
140 EXPECT_FALSE(clipboard_content_->GetRecentURLFromClipboard(&gurl)); 145 EXPECT_FALSE(clipboard_content_->GetRecentURLFromClipboard(&gurl));
141 146
142 // Check that if the pasteboard changes, the new content is not 147 // Check that if the pasteboard changes, the new content is not
143 // supressed anymore. 148 // supressed anymore.
144 SetPasteboardContent(kRecognizedURL); 149 SetPasteboardContent(kRecognizedURL);
145 EXPECT_TRUE(clipboard_content_->GetRecentURLFromClipboard(&gurl)); 150 EXPECT_TRUE(clipboard_content_->GetRecentURLFromClipboard(&gurl));
146 } 151 }
152
153 // Checks that if user copies something other than a string we don't cache the
154 // string in pasteboard.
155 TEST_F(ClipboardRecentContentIOSTest, AddingNonStringRemovesCachedString) {
156 GURL gurl;
157 SetPasteboardContent(kRecognizedURL);
158
159 // Test that recent pasteboard data is provided.
160 EXPECT_TRUE(clipboard_content_->GetRecentURLFromClipboard(&gurl));
161 EXPECT_STREQ(kRecognizedURL, gurl.spec().c_str());
162
163 // Overwrite pasteboard with an image.
164 base::scoped_nsobject<UIImage> image([[UIImage alloc] init]);
165 SetPasteboardImage(image);
166
167 // Pasteboard should appear empty.
168 EXPECT_FALSE(clipboard_content_->GetRecentURLFromClipboard(&gurl));
169
170 // Tests that if URL is added again, pasteboard provides it normally.
171 SetPasteboardContent(kRecognizedURL);
172 EXPECT_TRUE(clipboard_content_->GetRecentURLFromClipboard(&gurl));
173 EXPECT_STREQ(kRecognizedURL, gurl.spec().c_str());
174 }
OLDNEW
« 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