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

Side by Side Diff: ppapi/tests/test_flash_clipboard.cc

Issue 10539028: Only paste the fragment of text which was copied to the clipboard. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: . Created 8 years, 5 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 | « no previous file | ui/base/clipboard/clipboard_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ppapi/tests/test_flash_clipboard.h" 5 #include "ppapi/tests/test_flash_clipboard.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ppapi/cpp/instance.h" 10 #include "ppapi/cpp/instance.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 PlatformSleep(kIntervalMs); 90 PlatformSleep(kIntervalMs);
91 } 91 }
92 return false; 92 return false;
93 } 93 }
94 94
95 bool TestFlashClipboard::ReadHTMLMatches(const std::string& expected) { 95 bool TestFlashClipboard::ReadHTMLMatches(const std::string& expected) {
96 for (int i = 0; i < kMaxIntervals; ++i) { 96 for (int i = 0; i < kMaxIntervals; ++i) {
97 std::string result; 97 std::string result;
98 bool success = ReadStringVar(PP_FLASH_CLIPBOARD_FORMAT_HTML, &result); 98 bool success = ReadStringVar(PP_FLASH_CLIPBOARD_FORMAT_HTML, &result);
99 // Markup is inserted around the copied html, so just check that 99 // Harmless markup may be inserted around the copied html on some
100 // the pasted string contains the copied string. 100 // platforms, so just check that the pasted string contains the
101 if (success && result.find(expected) != std::string::npos) 101 // copied string. Also check that we only paste the copied fragment, see
102 // http://code.google.com/p/chromium/issues/detail?id=130827.
103 if (success && result.find(expected) != std::string::npos &&
104 result.find("<!--StartFragment-->") == std::string::npos &&
105 result.find("<!--EndFragment-->") == std::string::npos) {
102 return true; 106 return true;
107 }
103 108
104 PlatformSleep(kIntervalMs); 109 PlatformSleep(kIntervalMs);
105 } 110 }
106 return false; 111 return false;
107 } 112 }
108 113
109 std::string TestFlashClipboard::TestReadWritePlainText() { 114 std::string TestFlashClipboard::TestReadWritePlainText() {
110 std::string input = "Hello world plain text!"; 115 std::string input = "Hello world plain text!";
111 ASSERT_TRUE(WriteStringVar(PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT, input)); 116 ASSERT_TRUE(WriteStringVar(PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT, input));
112 ASSERT_TRUE(IsFormatAvailableMatches(PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT, 117 ASSERT_TRUE(IsFormatAvailableMatches(PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 std::string TestFlashClipboard::TestInvalidFormat() { 207 std::string TestFlashClipboard::TestInvalidFormat() {
203 PP_Flash_Clipboard_Format invalid_format = 208 PP_Flash_Clipboard_Format invalid_format =
204 static_cast<PP_Flash_Clipboard_Format>(-1); 209 static_cast<PP_Flash_Clipboard_Format>(-1);
205 ASSERT_FALSE(WriteStringVar(invalid_format, "text")); 210 ASSERT_FALSE(WriteStringVar(invalid_format, "text"));
206 ASSERT_TRUE(IsFormatAvailableMatches(invalid_format, false)); 211 ASSERT_TRUE(IsFormatAvailableMatches(invalid_format, false));
207 std::string unused; 212 std::string unused;
208 ASSERT_FALSE(ReadStringVar(invalid_format, &unused)); 213 ASSERT_FALSE(ReadStringVar(invalid_format, &unused));
209 214
210 PASS(); 215 PASS();
211 } 216 }
OLDNEW
« no previous file with comments | « no previous file | ui/base/clipboard/clipboard_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698