OLD | NEW |
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/memory/scoped_ptr.h" | 9 #include <memory> |
| 10 |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "testing/platform_test.h" | 12 #include "testing/platform_test.h" |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 void SetPasteboardImage(UIImage* image) { | 16 void SetPasteboardImage(UIImage* image) { |
16 [[UIPasteboard generalPasteboard] setImage:image]; | 17 [[UIPasteboard generalPasteboard] setImage:image]; |
17 } | 18 } |
18 | 19 |
19 void SetPasteboardContent(const char* data) { | 20 void SetPasteboardContent(const char* data) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 clipboard_content_->last_pasteboard_change_date_.reset([changeDate copy]); | 52 clipboard_content_->last_pasteboard_change_date_.reset([changeDate copy]); |
52 clipboard_content_->SaveToUserDefaults(); | 53 clipboard_content_->SaveToUserDefaults(); |
53 } | 54 } |
54 | 55 |
55 void SetStoredPasteboardChangeCount(NSInteger newChangeCount) { | 56 void SetStoredPasteboardChangeCount(NSInteger newChangeCount) { |
56 clipboard_content_->last_pasteboard_change_count_ = newChangeCount; | 57 clipboard_content_->last_pasteboard_change_count_ = newChangeCount; |
57 clipboard_content_->SaveToUserDefaults(); | 58 clipboard_content_->SaveToUserDefaults(); |
58 } | 59 } |
59 | 60 |
60 protected: | 61 protected: |
61 scoped_ptr<ClipboardRecentContentIOS> clipboard_content_; | 62 std::unique_ptr<ClipboardRecentContentIOS> clipboard_content_; |
62 }; | 63 }; |
63 | 64 |
64 TEST_F(ClipboardRecentContentIOSTest, SchemeFiltering) { | 65 TEST_F(ClipboardRecentContentIOSTest, SchemeFiltering) { |
65 GURL gurl; | 66 GURL gurl; |
66 | 67 |
67 // Test unrecognized URL. | 68 // Test unrecognized URL. |
68 SetPasteboardContent(kUnrecognizedURL); | 69 SetPasteboardContent(kUnrecognizedURL); |
69 EXPECT_FALSE(clipboard_content_->GetRecentURLFromClipboard(&gurl)); | 70 EXPECT_FALSE(clipboard_content_->GetRecentURLFromClipboard(&gurl)); |
70 | 71 |
71 // Test recognized URL. | 72 // Test recognized URL. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 SetPasteboardImage(image); | 157 SetPasteboardImage(image); |
157 | 158 |
158 // Pasteboard should appear empty. | 159 // Pasteboard should appear empty. |
159 EXPECT_FALSE(clipboard_content_->GetRecentURLFromClipboard(&gurl)); | 160 EXPECT_FALSE(clipboard_content_->GetRecentURLFromClipboard(&gurl)); |
160 | 161 |
161 // Tests that if URL is added again, pasteboard provides it normally. | 162 // Tests that if URL is added again, pasteboard provides it normally. |
162 SetPasteboardContent(kRecognizedURL); | 163 SetPasteboardContent(kRecognizedURL); |
163 EXPECT_TRUE(clipboard_content_->GetRecentURLFromClipboard(&gurl)); | 164 EXPECT_TRUE(clipboard_content_->GetRecentURLFromClipboard(&gurl)); |
164 EXPECT_STREQ(kRecognizedURL, gurl.spec().c_str()); | 165 EXPECT_STREQ(kRecognizedURL, gurl.spec().c_str()); |
165 } | 166 } |
OLD | NEW |