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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 CLIPBOARD_TYPE_COPY_PASTE)); | 82 CLIPBOARD_TYPE_COPY_PASTE)); |
83 clipboard().ReadText(CLIPBOARD_TYPE_COPY_PASTE, &text_result); | 83 clipboard().ReadText(CLIPBOARD_TYPE_COPY_PASTE, &text_result); |
84 | 84 |
85 EXPECT_EQ(text, text_result); | 85 EXPECT_EQ(text, text_result); |
86 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &ascii_text); | 86 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &ascii_text); |
87 EXPECT_EQ(UTF16ToUTF8(text), ascii_text); | 87 EXPECT_EQ(UTF16ToUTF8(text), ascii_text); |
88 } | 88 } |
89 | 89 |
90 TEST_F(ClipboardTest, HTMLTest) { | 90 TEST_F(ClipboardTest, HTMLTest) { |
91 string16 markup(ASCIIToUTF16("<string>Hi!</string>")), markup_result; | 91 string16 markup(ASCIIToUTF16("<string>Hi!</string>")), markup_result; |
| 92 string16 plain(ASCIIToUTF16("Hi!")), plain_result; |
92 std::string url("http://www.example.com/"), url_result; | 93 std::string url("http://www.example.com/"), url_result; |
93 | 94 |
94 { | 95 { |
95 ScopedClipboardWriter clipboard_writer(&clipboard(), | 96 ScopedClipboardWriter clipboard_writer(&clipboard(), |
96 CLIPBOARD_TYPE_COPY_PASTE); | 97 CLIPBOARD_TYPE_COPY_PASTE); |
| 98 clipboard_writer.WriteText(plain); |
97 clipboard_writer.WriteHTML(markup, url); | 99 clipboard_writer.WriteHTML(markup, url); |
98 } | 100 } |
99 | 101 |
100 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), | 102 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), |
101 CLIPBOARD_TYPE_COPY_PASTE)); | 103 CLIPBOARD_TYPE_COPY_PASTE)); |
102 uint32 ignored; | 104 uint32 ignored; |
103 clipboard().ReadHTML(CLIPBOARD_TYPE_COPY_PASTE, &markup_result, &url_result, | 105 clipboard().ReadHTML(CLIPBOARD_TYPE_COPY_PASTE, &markup_result, &url_result, |
104 &ignored, &ignored); | 106 &ignored, &ignored); |
105 EXPECT_PRED2(MarkupMatches, markup, markup_result); | 107 EXPECT_PRED2(MarkupMatches, markup, markup_result); |
106 #if defined(OS_WIN) | 108 #if defined(OS_WIN) |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 EXPECT_TRUE(clipboard().IsFormatAvailable( | 668 EXPECT_TRUE(clipboard().IsFormatAvailable( |
667 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); | 669 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); |
668 | 670 |
669 // Make sure the text is what we inserted while simulating the other app | 671 // Make sure the text is what we inserted while simulating the other app |
670 std::string contents; | 672 std::string contents; |
671 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &contents); | 673 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &contents); |
672 EXPECT_EQ(contents, new_value); | 674 EXPECT_EQ(contents, new_value); |
673 } | 675 } |
674 #endif | 676 #endif |
675 } // namespace ui | 677 } // namespace ui |
OLD | NEW |