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

Side by Side Diff: ui/base/dragdrop/os_exchange_data_unittest.cc

Issue 208313009: Fix the HTML5 drag and drop demos on Linux and CrOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 OSExchangeData::CONVERT_FILENAMES, &output_url, &output_title)); 58 OSExchangeData::CONVERT_FILENAMES, &output_url, &output_title));
59 EXPECT_EQ(url_spec, output_url.spec()); 59 EXPECT_EQ(url_spec, output_url.spec());
60 EXPECT_EQ(url_title, output_title); 60 EXPECT_EQ(url_title, output_title);
61 base::string16 output_string; 61 base::string16 output_string;
62 62
63 // URL should be the raw text response 63 // URL should be the raw text response
64 EXPECT_TRUE(data2.GetString(&output_string)); 64 EXPECT_TRUE(data2.GetString(&output_string));
65 EXPECT_EQ(url_spec, base::UTF16ToUTF8(output_string)); 65 EXPECT_EQ(url_spec, base::UTF16ToUTF8(output_string));
66 } 66 }
67 67
68 // Test that setting the URL does not overwrite a previously set custom string.
69 TEST_F(OSExchangeDataTest, URLAndString) {
70 OSExchangeData data;
71 base::string16 string = base::ASCIIToUTF16("I can has cheezburger?");
72 data.SetString(string);
73 std::string url_spec = "http://www.google.com/";
74 GURL url(url_spec);
75 base::string16 url_title = base::ASCIIToUTF16("www.google.com");
76 data.SetURL(url, url_title);
77
78 base::string16 output_string;
79 EXPECT_TRUE(data.GetString(&output_string));
80 EXPECT_EQ(string, output_string);
81
82 GURL output_url;
83 base::string16 output_title;
84 EXPECT_TRUE(data.GetURLAndTitle(
85 OSExchangeData::CONVERT_FILENAMES, &output_url, &output_title));
86 EXPECT_EQ(url_spec, output_url.spec());
87 EXPECT_EQ(url_title, output_title);
88 }
89
68 TEST_F(OSExchangeDataTest, TestPickledData) { 90 TEST_F(OSExchangeDataTest, TestPickledData) {
69 const OSExchangeData::CustomFormat kTestFormat = 91 const OSExchangeData::CustomFormat kTestFormat =
70 ui::Clipboard::GetFormatType("application/vnd.chromium.test"); 92 ui::Clipboard::GetFormatType("application/vnd.chromium.test");
71 93
72 Pickle saved_pickle; 94 Pickle saved_pickle;
73 saved_pickle.WriteInt(1); 95 saved_pickle.WriteInt(1);
74 saved_pickle.WriteInt(2); 96 saved_pickle.WriteInt(2);
75 OSExchangeData data; 97 OSExchangeData data;
76 data.SetPickledData(kTestFormat, saved_pickle); 98 data.SetPickledData(kTestFormat, saved_pickle);
77 99
(...skipping 21 matching lines...) Expand all
99 data.SetHtml(html, url); 121 data.SetHtml(html, url);
100 122
101 OSExchangeData copy(data.provider().Clone()); 123 OSExchangeData copy(data.provider().Clone());
102 base::string16 read_html; 124 base::string16 read_html;
103 EXPECT_TRUE(copy.GetHtml(&read_html, &url)); 125 EXPECT_TRUE(copy.GetHtml(&read_html, &url));
104 EXPECT_EQ(html, read_html); 126 EXPECT_EQ(html, read_html);
105 } 127 }
106 #endif 128 #endif
107 129
108 } // namespace ui 130 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698