| OLD | NEW |
| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 Clipboard::BUFFER_STANDARD)); | 135 Clipboard::BUFFER_STANDARD)); |
| 136 clipboard.ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result); | 136 clipboard.ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result); |
| 137 EXPECT_TRUE(ClipboardContentsIsExpected(markup, markup_result)); | 137 EXPECT_TRUE(ClipboardContentsIsExpected(markup, markup_result)); |
| 138 #if defined(OS_WIN) | 138 #if defined(OS_WIN) |
| 139 // TODO(playmobil): It's not clear that non windows clipboards need to support | 139 // TODO(playmobil): It's not clear that non windows clipboards need to support |
| 140 // this. | 140 // this. |
| 141 EXPECT_EQ(url, url_result); | 141 EXPECT_EQ(url, url_result); |
| 142 #endif // defined(OS_WIN) | 142 #endif // defined(OS_WIN) |
| 143 } | 143 } |
| 144 | 144 |
| 145 #if defined(OS_LINUX) | 145 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 146 // Regression test for crbug.com/56298 (pasting empty HTML crashes Linux). | 146 // Regression test for crbug.com/56298 (pasting empty HTML crashes Linux). |
| 147 TEST_F(ClipboardTest, EmptyHTMLTest) { | 147 TEST_F(ClipboardTest, EmptyHTMLTest) { |
| 148 Clipboard clipboard; | 148 Clipboard clipboard; |
| 149 // ScopedClipboardWriter doesn't let us write empty data to the clipboard. | 149 // ScopedClipboardWriter doesn't let us write empty data to the clipboard. |
| 150 clipboard.clipboard_data_ = new Clipboard::TargetMap(); | 150 clipboard.clipboard_data_ = new Clipboard::TargetMap(); |
| 151 // The 1 is so the compiler doesn't warn about allocating an empty array. | 151 // The 1 is so the compiler doesn't warn about allocating an empty array. |
| 152 char* empty = new char[1]; | 152 char* empty = new char[1]; |
| 153 clipboard.InsertMapping("text/html", empty, 0U); | 153 clipboard.InsertMapping("text/html", empty, 0U); |
| 154 clipboard.SetGtkClipboard(); | 154 clipboard.SetGtkClipboard(); |
| 155 | 155 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 Clipboard::BUFFER_STANDARD)); | 232 Clipboard::BUFFER_STANDARD)); |
| 233 string16 text_result; | 233 string16 text_result; |
| 234 clipboard.ReadText(Clipboard::BUFFER_STANDARD, &text_result); | 234 clipboard.ReadText(Clipboard::BUFFER_STANDARD, &text_result); |
| 235 | 235 |
| 236 EXPECT_EQ(text_result, url); | 236 EXPECT_EQ(text_result, url); |
| 237 | 237 |
| 238 std::string ascii_text; | 238 std::string ascii_text; |
| 239 clipboard.ReadAsciiText(Clipboard::BUFFER_STANDARD, &ascii_text); | 239 clipboard.ReadAsciiText(Clipboard::BUFFER_STANDARD, &ascii_text); |
| 240 EXPECT_EQ(UTF16ToUTF8(url), ascii_text); | 240 EXPECT_EQ(UTF16ToUTF8(url), ascii_text); |
| 241 | 241 |
| 242 #if defined(OS_LINUX) | 242 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 243 ascii_text.clear(); | 243 ascii_text.clear(); |
| 244 clipboard.ReadAsciiText(Clipboard::BUFFER_SELECTION, &ascii_text); | 244 clipboard.ReadAsciiText(Clipboard::BUFFER_SELECTION, &ascii_text); |
| 245 EXPECT_EQ(UTF16ToUTF8(url), ascii_text); | 245 EXPECT_EQ(UTF16ToUTF8(url), ascii_text); |
| 246 #endif // defined(OS_LINUX) | 246 #endif |
| 247 } | 247 } |
| 248 | 248 |
| 249 TEST_F(ClipboardTest, SharedBitmapTest) { | 249 TEST_F(ClipboardTest, SharedBitmapTest) { |
| 250 unsigned int fake_bitmap[] = { | 250 unsigned int fake_bitmap[] = { |
| 251 0x46155189, 0xF6A55C8D, 0x79845674, 0xFA57BD89, | 251 0x46155189, 0xF6A55C8D, 0x79845674, 0xFA57BD89, |
| 252 0x78FD46AE, 0x87C64F5A, 0x36EDC5AF, 0x4378F568, | 252 0x78FD46AE, 0x87C64F5A, 0x36EDC5AF, 0x4378F568, |
| 253 0x91E9F63A, 0xC31EA14F, 0x69AB32DF, 0x643A3FD1, | 253 0x91E9F63A, 0xC31EA14F, 0x69AB32DF, 0x643A3FD1, |
| 254 }; | 254 }; |
| 255 gfx::Size fake_bitmap_size(3, 4); | 255 gfx::Size fake_bitmap_size(3, 4); |
| 256 uint32 bytes = sizeof(fake_bitmap); | 256 uint32 bytes = sizeof(fake_bitmap); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 writer.WriteBookmark(UTF8ToUTF16("foo"), "bar"); | 423 writer.WriteBookmark(UTF8ToUTF16("foo"), "bar"); |
| 424 writer.WriteHyperlink(ASCIIToUTF16("foo"), "bar"); | 424 writer.WriteHyperlink(ASCIIToUTF16("foo"), "bar"); |
| 425 writer.WriteWebSmartPaste(); | 425 writer.WriteWebSmartPaste(); |
| 426 // Left out: WriteFile, WriteFiles, WriteBitmapFromPixels, WritePickledData. | 426 // Left out: WriteFile, WriteFiles, WriteBitmapFromPixels, WritePickledData. |
| 427 } | 427 } |
| 428 | 428 |
| 429 // Passes if we don't crash. | 429 // Passes if we don't crash. |
| 430 } | 430 } |
| 431 | 431 |
| 432 } // namespace ui | 432 } // namespace ui |
| OLD | NEW |