OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/loader/ThreadableLoader.h" | 5 #include "core/loader/ThreadableLoader.h" |
6 | 6 |
7 #include "core/dom/CrossThreadTask.h" | 7 #include "core/dom/CrossThreadTask.h" |
8 #include "core/fetch/MemoryCache.h" | 8 #include "core/fetch/MemoryCache.h" |
9 #include "core/fetch/ResourceLoaderOptions.h" | 9 #include "core/fetch/ResourceLoaderOptions.h" |
10 #include "core/loader/DocumentThreadableLoader.h" | 10 #include "core/loader/DocumentThreadableLoader.h" |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 TEST_P(ThreadableLoaderTest, DidFinishLoading) | 540 TEST_P(ThreadableLoaderTest, DidFinishLoading) |
541 { | 541 { |
542 InSequence s; | 542 InSequence s; |
543 EXPECT_CALL(checkpoint(), Call(1)); | 543 EXPECT_CALL(checkpoint(), Call(1)); |
544 createLoader(); | 544 createLoader(); |
545 callCheckpoint(1); | 545 callCheckpoint(1); |
546 | 546 |
547 EXPECT_CALL(checkpoint(), Call(2)); | 547 EXPECT_CALL(checkpoint(), Call(2)); |
548 EXPECT_CALL(*client(), didReceiveResponseMock(_, _, _)); | 548 EXPECT_CALL(*client(), didReceiveResponseMock(_, _, _)); |
549 EXPECT_CALL(*client(), didReceiveData(StrEq("fox"), 4)); | 549 EXPECT_CALL(*client(), didReceiveData(StrEq("fox"), 4)); |
550 // We expect didReceiveResourceTiming() calls in DocumentThreadableLoader; | 550 EXPECT_CALL(*client(), didReceiveResourceTiming(_)); |
551 // it's used to connect DocumentThreadableLoader to WorkerThreadableLoader, | |
552 // not to ThreadableLoaderClient. | |
553 if (GetParam() == DocumentThreadableLoaderTest) | |
554 EXPECT_CALL(*client(), didReceiveResourceTiming(_)); | |
555 EXPECT_CALL(*client(), didFinishLoading(_, _)); | 551 EXPECT_CALL(*client(), didFinishLoading(_, _)); |
556 | 552 |
557 startLoader(successURL()); | 553 startLoader(successURL()); |
558 callCheckpoint(2); | 554 callCheckpoint(2); |
559 serveRequests(); | 555 serveRequests(); |
560 } | 556 } |
561 | 557 |
562 TEST_P(ThreadableLoaderTest, CancelInDidFinishLoading) | 558 TEST_P(ThreadableLoaderTest, CancelInDidFinishLoading) |
563 { | 559 { |
564 InSequence s; | 560 InSequence s; |
565 EXPECT_CALL(checkpoint(), Call(1)); | 561 EXPECT_CALL(checkpoint(), Call(1)); |
566 createLoader(); | 562 createLoader(); |
567 callCheckpoint(1); | 563 callCheckpoint(1); |
568 | 564 |
569 EXPECT_CALL(checkpoint(), Call(2)); | 565 EXPECT_CALL(checkpoint(), Call(2)); |
570 EXPECT_CALL(*client(), didReceiveResponseMock(_, _, _)); | 566 EXPECT_CALL(*client(), didReceiveResponseMock(_, _, _)); |
571 EXPECT_CALL(*client(), didReceiveData(_, _)); | 567 EXPECT_CALL(*client(), didReceiveData(_, _)); |
572 if (GetParam() == DocumentThreadableLoaderTest) | 568 EXPECT_CALL(*client(), didReceiveResourceTiming(_)); |
573 EXPECT_CALL(*client(), didReceiveResourceTiming(_)); | |
574 EXPECT_CALL(*client(), didFinishLoading(_, _)).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::cancelLoader)); | 569 EXPECT_CALL(*client(), didFinishLoading(_, _)).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::cancelLoader)); |
575 | 570 |
576 startLoader(successURL()); | 571 startLoader(successURL()); |
577 callCheckpoint(2); | 572 callCheckpoint(2); |
578 serveRequests(); | 573 serveRequests(); |
579 } | 574 } |
580 | 575 |
581 TEST_P(ThreadableLoaderTest, ClearInDidFinishLoading) | 576 TEST_P(ThreadableLoaderTest, ClearInDidFinishLoading) |
582 { | 577 { |
583 InSequence s; | 578 InSequence s; |
584 EXPECT_CALL(checkpoint(), Call(1)); | 579 EXPECT_CALL(checkpoint(), Call(1)); |
585 createLoader(); | 580 createLoader(); |
586 callCheckpoint(1); | 581 callCheckpoint(1); |
587 | 582 |
588 EXPECT_CALL(checkpoint(), Call(2)); | 583 EXPECT_CALL(checkpoint(), Call(2)); |
589 EXPECT_CALL(*client(), didReceiveResponseMock(_, _, _)); | 584 EXPECT_CALL(*client(), didReceiveResponseMock(_, _, _)); |
590 EXPECT_CALL(*client(), didReceiveData(_, _)); | 585 EXPECT_CALL(*client(), didReceiveData(_, _)); |
591 if (GetParam() == DocumentThreadableLoaderTest) | 586 EXPECT_CALL(*client(), didReceiveResourceTiming(_)); |
592 EXPECT_CALL(*client(), didReceiveResourceTiming(_)); | |
593 EXPECT_CALL(*client(), didFinishLoading(_, _)).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::clearLoader)); | 587 EXPECT_CALL(*client(), didFinishLoading(_, _)).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::clearLoader)); |
594 | 588 |
595 startLoader(successURL()); | 589 startLoader(successURL()); |
596 callCheckpoint(2); | 590 callCheckpoint(2); |
597 serveRequests(); | 591 serveRequests(); |
598 } | 592 } |
599 | 593 |
600 TEST_P(ThreadableLoaderTest, DidFail) | 594 TEST_P(ThreadableLoaderTest, DidFail) |
601 { | 595 { |
602 InSequence s; | 596 InSequence s; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 TEST_P(ThreadableLoaderTest, RedirectDidFinishLoading) | 732 TEST_P(ThreadableLoaderTest, RedirectDidFinishLoading) |
739 { | 733 { |
740 InSequence s; | 734 InSequence s; |
741 EXPECT_CALL(checkpoint(), Call(1)); | 735 EXPECT_CALL(checkpoint(), Call(1)); |
742 createLoader(); | 736 createLoader(); |
743 callCheckpoint(1); | 737 callCheckpoint(1); |
744 | 738 |
745 EXPECT_CALL(checkpoint(), Call(2)); | 739 EXPECT_CALL(checkpoint(), Call(2)); |
746 EXPECT_CALL(*client(), didReceiveResponseMock(_, _, _)); | 740 EXPECT_CALL(*client(), didReceiveResponseMock(_, _, _)); |
747 EXPECT_CALL(*client(), didReceiveData(StrEq("fox"), 4)); | 741 EXPECT_CALL(*client(), didReceiveData(StrEq("fox"), 4)); |
748 if (GetParam() == DocumentThreadableLoaderTest) | 742 EXPECT_CALL(*client(), didReceiveResourceTiming(_)); |
749 EXPECT_CALL(*client(), didReceiveResourceTiming(_)); | |
750 EXPECT_CALL(*client(), didFinishLoading(_, _)); | 743 EXPECT_CALL(*client(), didFinishLoading(_, _)); |
751 | 744 |
752 startLoader(redirectURL()); | 745 startLoader(redirectURL()); |
753 callCheckpoint(2); | 746 callCheckpoint(2); |
754 serveRequests(); | 747 serveRequests(); |
755 } | 748 } |
756 | 749 |
757 TEST_P(ThreadableLoaderTest, CancelInRedirectDidFinishLoading) | 750 TEST_P(ThreadableLoaderTest, CancelInRedirectDidFinishLoading) |
758 { | 751 { |
759 InSequence s; | 752 InSequence s; |
760 EXPECT_CALL(checkpoint(), Call(1)); | 753 EXPECT_CALL(checkpoint(), Call(1)); |
761 createLoader(); | 754 createLoader(); |
762 callCheckpoint(1); | 755 callCheckpoint(1); |
763 | 756 |
764 EXPECT_CALL(checkpoint(), Call(2)); | 757 EXPECT_CALL(checkpoint(), Call(2)); |
765 EXPECT_CALL(*client(), didReceiveResponseMock(_, _, _)); | 758 EXPECT_CALL(*client(), didReceiveResponseMock(_, _, _)); |
766 EXPECT_CALL(*client(), didReceiveData(StrEq("fox"), 4)); | 759 EXPECT_CALL(*client(), didReceiveData(StrEq("fox"), 4)); |
767 if (GetParam() == DocumentThreadableLoaderTest) | 760 EXPECT_CALL(*client(), didReceiveResourceTiming(_)); |
768 EXPECT_CALL(*client(), didReceiveResourceTiming(_)); | |
769 EXPECT_CALL(*client(), didFinishLoading(_, _)).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::cancelLoader)); | 761 EXPECT_CALL(*client(), didFinishLoading(_, _)).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::cancelLoader)); |
770 | 762 |
771 startLoader(redirectURL()); | 763 startLoader(redirectURL()); |
772 callCheckpoint(2); | 764 callCheckpoint(2); |
773 serveRequests(); | 765 serveRequests(); |
774 } | 766 } |
775 | 767 |
776 TEST_P(ThreadableLoaderTest, ClearInRedirectDidFinishLoading) | 768 TEST_P(ThreadableLoaderTest, ClearInRedirectDidFinishLoading) |
777 { | 769 { |
778 InSequence s; | 770 InSequence s; |
779 EXPECT_CALL(checkpoint(), Call(1)); | 771 EXPECT_CALL(checkpoint(), Call(1)); |
780 createLoader(); | 772 createLoader(); |
781 callCheckpoint(1); | 773 callCheckpoint(1); |
782 | 774 |
783 EXPECT_CALL(checkpoint(), Call(2)); | 775 EXPECT_CALL(checkpoint(), Call(2)); |
784 EXPECT_CALL(*client(), didReceiveResponseMock(_, _, _)); | 776 EXPECT_CALL(*client(), didReceiveResponseMock(_, _, _)); |
785 EXPECT_CALL(*client(), didReceiveData(StrEq("fox"), 4)); | 777 EXPECT_CALL(*client(), didReceiveData(StrEq("fox"), 4)); |
786 if (GetParam() == DocumentThreadableLoaderTest) | 778 EXPECT_CALL(*client(), didReceiveResourceTiming(_)); |
787 EXPECT_CALL(*client(), didReceiveResourceTiming(_)); | |
788 EXPECT_CALL(*client(), didFinishLoading(_, _)).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::clearLoader)); | 779 EXPECT_CALL(*client(), didFinishLoading(_, _)).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::clearLoader)); |
789 | 780 |
790 startLoader(redirectURL()); | 781 startLoader(redirectURL()); |
791 callCheckpoint(2); | 782 callCheckpoint(2); |
792 serveRequests(); | 783 serveRequests(); |
793 } | 784 } |
794 | 785 |
795 TEST_P(ThreadableLoaderTest, DidFailRedirectCheck) | 786 TEST_P(ThreadableLoaderTest, DidFailRedirectCheck) |
796 { | 787 { |
797 InSequence s; | 788 InSequence s; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 EXPECT_CALL(*client(), didFailRedirectCheck()).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::clearLoader)); | 824 EXPECT_CALL(*client(), didFailRedirectCheck()).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::clearLoader)); |
834 | 825 |
835 startLoader(redirectLoopURL()); | 826 startLoader(redirectLoopURL()); |
836 callCheckpoint(2); | 827 callCheckpoint(2); |
837 serveRequests(); | 828 serveRequests(); |
838 } | 829 } |
839 | 830 |
840 } // namespace | 831 } // namespace |
841 | 832 |
842 } // namespace blink | 833 } // namespace blink |
OLD | NEW |