OLD | NEW |
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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
27 #include "ui/base/clipboard/clipboard_util_win.h" | 27 #include "ui/base/clipboard/clipboard_util_win.h" |
28 #endif | 28 #endif |
29 | 29 |
30 #if defined(OS_ANDROID) | 30 #if defined(OS_ANDROID) |
31 #include "base/android/jni_android.h" | 31 #include "base/android/jni_android.h" |
32 #include "base/android/jni_string.h" | 32 #include "base/android/jni_string.h" |
33 #endif | 33 #endif |
34 | 34 |
| 35 #if defined(USE_AURA) |
| 36 #include "ui/events/platform/platform_event_source.h" |
| 37 #endif |
| 38 |
35 using base::ASCIIToUTF16; | 39 using base::ASCIIToUTF16; |
36 using base::UTF8ToUTF16; | 40 using base::UTF8ToUTF16; |
37 using base::UTF16ToUTF8; | 41 using base::UTF16ToUTF8; |
38 | 42 |
39 namespace ui { | 43 namespace ui { |
40 | 44 |
41 class ClipboardTest : public PlatformTest { | 45 class ClipboardTest : public PlatformTest { |
42 public: | 46 public: |
| 47 #if defined(USE_AURA) |
| 48 ClipboardTest() : event_source_(ui::PlatformEventSource::CreateDefault()) {} |
| 49 #else |
| 50 ClipboardTest() {} |
| 51 #endif |
| 52 |
43 static void WriteObjectsToClipboard(ui::Clipboard* clipboard, | 53 static void WriteObjectsToClipboard(ui::Clipboard* clipboard, |
44 const Clipboard::ObjectMap& objects) { | 54 const Clipboard::ObjectMap& objects) { |
45 clipboard->WriteObjects(ui::CLIPBOARD_TYPE_COPY_PASTE, objects); | 55 clipboard->WriteObjects(ui::CLIPBOARD_TYPE_COPY_PASTE, objects); |
46 } | 56 } |
47 | 57 |
48 protected: | 58 protected: |
49 Clipboard& clipboard() { return clipboard_; } | 59 Clipboard& clipboard() { return clipboard_; } |
50 | 60 |
51 void WriteObjectsToClipboard(const Clipboard::ObjectMap& objects) { | 61 void WriteObjectsToClipboard(const Clipboard::ObjectMap& objects) { |
52 WriteObjectsToClipboard(&clipboard(), objects); | 62 WriteObjectsToClipboard(&clipboard(), objects); |
53 } | 63 } |
54 | 64 |
55 private: | 65 private: |
56 base::MessageLoopForUI message_loop_; | 66 base::MessageLoopForUI message_loop_; |
| 67 #if defined(USE_AURA) |
| 68 scoped_ptr<PlatformEventSource> event_source_; |
| 69 #endif |
57 Clipboard clipboard_; | 70 Clipboard clipboard_; |
58 }; | 71 }; |
59 | 72 |
60 namespace { | 73 namespace { |
61 | 74 |
62 bool MarkupMatches(const base::string16& expected_markup, | 75 bool MarkupMatches(const base::string16& expected_markup, |
63 const base::string16& actual_markup) { | 76 const base::string16& actual_markup) { |
64 return actual_markup.find(expected_markup) != base::string16::npos; | 77 return actual_markup.find(expected_markup) != base::string16::npos; |
65 } | 78 } |
66 | 79 |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 EXPECT_TRUE(clipboard().IsFormatAvailable( | 835 EXPECT_TRUE(clipboard().IsFormatAvailable( |
823 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); | 836 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); |
824 | 837 |
825 // Make sure the text is what we inserted while simulating the other app | 838 // Make sure the text is what we inserted while simulating the other app |
826 std::string contents; | 839 std::string contents; |
827 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &contents); | 840 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &contents); |
828 EXPECT_EQ(contents, new_value); | 841 EXPECT_EQ(contents, new_value); |
829 } | 842 } |
830 #endif | 843 #endif |
831 } // namespace ui | 844 } // namespace ui |
OLD | NEW |