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

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

Issue 10829341: Desktop aura: Use the X11 clipboard (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix MessageLoop ordering in tests. Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ui/base/clipboard/clipboard_chromeos.cc ('k') | ui/base/x/x11_atom_cache.h » ('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 "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"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/pickle.h" 12 #include "base/pickle.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "testing/platform_test.h" 16 #include "testing/platform_test.h"
17 #include "third_party/skia/include/core/SkBitmap.h" 17 #include "third_party/skia/include/core/SkBitmap.h"
18 #include "ui/base/clipboard/clipboard.h" 18 #include "ui/base/clipboard/clipboard.h"
19 #include "ui/base/clipboard/scoped_clipboard_writer.h" 19 #include "ui/base/clipboard/scoped_clipboard_writer.h"
20 #include "ui/gfx/size.h" 20 #include "ui/gfx/size.h"
21 21
22 #if defined(OS_WIN) 22 #if defined(OS_WIN)
23 #include "ui/base/clipboard/clipboard_util_win.h" 23 #include "ui/base/clipboard/clipboard_util_win.h"
24 #endif 24 #endif
25 25
26 #if defined(OS_ANDROID) 26 #if defined(OS_ANDROID)
27 #include "base/android/jni_android.h" 27 #include "base/android/jni_android.h"
28 #endif 28 #endif
29 29
30 #if defined(OS_WIN) || defined(USE_AURA)
31 #include "base/message_loop.h"
32 #endif
33
30 namespace ui { 34 namespace ui {
31 35
32 class ClipboardTest : public PlatformTest { 36 class ClipboardTest : public PlatformTest {
33 protected: 37 protected:
34 Clipboard& clipboard() { return clipboard_; } 38 Clipboard& clipboard() { return clipboard_; }
35 39
36 private: 40 private:
37 MessageLoopForUI message_loop_; 41 MessageLoopForUI message_loop_;
38 Clipboard clipboard_; 42 Clipboard clipboard_;
39 }; 43 };
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 clipboard().ReadAsciiText(Clipboard::BUFFER_STANDARD, &ascii_text); 315 clipboard().ReadAsciiText(Clipboard::BUFFER_STANDARD, &ascii_text);
312 EXPECT_EQ(UTF16ToUTF8(url), ascii_text); 316 EXPECT_EQ(UTF16ToUTF8(url), ascii_text);
313 317
314 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) 318 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
315 ascii_text.clear(); 319 ascii_text.clear();
316 clipboard().ReadAsciiText(Clipboard::BUFFER_SELECTION, &ascii_text); 320 clipboard().ReadAsciiText(Clipboard::BUFFER_SELECTION, &ascii_text);
317 EXPECT_EQ(UTF16ToUTF8(url), ascii_text); 321 EXPECT_EQ(UTF16ToUTF8(url), ascii_text);
318 #endif 322 #endif
319 } 323 }
320 324
325 // TODO(erg): Reenable this everywhere once linux_aura learns what bitmaps are.
326 #if !(defined(USE_AURA) && !defined(OS_CHROMEOS))
321 TEST_F(ClipboardTest, SharedBitmapTest) { 327 TEST_F(ClipboardTest, SharedBitmapTest) {
322 unsigned int fake_bitmap[] = { 328 unsigned int fake_bitmap[] = {
323 0x46155189, 0xF6A55C8D, 0x79845674, 0xFA57BD89, 329 0x46155189, 0xF6A55C8D, 0x79845674, 0xFA57BD89,
324 0x78FD46AE, 0x87C64F5A, 0x36EDC5AF, 0x4378F568, 330 0x78FD46AE, 0x87C64F5A, 0x36EDC5AF, 0x4378F568,
325 0x91E9F63A, 0xC31EA14F, 0x69AB32DF, 0x643A3FD1, 331 0x91E9F63A, 0xC31EA14F, 0x69AB32DF, 0x643A3FD1,
326 }; 332 };
327 gfx::Size fake_bitmap_size(3, 4); 333 gfx::Size fake_bitmap_size(3, 4);
328 uint32 bytes = sizeof(fake_bitmap); 334 uint32 bytes = sizeof(fake_bitmap);
329 335
330 // Create shared memory region. 336 // Create shared memory region.
(...skipping 21 matching lines...) Expand all
352 358
353 Clipboard::ObjectMap objects; 359 Clipboard::ObjectMap objects;
354 objects[Clipboard::CBF_SMBITMAP] = params; 360 objects[Clipboard::CBF_SMBITMAP] = params;
355 Clipboard::ReplaceSharedMemHandle(&objects, handle_to_share, current_process); 361 Clipboard::ReplaceSharedMemHandle(&objects, handle_to_share, current_process);
356 362
357 clipboard().WriteObjects(Clipboard::BUFFER_STANDARD, objects); 363 clipboard().WriteObjects(Clipboard::BUFFER_STANDARD, objects);
358 364
359 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetBitmapFormatType(), 365 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetBitmapFormatType(),
360 Clipboard::BUFFER_STANDARD)); 366 Clipboard::BUFFER_STANDARD));
361 } 367 }
368 #endif
362 369
363 // The following test somehow fails on GTK. The image when read back from the 370 // The following test somehow fails on GTK. The image when read back from the
364 // clipboard has the alpha channel set to 0xFF for some reason. The other 371 // clipboard has the alpha channel set to 0xFF for some reason. The other
365 // channels stay intact. So I am turning this on only for aura. 372 // channels stay intact. So I am turning this on only for aura.
366 #if (defined(USE_AURA) && !defined(OS_WIN)) || defined(OS_ANDROID) 373 //
374 // TODO(erg): This also crashes in linux_aura. Investigate once bitmap writing
375 // is implemented.
376 #if (defined(USE_AURA) && !(defined(OS_WIN) || !defined(OS_CHROMEOS))) || \
377 defined(OS_ANDROID)
367 TEST_F(ClipboardTest, MultipleBitmapReadWriteTest) { 378 TEST_F(ClipboardTest, MultipleBitmapReadWriteTest) {
368 // Test first bitmap 379 // Test first bitmap
369 unsigned int fake_bitmap_1[] = { 380 unsigned int fake_bitmap_1[] = {
370 0x46155189, 0xF6A55C8D, 0x79845674, 0xFA57BD89, 381 0x46155189, 0xF6A55C8D, 0x79845674, 0xFA57BD89,
371 0x78FD46AE, 0x87C64F5A, 0x36EDC5AF, 0x4378F568, 382 0x78FD46AE, 0x87C64F5A, 0x36EDC5AF, 0x4378F568,
372 0x91E9F63A, 0xC31EA14F, 0x69AB32DF, 0x643A3FD1, 383 0x91E9F63A, 0xC31EA14F, 0x69AB32DF, 0x643A3FD1,
373 }; 384 };
374 gfx::Size fake_bitmap_1_size(3, 4); 385 gfx::Size fake_bitmap_1_size(3, 4);
375 { 386 {
376 ScopedClipboardWriter clipboard_writer(&clipboard(), 387 ScopedClipboardWriter clipboard_writer(&clipboard(),
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 EXPECT_TRUE(clipboard().IsFormatAvailable( 685 EXPECT_TRUE(clipboard().IsFormatAvailable(
675 Clipboard::GetPlainTextWFormatType(), Clipboard::BUFFER_STANDARD)); 686 Clipboard::GetPlainTextWFormatType(), Clipboard::BUFFER_STANDARD));
676 687
677 // Make sure the text is what we inserted while simulating the other app 688 // Make sure the text is what we inserted while simulating the other app
678 std::string contents; 689 std::string contents;
679 clipboard().ReadAsciiText(Clipboard::BUFFER_STANDARD, &contents); 690 clipboard().ReadAsciiText(Clipboard::BUFFER_STANDARD, &contents);
680 EXPECT_EQ(contents, new_value); 691 EXPECT_EQ(contents, new_value);
681 } 692 }
682 #endif 693 #endif
683 } // namespace ui 694 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_chromeos.cc ('k') | ui/base/x/x11_atom_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698