OLD | NEW |
1 // Copyright (c) 2011 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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/memory/scoped_handle.h" | 6 #include "base/memory/scoped_handle.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "base/win/scoped_hglobal.h" | 10 #include "base/win/scoped_hglobal.h" |
11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 saved_pickle.WriteInt(1); | 343 saved_pickle.WriteInt(1); |
344 saved_pickle.WriteInt(2); | 344 saved_pickle.WriteInt(2); |
345 OSExchangeData data; | 345 OSExchangeData data; |
346 data.SetPickledData(test_cf, saved_pickle); | 346 data.SetPickledData(test_cf, saved_pickle); |
347 | 347 |
348 OSExchangeData copy(CloneProvider(data)); | 348 OSExchangeData copy(CloneProvider(data)); |
349 EXPECT_TRUE(copy.HasCustomFormat(test_cf)); | 349 EXPECT_TRUE(copy.HasCustomFormat(test_cf)); |
350 | 350 |
351 Pickle restored_pickle; | 351 Pickle restored_pickle; |
352 EXPECT_TRUE(copy.GetPickledData(test_cf, &restored_pickle)); | 352 EXPECT_TRUE(copy.GetPickledData(test_cf, &restored_pickle)); |
353 void* p_iterator = NULL; | 353 PickleIterator iterator(restored_pickle); |
354 int value; | 354 int value; |
355 EXPECT_TRUE(restored_pickle.ReadInt(&p_iterator, &value)); | 355 EXPECT_TRUE(restored_pickle.ReadInt(&iterator, &value)); |
356 EXPECT_EQ(1, value); | 356 EXPECT_EQ(1, value); |
357 EXPECT_TRUE(restored_pickle.ReadInt(&p_iterator, &value)); | 357 EXPECT_TRUE(restored_pickle.ReadInt(&iterator, &value)); |
358 EXPECT_EQ(2, value); | 358 EXPECT_EQ(2, value); |
359 } | 359 } |
360 | 360 |
361 TEST(OSExchangeDataTest, FileContents) { | 361 TEST(OSExchangeDataTest, FileContents) { |
362 OSExchangeData data; | 362 OSExchangeData data; |
363 std::string file_contents("data\0with\0nulls", 15); | 363 std::string file_contents("data\0with\0nulls", 15); |
364 data.SetFileContents(FilePath(L"filename.txt"), file_contents); | 364 data.SetFileContents(FilePath(L"filename.txt"), file_contents); |
365 | 365 |
366 OSExchangeData copy(CloneProvider(data)); | 366 OSExchangeData copy(CloneProvider(data)); |
367 FilePath filename; | 367 FilePath filename; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 | 416 |
417 OSExchangeData data2(CloneProvider(data)); | 417 OSExchangeData data2(CloneProvider(data)); |
418 ASSERT_TRUE(data2.HasURL()); | 418 ASSERT_TRUE(data2.HasURL()); |
419 GURL read_url; | 419 GURL read_url; |
420 std::wstring title; | 420 std::wstring title; |
421 EXPECT_TRUE(data2.GetURLAndTitle(&read_url, &title)); | 421 EXPECT_TRUE(data2.GetURLAndTitle(&read_url, &title)); |
422 EXPECT_EQ(GURL("http://google.com"), read_url); | 422 EXPECT_EQ(GURL("http://google.com"), read_url); |
423 } | 423 } |
424 | 424 |
425 } // namespace ui | 425 } // namespace ui |
OLD | NEW |