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

Side by Side Diff: ui/base/clipboard/clipboard_test_template.h

Issue 825353003: Revert of Remove deprecated methods from Pickle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
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 // Note: This header doesn't use REGISTER_TYPED_TEST_CASE_P like most 5 // Note: This header doesn't use REGISTER_TYPED_TEST_CASE_P like most
6 // type-parameterized gtests. There are lot of test cases in here that are only 6 // type-parameterized gtests. There are lot of test cases in here that are only
7 // enabled on certain platforms. However, preprocessor directives in macro 7 // enabled on certain platforms. However, preprocessor directives in macro
8 // arguments result in undefined behavior (and don't work on MSVC). Instead, 8 // arguments result in undefined behavior (and don't work on MSVC). Instead,
9 // 'parameterized' tests should typedef TypesToTest (which is used to 9 // 'parameterized' tests should typedef TypesToTest (which is used to
10 // instantiate the tests using the TYPED_TEST_CASE macro) and then #include this 10 // instantiate the tests using the TYPED_TEST_CASE macro) and then #include this
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 408
409 ASSERT_TRUE( 409 ASSERT_TRUE(
410 this->clipboard().IsFormatAvailable(kFormat, CLIPBOARD_TYPE_COPY_PASTE)); 410 this->clipboard().IsFormatAvailable(kFormat, CLIPBOARD_TYPE_COPY_PASTE));
411 std::string output; 411 std::string output;
412 this->clipboard().ReadData(kFormat, &output); 412 this->clipboard().ReadData(kFormat, &output);
413 ASSERT_FALSE(output.empty()); 413 ASSERT_FALSE(output.empty());
414 414
415 Pickle read_pickle(output.data(), output.size()); 415 Pickle read_pickle(output.data(), output.size());
416 PickleIterator iter(read_pickle); 416 PickleIterator iter(read_pickle);
417 std::string unpickled_string; 417 std::string unpickled_string;
418 ASSERT_TRUE(iter.ReadString(&unpickled_string)); 418 ASSERT_TRUE(read_pickle.ReadString(&iter, &unpickled_string));
419 EXPECT_EQ(payload, unpickled_string); 419 EXPECT_EQ(payload, unpickled_string);
420 } 420 }
421 421
422 TYPED_TEST(ClipboardTest, MultipleDataTest) { 422 TYPED_TEST(ClipboardTest, MultipleDataTest) {
423 const ui::Clipboard::FormatType kFormat1 = 423 const ui::Clipboard::FormatType kFormat1 =
424 ui::Clipboard::GetFormatType("chromium/x-test-format1"); 424 ui::Clipboard::GetFormatType("chromium/x-test-format1");
425 std::string payload1("test string1"); 425 std::string payload1("test string1");
426 Pickle write_pickle1; 426 Pickle write_pickle1;
427 write_pickle1.WriteString(payload1); 427 write_pickle1.WriteString(payload1);
428 428
(...skipping 14 matching lines...) Expand all
443 this->clipboard().IsFormatAvailable(kFormat2, CLIPBOARD_TYPE_COPY_PASTE)); 443 this->clipboard().IsFormatAvailable(kFormat2, CLIPBOARD_TYPE_COPY_PASTE));
444 444
445 // Check string 2. 445 // Check string 2.
446 std::string output2; 446 std::string output2;
447 this->clipboard().ReadData(kFormat2, &output2); 447 this->clipboard().ReadData(kFormat2, &output2);
448 ASSERT_FALSE(output2.empty()); 448 ASSERT_FALSE(output2.empty());
449 449
450 Pickle read_pickle2(output2.data(), output2.size()); 450 Pickle read_pickle2(output2.data(), output2.size());
451 PickleIterator iter2(read_pickle2); 451 PickleIterator iter2(read_pickle2);
452 std::string unpickled_string2; 452 std::string unpickled_string2;
453 ASSERT_TRUE(iter2.ReadString(&unpickled_string2)); 453 ASSERT_TRUE(read_pickle2.ReadString(&iter2, &unpickled_string2));
454 EXPECT_EQ(payload2, unpickled_string2); 454 EXPECT_EQ(payload2, unpickled_string2);
455 455
456 { 456 {
457 ScopedClipboardWriter clipboard_writer(CLIPBOARD_TYPE_COPY_PASTE); 457 ScopedClipboardWriter clipboard_writer(CLIPBOARD_TYPE_COPY_PASTE);
458 clipboard_writer.WritePickledData(write_pickle2, kFormat2); 458 clipboard_writer.WritePickledData(write_pickle2, kFormat2);
459 // overwrite the previous pickle for fun 459 // overwrite the previous pickle for fun
460 clipboard_writer.WritePickledData(write_pickle1, kFormat1); 460 clipboard_writer.WritePickledData(write_pickle1, kFormat1);
461 } 461 }
462 462
463 ASSERT_TRUE( 463 ASSERT_TRUE(
464 this->clipboard().IsFormatAvailable(kFormat1, CLIPBOARD_TYPE_COPY_PASTE)); 464 this->clipboard().IsFormatAvailable(kFormat1, CLIPBOARD_TYPE_COPY_PASTE));
465 465
466 // Check string 1. 466 // Check string 1.
467 std::string output1; 467 std::string output1;
468 this->clipboard().ReadData(kFormat1, &output1); 468 this->clipboard().ReadData(kFormat1, &output1);
469 ASSERT_FALSE(output1.empty()); 469 ASSERT_FALSE(output1.empty());
470 470
471 Pickle read_pickle1(output1.data(), output1.size()); 471 Pickle read_pickle1(output1.data(), output1.size());
472 PickleIterator iter1(read_pickle1); 472 PickleIterator iter1(read_pickle1);
473 std::string unpickled_string1; 473 std::string unpickled_string1;
474 ASSERT_TRUE(iter1.ReadString(&unpickled_string1)); 474 ASSERT_TRUE(read_pickle1.ReadString(&iter1, &unpickled_string1));
475 EXPECT_EQ(payload1, unpickled_string1); 475 EXPECT_EQ(payload1, unpickled_string1);
476 } 476 }
477 477
478 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 478 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
479 TYPED_TEST(ClipboardTest, HyperlinkTest) { 479 TYPED_TEST(ClipboardTest, HyperlinkTest) {
480 const std::string kTitle("The <Example> Company's \"home page\""); 480 const std::string kTitle("The <Example> Company's \"home page\"");
481 const std::string kUrl("http://www.example.com?x=3&lt=3#\"'<>"); 481 const std::string kUrl("http://www.example.com?x=3&lt=3#\"'<>");
482 const base::string16 kExpectedHtml(UTF8ToUTF16( 482 const base::string16 kExpectedHtml(UTF8ToUTF16(
483 "<a href=\"http://www.example.com?x=3&amp;lt=3#&quot;&#39;&lt;&gt;\">" 483 "<a href=\"http://www.example.com?x=3&amp;lt=3#&quot;&#39;&lt;&gt;\">"
484 "The &lt;Example&gt; Company&#39;s &quot;home page&quot;</a>")); 484 "The &lt;Example&gt; Company&#39;s &quot;home page&quot;</a>"));
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 ScopedClipboardWriter scw(CLIPBOARD_TYPE_COPY_PASTE); 638 ScopedClipboardWriter scw(CLIPBOARD_TYPE_COPY_PASTE);
639 scw.WritePickledData(Pickle(), Clipboard::GetPlainTextFormatType()); 639 scw.WritePickledData(Pickle(), Clipboard::GetPlainTextFormatType());
640 } 640 }
641 641
642 TYPED_TEST(ClipboardTest, WriteImageEmptyParams) { 642 TYPED_TEST(ClipboardTest, WriteImageEmptyParams) {
643 ScopedClipboardWriter scw(CLIPBOARD_TYPE_COPY_PASTE); 643 ScopedClipboardWriter scw(CLIPBOARD_TYPE_COPY_PASTE);
644 scw.WriteImage(SkBitmap()); 644 scw.WriteImage(SkBitmap());
645 } 645 }
646 646
647 } // namespace ui 647 } // namespace ui
OLDNEW
« no previous file with comments | « storage/browser/fileapi/sandbox_prioritized_origin_database.cc ('k') | ui/base/clipboard/custom_data_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698