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

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

Issue 1154283003: Change most uses of Pickle to base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « ui/base/dragdrop/os_exchange_data_provider_win.cc ('k') | ui/gfx/ipc/gfx_param_traits.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/files/file_util.h" 5 #include "base/files/file_util.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/pickle.h" 7 #include "base/pickle.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "net/base/filename_util.h" 9 #include "net/base/filename_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 EXPECT_TRUE(data.HasFile()); 140 EXPECT_TRUE(data.HasFile());
141 base::FilePath actual_path; 141 base::FilePath actual_path;
142 EXPECT_TRUE(data.GetFilename(&actual_path)); 142 EXPECT_TRUE(data.GetFilename(&actual_path));
143 EXPECT_EQ(current_directory, actual_path); 143 EXPECT_EQ(current_directory, actual_path);
144 } 144 }
145 145
146 TEST_F(OSExchangeDataTest, TestPickledData) { 146 TEST_F(OSExchangeDataTest, TestPickledData) {
147 const OSExchangeData::CustomFormat kTestFormat = 147 const OSExchangeData::CustomFormat kTestFormat =
148 ui::Clipboard::GetFormatType("application/vnd.chromium.test"); 148 ui::Clipboard::GetFormatType("application/vnd.chromium.test");
149 149
150 Pickle saved_pickle; 150 base::Pickle saved_pickle;
151 saved_pickle.WriteInt(1); 151 saved_pickle.WriteInt(1);
152 saved_pickle.WriteInt(2); 152 saved_pickle.WriteInt(2);
153 OSExchangeData data; 153 OSExchangeData data;
154 data.SetPickledData(kTestFormat, saved_pickle); 154 data.SetPickledData(kTestFormat, saved_pickle);
155 155
156 OSExchangeData copy(data.provider().Clone()); 156 OSExchangeData copy(data.provider().Clone());
157 EXPECT_TRUE(copy.HasCustomFormat(kTestFormat)); 157 EXPECT_TRUE(copy.HasCustomFormat(kTestFormat));
158 158
159 Pickle restored_pickle; 159 base::Pickle restored_pickle;
160 EXPECT_TRUE(copy.GetPickledData(kTestFormat, &restored_pickle)); 160 EXPECT_TRUE(copy.GetPickledData(kTestFormat, &restored_pickle));
161 PickleIterator iterator(restored_pickle); 161 base::PickleIterator iterator(restored_pickle);
162 int value; 162 int value;
163 EXPECT_TRUE(iterator.ReadInt(&value)); 163 EXPECT_TRUE(iterator.ReadInt(&value));
164 EXPECT_EQ(1, value); 164 EXPECT_EQ(1, value);
165 EXPECT_TRUE(iterator.ReadInt(&value)); 165 EXPECT_TRUE(iterator.ReadInt(&value));
166 EXPECT_EQ(2, value); 166 EXPECT_EQ(2, value);
167 } 167 }
168 168
169 #if defined(USE_AURA) 169 #if defined(USE_AURA)
170 TEST_F(OSExchangeDataTest, TestHTML) { 170 TEST_F(OSExchangeDataTest, TestHTML) {
171 OSExchangeData data; 171 OSExchangeData data;
172 GURL url("http://www.google.com/"); 172 GURL url("http://www.google.com/");
173 base::string16 html = base::ASCIIToUTF16( 173 base::string16 html = base::ASCIIToUTF16(
174 "<HTML>\n<BODY>\n" 174 "<HTML>\n<BODY>\n"
175 "<b>bold.</b> <i><b>This is bold italic.</b></i>\n" 175 "<b>bold.</b> <i><b>This is bold italic.</b></i>\n"
176 "</BODY>\n</HTML>"); 176 "</BODY>\n</HTML>");
177 data.SetHtml(html, url); 177 data.SetHtml(html, url);
178 178
179 OSExchangeData copy(data.provider().Clone()); 179 OSExchangeData copy(data.provider().Clone());
180 base::string16 read_html; 180 base::string16 read_html;
181 EXPECT_TRUE(copy.GetHtml(&read_html, &url)); 181 EXPECT_TRUE(copy.GetHtml(&read_html, &url));
182 EXPECT_EQ(html, read_html); 182 EXPECT_EQ(html, read_html);
183 } 183 }
184 #endif 184 #endif
185 185
186 } // namespace ui 186 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/dragdrop/os_exchange_data_provider_win.cc ('k') | ui/gfx/ipc/gfx_param_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698