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

Side by Side Diff: ui/base/clipboard/clipboard_unittest.cc

Issue 8429022: Adjust fragment indices appropriately when pasting HTML on Windows. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: . Created 9 years, 1 month 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_win.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 clipboard.ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result, 136 clipboard.ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result,
137 &ignored, &ignored); 137 &ignored, &ignored);
138 EXPECT_PRED2(MarkupMatches, markup, markup_result); 138 EXPECT_PRED2(MarkupMatches, markup, markup_result);
139 #if defined(OS_WIN) 139 #if defined(OS_WIN)
140 // TODO(playmobil): It's not clear that non windows clipboards need to support 140 // TODO(playmobil): It's not clear that non windows clipboards need to support
141 // this. 141 // this.
142 EXPECT_EQ(url, url_result); 142 EXPECT_EQ(url, url_result);
143 #endif // defined(OS_WIN) 143 #endif // defined(OS_WIN)
144 } 144 }
145 145
146 #if defined(OS_WIN)
147 TEST_F(ClipboardTest, UniodeHTMLTest) {
148 Clipboard clipboard;
149
150 string16 markup(UTF8ToUTF16("<div>A \xc3\xb8 \xe6\xb0\xb4</div>")),
151 markup_result;
152 std::string url, url_result;
153
154 {
155 ScopedClipboardWriter clipboard_writer(&clipboard);
156 clipboard_writer.WriteHTML(markup, url);
157 }
158
159 EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetHtmlFormatType(),
160 Clipboard::BUFFER_STANDARD));
161 uint32 fragment_start;
162 uint32 fragment_end;
163 clipboard.ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result,
164 &fragment_start, &fragment_end);
165 EXPECT_PRED2(MarkupMatches, markup, markup_result);
166 EXPECT_EQ(url, url_result);
167 // Make sure that fragment indices were adjusted when converting.
168 EXPECT_EQ(36, fragment_start);
169 EXPECT_EQ(56, fragment_end);
170 }
171 #endif // defined(OS_WIN)
172
146 #if defined(TOOLKIT_USES_GTK) 173 #if defined(TOOLKIT_USES_GTK)
147 // Regression test for crbug.com/56298 (pasting empty HTML crashes Linux). 174 // Regression test for crbug.com/56298 (pasting empty HTML crashes Linux).
148 TEST_F(ClipboardTest, EmptyHTMLTest) { 175 TEST_F(ClipboardTest, EmptyHTMLTest) {
149 Clipboard clipboard; 176 Clipboard clipboard;
150 // ScopedClipboardWriter doesn't let us write empty data to the clipboard. 177 // ScopedClipboardWriter doesn't let us write empty data to the clipboard.
151 clipboard.clipboard_data_ = new Clipboard::TargetMap(); 178 clipboard.clipboard_data_ = new Clipboard::TargetMap();
152 // The 1 is so the compiler doesn't warn about allocating an empty array. 179 // The 1 is so the compiler doesn't warn about allocating an empty array.
153 char* empty = new char[1]; 180 char* empty = new char[1];
154 clipboard.InsertMapping("text/html", empty, 0U); 181 clipboard.InsertMapping("text/html", empty, 0U);
155 clipboard.SetGtkClipboard(); 182 clipboard.SetGtkClipboard();
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 writer.WriteBookmark(UTF8ToUTF16("foo"), "bar"); 571 writer.WriteBookmark(UTF8ToUTF16("foo"), "bar");
545 writer.WriteHyperlink(ASCIIToUTF16("foo"), "bar"); 572 writer.WriteHyperlink(ASCIIToUTF16("foo"), "bar");
546 writer.WriteWebSmartPaste(); 573 writer.WriteWebSmartPaste();
547 // Left out: WriteFile, WriteFiles, WriteBitmapFromPixels, WritePickledData. 574 // Left out: WriteFile, WriteFiles, WriteBitmapFromPixels, WritePickledData.
548 } 575 }
549 576
550 // Passes if we don't crash. 577 // Passes if we don't crash.
551 } 578 }
552 579
553 } // namespace ui 580 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/base/clipboard/clipboard_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698