Chromium Code Reviews| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 static Clipboard* Create() { | 89 static Clipboard* Create() { |
| 90 return Clipboard::GetForCurrentThread(); | 90 return Clipboard::GetForCurrentThread(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 static void Destroy(Clipboard* clipboard) { | 93 static void Destroy(Clipboard* clipboard) { |
| 94 ASSERT_EQ(Clipboard::GetForCurrentThread(), clipboard); | 94 ASSERT_EQ(Clipboard::GetForCurrentThread(), clipboard); |
| 95 Clipboard::DestroyClipboardForCurrentThread(); | 95 Clipboard::DestroyClipboardForCurrentThread(); |
| 96 } | 96 } |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 TYPED_TEST_CASE(ClipboardTest, PlatformClipboardTraits); | 99 struct FakeClipboardTraits { |
|
sky
2014/11/14 02:10:31
TestClipboardTraits
dcheng
2014/11/14 03:30:28
Done.
| |
| 100 static Clipboard* Create() { | |
| 101 Clipboard::UseFakeForCurrentThreadForTest(); | |
| 102 return Clipboard::GetForCurrentThread(); | |
| 103 } | |
| 104 | |
| 105 static void Destroy(Clipboard* clipboard) { | |
| 106 ASSERT_EQ(Clipboard::GetForCurrentThread(), clipboard); | |
| 107 Clipboard::DestroyClipboardForCurrentThread(); | |
| 108 } | |
| 109 }; | |
| 110 | |
| 111 typedef ::testing::Types<PlatformClipboardTraits, FakeClipboardTraits> | |
| 112 ClipboardTypes; | |
| 113 TYPED_TEST_CASE(ClipboardTest, ClipboardTypes); | |
| 100 | 114 |
| 101 TYPED_TEST(ClipboardTest, ClearTest) { | 115 TYPED_TEST(ClipboardTest, ClearTest) { |
| 102 { | 116 { |
| 103 ScopedClipboardWriter clipboard_writer(CLIPBOARD_TYPE_COPY_PASTE); | 117 ScopedClipboardWriter clipboard_writer(CLIPBOARD_TYPE_COPY_PASTE); |
| 104 clipboard_writer.WriteText(ASCIIToUTF16("clear me")); | 118 clipboard_writer.WriteText(ASCIIToUTF16("clear me")); |
| 105 } | 119 } |
| 106 | 120 |
| 107 this->clipboard().Clear(CLIPBOARD_TYPE_COPY_PASTE); | 121 this->clipboard().Clear(CLIPBOARD_TYPE_COPY_PASTE); |
| 108 | 122 |
| 109 EXPECT_FALSE(this->clipboard().IsFormatAvailable( | 123 EXPECT_FALSE(this->clipboard().IsFormatAvailable( |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 807 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); | 821 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); |
| 808 | 822 |
| 809 // Make sure the text is what we inserted while simulating the other app | 823 // Make sure the text is what we inserted while simulating the other app |
| 810 std::string contents; | 824 std::string contents; |
| 811 this->clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &contents); | 825 this->clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &contents); |
| 812 EXPECT_EQ(contents, new_value); | 826 EXPECT_EQ(contents, new_value); |
| 813 } | 827 } |
| 814 #endif | 828 #endif |
| 815 | 829 |
| 816 } // namespace ui | 830 } // namespace ui |
| OLD | NEW |