OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "base/pickle.h" | 6 #include "base/pickle.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "testing/platform_test.h" | 9 #include "testing/platform_test.h" |
10 #include "ui/base/dragdrop/os_exchange_data.h" | 10 #include "ui/base/dragdrop/os_exchange_data.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 OSExchangeData::DO_NOT_CONVERT_FILENAMES, &output_url, &output_title)); | 63 OSExchangeData::DO_NOT_CONVERT_FILENAMES, &output_url, &output_title)); |
64 EXPECT_EQ(url_spec, output_url.spec()); | 64 EXPECT_EQ(url_spec, output_url.spec()); |
65 EXPECT_EQ(url_title, output_title); | 65 EXPECT_EQ(url_title, output_title); |
66 base::string16 output_string; | 66 base::string16 output_string; |
67 | 67 |
68 // URL should be the raw text response | 68 // URL should be the raw text response |
69 EXPECT_TRUE(data2.GetString(&output_string)); | 69 EXPECT_TRUE(data2.GetString(&output_string)); |
70 EXPECT_EQ(url_spec, base::UTF16ToUTF8(output_string)); | 70 EXPECT_EQ(url_spec, base::UTF16ToUTF8(output_string)); |
71 } | 71 } |
72 | 72 |
| 73 // Test that setting the URL does not overwrite a previously set custom string. |
| 74 TEST_F(OSExchangeDataTest, URLAndString) { |
| 75 OSExchangeData data; |
| 76 base::string16 string = base::ASCIIToUTF16("I can has cheezburger?"); |
| 77 data.SetString(string); |
| 78 std::string url_spec = "http://www.google.com/"; |
| 79 GURL url(url_spec); |
| 80 base::string16 url_title = base::ASCIIToUTF16("www.google.com"); |
| 81 data.SetURL(url, url_title); |
| 82 |
| 83 base::string16 output_string; |
| 84 EXPECT_TRUE(data.GetString(&output_string)); |
| 85 EXPECT_EQ(string, output_string); |
| 86 |
| 87 GURL output_url; |
| 88 base::string16 output_title; |
| 89 EXPECT_TRUE(data.GetURLAndTitle( |
| 90 OSExchangeData::CONVERT_FILENAMES, &output_url, &output_title)); |
| 91 EXPECT_EQ(url_spec, output_url.spec()); |
| 92 EXPECT_EQ(url_title, output_title); |
| 93 } |
| 94 |
73 TEST_F(OSExchangeDataTest, TestPickledData) { | 95 TEST_F(OSExchangeDataTest, TestPickledData) { |
74 const OSExchangeData::CustomFormat kTestFormat = | 96 const OSExchangeData::CustomFormat kTestFormat = |
75 ui::Clipboard::GetFormatType("application/vnd.chromium.test"); | 97 ui::Clipboard::GetFormatType("application/vnd.chromium.test"); |
76 | 98 |
77 Pickle saved_pickle; | 99 Pickle saved_pickle; |
78 saved_pickle.WriteInt(1); | 100 saved_pickle.WriteInt(1); |
79 saved_pickle.WriteInt(2); | 101 saved_pickle.WriteInt(2); |
80 OSExchangeData data; | 102 OSExchangeData data; |
81 data.SetPickledData(kTestFormat, saved_pickle); | 103 data.SetPickledData(kTestFormat, saved_pickle); |
82 | 104 |
(...skipping 21 matching lines...) Expand all Loading... |
104 data.SetHtml(html, url); | 126 data.SetHtml(html, url); |
105 | 127 |
106 OSExchangeData copy(data.provider().Clone()); | 128 OSExchangeData copy(data.provider().Clone()); |
107 base::string16 read_html; | 129 base::string16 read_html; |
108 EXPECT_TRUE(copy.GetHtml(&read_html, &url)); | 130 EXPECT_TRUE(copy.GetHtml(&read_html, &url)); |
109 EXPECT_EQ(html, read_html); | 131 EXPECT_EQ(html, read_html); |
110 } | 132 } |
111 #endif | 133 #endif |
112 | 134 |
113 } // namespace ui | 135 } // namespace ui |
OLD | NEW |