| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 class MockImageBuffer : public ImageBuffer { | 455 class MockImageBuffer : public ImageBuffer { |
| 456 public: | 456 public: |
| 457 MockImageBuffer() | 457 MockImageBuffer() |
| 458 : ImageBuffer(adoptPtr(new UnacceleratedImageBufferSurface(IntSize(1, 1)
))) { } | 458 : ImageBuffer(adoptPtr(new UnacceleratedImageBufferSurface(IntSize(1, 1)
))) { } |
| 459 | 459 |
| 460 MOCK_CONST_METHOD1(resetCanvas, void(SkCanvas*)); | 460 MOCK_CONST_METHOD1(resetCanvas, void(SkCanvas*)); |
| 461 | 461 |
| 462 virtual ~MockImageBuffer() { } | 462 virtual ~MockImageBuffer() { } |
| 463 }; | 463 }; |
| 464 | 464 |
| 465 #if CANVAS2D_HIBERNATION_ENABLED |
| 465 TEST_F(Canvas2DLayerBridgeTest, HibernationLifeCycle) | 466 TEST_F(Canvas2DLayerBridgeTest, HibernationLifeCycle) |
| 467 #else |
| 468 TEST_F(Canvas2DLayerBridgeTest, DISABLED_HibernationLifeCycle) |
| 469 #endif |
| 466 { | 470 { |
| 467 MockCanvasContext mainMock; | 471 MockCanvasContext mainMock; |
| 468 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 472 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 469 | 473 |
| 470 // The Canvas2DLayerBridge has to be created on the thread that will use it | 474 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 471 // to avoid WeakPtr thread check issues. | 475 // to avoid WeakPtr thread check issues. |
| 472 Canvas2DLayerBridgePtr bridge; | 476 Canvas2DLayerBridgePtr bridge; |
| 473 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); | 477 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); |
| 474 | 478 |
| 475 // Register an alternate Logger for tracking hibernation events | 479 // Register an alternate Logger for tracking hibernation events |
| (...skipping 21 matching lines...) Expand all Loading... |
| 497 EXPECT_FALSE(bridge->isHibernating()); | 501 EXPECT_FALSE(bridge->isHibernating()); |
| 498 EXPECT_TRUE(bridge->checkSurfaceValid()); | 502 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 499 | 503 |
| 500 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 504 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 501 // without crashing due to thread checks | 505 // without crashing due to thread checks |
| 502 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 506 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 503 | 507 |
| 504 ::testing::Mock::VerifyAndClearExpectations(&mainMock); | 508 ::testing::Mock::VerifyAndClearExpectations(&mainMock); |
| 505 } | 509 } |
| 506 | 510 |
| 511 #if CANVAS2D_HIBERNATION_ENABLED |
| 507 TEST_F(Canvas2DLayerBridgeTest, HibernationReEntry) | 512 TEST_F(Canvas2DLayerBridgeTest, HibernationReEntry) |
| 513 #else |
| 514 TEST_F(Canvas2DLayerBridgeTest, DISABLED_HibernationReEntry) |
| 515 #endif |
| 508 { | 516 { |
| 509 MockCanvasContext mainMock; | 517 MockCanvasContext mainMock; |
| 510 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 518 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 511 | 519 |
| 512 // The Canvas2DLayerBridge has to be created on the thread that will use it | 520 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 513 // to avoid WeakPtr thread check issues. | 521 // to avoid WeakPtr thread check issues. |
| 514 Canvas2DLayerBridgePtr bridge; | 522 Canvas2DLayerBridgePtr bridge; |
| 515 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); | 523 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); |
| 516 | 524 |
| 517 // Register an alternate Logger for tracking hibernation events | 525 // Register an alternate Logger for tracking hibernation events |
| (...skipping 27 matching lines...) Expand all Loading... |
| 545 EXPECT_TRUE(bridge->checkSurfaceValid()); | 553 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 546 | 554 |
| 547 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 555 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 548 // without crashing due to thread checks | 556 // without crashing due to thread checks |
| 549 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 557 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 550 | 558 |
| 551 ::testing::Mock::VerifyAndClearExpectations(&mainMock); | 559 ::testing::Mock::VerifyAndClearExpectations(&mainMock); |
| 552 | 560 |
| 553 } | 561 } |
| 554 | 562 |
| 563 #if CANVAS2D_HIBERNATION_ENABLED |
| 555 TEST_F(Canvas2DLayerBridgeTest, HibernationLifeCycleWithDeferredRenderingDisable
d) | 564 TEST_F(Canvas2DLayerBridgeTest, HibernationLifeCycleWithDeferredRenderingDisable
d) |
| 565 #else |
| 566 TEST_F(Canvas2DLayerBridgeTest, DISABLED_HibernationLifeCycleWithDeferredRenderi
ngDisabled) |
| 567 #endif |
| 556 { | 568 { |
| 557 MockCanvasContext mainMock; | 569 MockCanvasContext mainMock; |
| 558 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 570 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 559 | 571 |
| 560 // The Canvas2DLayerBridge has to be created on the thread that will use it | 572 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 561 // to avoid WeakPtr thread check issues. | 573 // to avoid WeakPtr thread check issues. |
| 562 Canvas2DLayerBridgePtr bridge; | 574 Canvas2DLayerBridgePtr bridge; |
| 563 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); | 575 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); |
| 564 bridge->disableDeferral(DisableDeferralReasonUnknown); | 576 bridge->disableDeferral(DisableDeferralReasonUnknown); |
| 565 MockImageBuffer mockImageBuffer; | 577 MockImageBuffer mockImageBuffer; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 { | 625 { |
| 614 OwnPtr<WaitableEvent> doneEvent = adoptPtr(new WaitableEvent()); | 626 OwnPtr<WaitableEvent> doneEvent = adoptPtr(new WaitableEvent()); |
| 615 testThread->getWebTaskRunner()->postTask( | 627 testThread->getWebTaskRunner()->postTask( |
| 616 location, | 628 location, |
| 617 threadSafeBind(&runRenderingTask, | 629 threadSafeBind(&runRenderingTask, |
| 618 AllowCrossThreadAccess(bridge), | 630 AllowCrossThreadAccess(bridge), |
| 619 AllowCrossThreadAccess(doneEvent.get()))); | 631 AllowCrossThreadAccess(doneEvent.get()))); |
| 620 doneEvent->wait(); | 632 doneEvent->wait(); |
| 621 } | 633 } |
| 622 | 634 |
| 635 #if CANVAS2D_HIBERNATION_ENABLED |
| 623 TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernating) | 636 TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernating) |
| 637 #else |
| 638 TEST_F(Canvas2DLayerBridgeTest, DISABLED_BackgroundRenderingWhileHibernating) |
| 639 #endif |
| 624 { | 640 { |
| 625 MockCanvasContext mainMock; | 641 MockCanvasContext mainMock; |
| 626 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 642 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 627 | 643 |
| 628 // The Canvas2DLayerBridge has to be created on the thread that will use it | 644 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 629 // to avoid WeakPtr thread check issues. | 645 // to avoid WeakPtr thread check issues. |
| 630 Canvas2DLayerBridgePtr bridge; | 646 Canvas2DLayerBridgePtr bridge; |
| 631 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); | 647 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); |
| 632 | 648 |
| 633 // Register an alternate Logger for tracking hibernation events | 649 // Register an alternate Logger for tracking hibernation events |
| (...skipping 28 matching lines...) Expand all Loading... |
| 662 EXPECT_FALSE(bridge->isHibernating()); | 678 EXPECT_FALSE(bridge->isHibernating()); |
| 663 EXPECT_TRUE(bridge->checkSurfaceValid()); | 679 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 664 | 680 |
| 665 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 681 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 666 // without crashing due to thread checks | 682 // without crashing due to thread checks |
| 667 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 683 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 668 | 684 |
| 669 ::testing::Mock::VerifyAndClearExpectations(&mainMock); | 685 ::testing::Mock::VerifyAndClearExpectations(&mainMock); |
| 670 } | 686 } |
| 671 | 687 |
| 688 #if CANVAS2D_HIBERNATION_ENABLED |
| 672 TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernatingWithDeferredR
enderingDisabled) | 689 TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernatingWithDeferredR
enderingDisabled) |
| 690 #else |
| 691 TEST_F(Canvas2DLayerBridgeTest, DISABLED_BackgroundRenderingWhileHibernatingWith
DeferredRenderingDisabled) |
| 692 #endif |
| 673 { | 693 { |
| 674 MockCanvasContext mainMock; | 694 MockCanvasContext mainMock; |
| 675 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 695 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 676 | 696 |
| 677 // The Canvas2DLayerBridge has to be created on the thread that will use it | 697 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 678 // to avoid WeakPtr thread check issues. | 698 // to avoid WeakPtr thread check issues. |
| 679 Canvas2DLayerBridgePtr bridge; | 699 Canvas2DLayerBridgePtr bridge; |
| 680 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); | 700 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); |
| 681 MockImageBuffer mockImageBuffer; | 701 MockImageBuffer mockImageBuffer; |
| 682 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber()); | 702 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 EXPECT_TRUE(bridge->isAccelerated()); // Becoming visible causes switch back
to GPU | 739 EXPECT_TRUE(bridge->isAccelerated()); // Becoming visible causes switch back
to GPU |
| 720 EXPECT_FALSE(bridge->isHibernating()); | 740 EXPECT_FALSE(bridge->isHibernating()); |
| 721 EXPECT_TRUE(bridge->checkSurfaceValid()); | 741 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 722 | 742 |
| 723 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 743 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 724 // without crashing due to thread checks | 744 // without crashing due to thread checks |
| 725 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber()); | 745 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber()); |
| 726 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 746 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 727 } | 747 } |
| 728 | 748 |
| 749 #if CANVAS2D_HIBERNATION_ENABLED |
| 729 TEST_F(Canvas2DLayerBridgeTest, DisableDeferredRenderingWhileHibernating) | 750 TEST_F(Canvas2DLayerBridgeTest, DisableDeferredRenderingWhileHibernating) |
| 751 #else |
| 752 TEST_F(Canvas2DLayerBridgeTest, DISABLED_DisableDeferredRenderingWhileHibernatin
g) |
| 753 #endif |
| 730 { | 754 { |
| 731 MockCanvasContext mainMock; | 755 MockCanvasContext mainMock; |
| 732 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 756 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 733 | 757 |
| 734 // The Canvas2DLayerBridge has to be created on the thread that will use it | 758 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 735 // to avoid WeakPtr thread check issues. | 759 // to avoid WeakPtr thread check issues. |
| 736 Canvas2DLayerBridgePtr bridge; | 760 Canvas2DLayerBridgePtr bridge; |
| 737 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); | 761 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); |
| 738 MockImageBuffer mockImageBuffer; | 762 MockImageBuffer mockImageBuffer; |
| 739 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber()); | 763 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 EXPECT_TRUE(bridge->isAccelerated()); // Becoming visible causes switch back
to GPU | 799 EXPECT_TRUE(bridge->isAccelerated()); // Becoming visible causes switch back
to GPU |
| 776 EXPECT_FALSE(bridge->isHibernating()); | 800 EXPECT_FALSE(bridge->isHibernating()); |
| 777 EXPECT_TRUE(bridge->checkSurfaceValid()); | 801 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 778 | 802 |
| 779 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 803 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 780 // without crashing due to thread checks | 804 // without crashing due to thread checks |
| 781 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber()); | 805 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber()); |
| 782 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 806 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 783 } | 807 } |
| 784 | 808 |
| 809 #if CANVAS2D_HIBERNATION_ENABLED |
| 785 TEST_F(Canvas2DLayerBridgeTest, TeardownWhileHibernating) | 810 TEST_F(Canvas2DLayerBridgeTest, TeardownWhileHibernating) |
| 811 #else |
| 812 TEST_F(Canvas2DLayerBridgeTest, DISABLED_TeardownWhileHibernating) |
| 813 #endif |
| 786 { | 814 { |
| 787 MockCanvasContext mainMock; | 815 MockCanvasContext mainMock; |
| 788 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 816 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 789 | 817 |
| 790 // The Canvas2DLayerBridge has to be created on the thread that will use it | 818 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 791 // to avoid WeakPtr thread check issues. | 819 // to avoid WeakPtr thread check issues. |
| 792 Canvas2DLayerBridgePtr bridge; | 820 Canvas2DLayerBridgePtr bridge; |
| 793 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); | 821 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); |
| 794 | 822 |
| 795 // Register an alternate Logger for tracking hibernation events | 823 // Register an alternate Logger for tracking hibernation events |
| (...skipping 30 matching lines...) Expand all Loading... |
| 826 | 854 |
| 827 void run(double /*deadline*/) override | 855 void run(double /*deadline*/) override |
| 828 { | 856 { |
| 829 m_doneEvent->signal(); | 857 m_doneEvent->signal(); |
| 830 } | 858 } |
| 831 | 859 |
| 832 private: | 860 private: |
| 833 WaitableEvent* m_doneEvent; | 861 WaitableEvent* m_doneEvent; |
| 834 }; | 862 }; |
| 835 | 863 |
| 864 #if CANVAS2D_HIBERNATION_ENABLED |
| 836 TEST_F(Canvas2DLayerBridgeTest, TeardownWhileHibernationIsPending) | 865 TEST_F(Canvas2DLayerBridgeTest, TeardownWhileHibernationIsPending) |
| 866 #else |
| 867 TEST_F(Canvas2DLayerBridgeTest, DISABLED_TeardownWhileHibernationIsPending) |
| 868 #endif |
| 837 { | 869 { |
| 838 MockCanvasContext mainMock; | 870 MockCanvasContext mainMock; |
| 839 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 871 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 840 | 872 |
| 841 // The Canvas2DLayerBridge has to be created on the thread that will use it | 873 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 842 // to avoid WeakPtr thread check issues. | 874 // to avoid WeakPtr thread check issues. |
| 843 Canvas2DLayerBridgePtr bridge; | 875 Canvas2DLayerBridgePtr bridge; |
| 844 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); | 876 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); |
| 845 | 877 |
| 846 // Register an alternate Logger for tracking hibernation events | 878 // Register an alternate Logger for tracking hibernation events |
| (...skipping 17 matching lines...) Expand all Loading... |
| 864 // completion before the thread is destroyed. | 896 // completion before the thread is destroyed. |
| 865 // This test passes by not crashing, which proves that the WeakPtr logic | 897 // This test passes by not crashing, which proves that the WeakPtr logic |
| 866 // is sound. | 898 // is sound. |
| 867 OwnPtr<WaitableEvent> fenceEvent = adoptPtr(new WaitableEvent()); | 899 OwnPtr<WaitableEvent> fenceEvent = adoptPtr(new WaitableEvent()); |
| 868 testThread->scheduler()->postIdleTask(BLINK_FROM_HERE, new IdleFenceTask(fen
ceEvent.get())); | 900 testThread->scheduler()->postIdleTask(BLINK_FROM_HERE, new IdleFenceTask(fen
ceEvent.get())); |
| 869 fenceEvent->wait(); | 901 fenceEvent->wait(); |
| 870 | 902 |
| 871 ::testing::Mock::VerifyAndClearExpectations(&mainMock); | 903 ::testing::Mock::VerifyAndClearExpectations(&mainMock); |
| 872 } | 904 } |
| 873 | 905 |
| 906 #if CANVAS2D_HIBERNATION_ENABLED |
| 874 TEST_F(Canvas2DLayerBridgeTest, HibernationAbortedDueToPendingTeardown) | 907 TEST_F(Canvas2DLayerBridgeTest, HibernationAbortedDueToPendingTeardown) |
| 908 #else |
| 909 TEST_F(Canvas2DLayerBridgeTest, DISABLED_HibernationAbortedDueToPendingTeardown) |
| 910 #endif |
| 875 { | 911 { |
| 876 MockCanvasContext mainMock; | 912 MockCanvasContext mainMock; |
| 877 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 913 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 878 | 914 |
| 879 // The Canvas2DLayerBridge has to be created on the thread that will use it | 915 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 880 // to avoid WeakPtr thread check issues. | 916 // to avoid WeakPtr thread check issues. |
| 881 Canvas2DLayerBridgePtr bridge; | 917 Canvas2DLayerBridgePtr bridge; |
| 882 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); | 918 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); |
| 883 | 919 |
| 884 // Register an alternate Logger for tracking hibernation events | 920 // Register an alternate Logger for tracking hibernation events |
| (...skipping 11 matching lines...) Expand all Loading... |
| 896 hibernationAbortedEvent->wait(); | 932 hibernationAbortedEvent->wait(); |
| 897 | 933 |
| 898 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); | 934 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); |
| 899 | 935 |
| 900 // Tear down bridge on thread | 936 // Tear down bridge on thread |
| 901 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 937 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 902 | 938 |
| 903 ::testing::Mock::VerifyAndClearExpectations(&mainMock); | 939 ::testing::Mock::VerifyAndClearExpectations(&mainMock); |
| 904 } | 940 } |
| 905 | 941 |
| 942 #if CANVAS2D_HIBERNATION_ENABLED |
| 906 TEST_F(Canvas2DLayerBridgeTest, HibernationAbortedDueToVisibilityChange) | 943 TEST_F(Canvas2DLayerBridgeTest, HibernationAbortedDueToVisibilityChange) |
| 944 #else |
| 945 TEST_F(Canvas2DLayerBridgeTest, DISABLED_HibernationAbortedDueToVisibilityChange
) |
| 946 #endif |
| 907 { | 947 { |
| 908 MockCanvasContext mainMock; | 948 MockCanvasContext mainMock; |
| 909 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 949 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 910 | 950 |
| 911 // The Canvas2DLayerBridge has to be created on the thread that will use it | 951 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 912 // to avoid WeakPtr thread check issues. | 952 // to avoid WeakPtr thread check issues. |
| 913 Canvas2DLayerBridgePtr bridge; | 953 Canvas2DLayerBridgePtr bridge; |
| 914 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); | 954 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); |
| 915 | 955 |
| 916 // Register an alternate Logger for tracking hibernation events | 956 // Register an alternate Logger for tracking hibernation events |
| (...skipping 14 matching lines...) Expand all Loading... |
| 931 EXPECT_FALSE(bridge->isHibernating()); | 971 EXPECT_FALSE(bridge->isHibernating()); |
| 932 EXPECT_TRUE(bridge->checkSurfaceValid()); | 972 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 933 | 973 |
| 934 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 974 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 935 // without crashing due to thread checks | 975 // without crashing due to thread checks |
| 936 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 976 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 937 | 977 |
| 938 ::testing::Mock::VerifyAndClearExpectations(&mainMock); | 978 ::testing::Mock::VerifyAndClearExpectations(&mainMock); |
| 939 } | 979 } |
| 940 | 980 |
| 981 #if CANVAS2D_HIBERNATION_ENABLED |
| 941 TEST_F(Canvas2DLayerBridgeTest, HibernationAbortedDueToLostContext) | 982 TEST_F(Canvas2DLayerBridgeTest, HibernationAbortedDueToLostContext) |
| 983 #else |
| 984 TEST_F(Canvas2DLayerBridgeTest, DISABLED_HibernationAbortedDueToLostContext) |
| 985 #endif |
| 942 { | 986 { |
| 943 MockCanvasContext mainMock; | 987 MockCanvasContext mainMock; |
| 944 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 988 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 945 | 989 |
| 946 // The Canvas2DLayerBridge has to be created on the thread that will use it | 990 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 947 // to avoid WeakPtr thread check issues. | 991 // to avoid WeakPtr thread check issues. |
| 948 Canvas2DLayerBridgePtr bridge; | 992 Canvas2DLayerBridgePtr bridge; |
| 949 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); | 993 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); |
| 950 | 994 |
| 951 // Register an alternate Logger for tracking hibernation events | 995 // Register an alternate Logger for tracking hibernation events |
| (...skipping 12 matching lines...) Expand all Loading... |
| 964 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); | 1008 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); |
| 965 EXPECT_FALSE(bridge->isHibernating()); | 1009 EXPECT_FALSE(bridge->isHibernating()); |
| 966 | 1010 |
| 967 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 1011 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 968 // without crashing due to thread checks | 1012 // without crashing due to thread checks |
| 969 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 1013 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 970 | 1014 |
| 971 ::testing::Mock::VerifyAndClearExpectations(&mainMock); | 1015 ::testing::Mock::VerifyAndClearExpectations(&mainMock); |
| 972 } | 1016 } |
| 973 | 1017 |
| 1018 #if CANVAS2D_HIBERNATION_ENABLED |
| 974 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWhileHibernating) | 1019 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWhileHibernating) |
| 1020 #else |
| 1021 TEST_F(Canvas2DLayerBridgeTest, DISABLED_PrepareMailboxWhileHibernating) |
| 1022 #endif |
| 975 { | 1023 { |
| 976 MockCanvasContext mainMock; | 1024 MockCanvasContext mainMock; |
| 977 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 1025 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 978 | 1026 |
| 979 // The Canvas2DLayerBridge has to be created on the thread that will use it | 1027 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 980 // to avoid WeakPtr thread check issues. | 1028 // to avoid WeakPtr thread check issues. |
| 981 Canvas2DLayerBridgePtr bridge; | 1029 Canvas2DLayerBridgePtr bridge; |
| 982 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); | 1030 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); |
| 983 | 1031 |
| 984 // Register an alternate Logger for tracking hibernation events | 1032 // Register an alternate Logger for tracking hibernation events |
| (...skipping 14 matching lines...) Expand all Loading... |
| 999 WebExternalTextureMailbox mailbox; | 1047 WebExternalTextureMailbox mailbox; |
| 1000 EXPECT_FALSE(bridge->prepareMailbox(&mailbox, 0)); | 1048 EXPECT_FALSE(bridge->prepareMailbox(&mailbox, 0)); |
| 1001 EXPECT_TRUE(bridge->checkSurfaceValid()); | 1049 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 1002 | 1050 |
| 1003 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 1051 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 1004 // without crashing due to thread checks | 1052 // without crashing due to thread checks |
| 1005 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::Hibe
rnationEndedWithTeardown)); | 1053 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::Hibe
rnationEndedWithTeardown)); |
| 1006 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 1054 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 1007 } | 1055 } |
| 1008 | 1056 |
| 1057 #if CANVAS2D_HIBERNATION_ENABLED |
| 1009 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWhileBackgroundRendering) | 1058 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWhileBackgroundRendering) |
| 1059 #else |
| 1060 TEST_F(Canvas2DLayerBridgeTest, DISABLED_PrepareMailboxWhileBackgroundRendering) |
| 1061 #endif |
| 1010 { | 1062 { |
| 1011 MockCanvasContext mainMock; | 1063 MockCanvasContext mainMock; |
| 1012 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 1064 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 1013 | 1065 |
| 1014 // The Canvas2DLayerBridge has to be created on the thread that will use it | 1066 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 1015 // to avoid WeakPtr thread check issues. | 1067 // to avoid WeakPtr thread check issues. |
| 1016 Canvas2DLayerBridgePtr bridge; | 1068 Canvas2DLayerBridgePtr bridge; |
| 1017 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); | 1069 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &mai
nMock, this); |
| 1018 | 1070 |
| 1019 // Register an alternate Logger for tracking hibernation events | 1071 // Register an alternate Logger for tracking hibernation events |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1042 WebExternalTextureMailbox mailbox; | 1094 WebExternalTextureMailbox mailbox; |
| 1043 EXPECT_FALSE(bridge->prepareMailbox(&mailbox, 0)); | 1095 EXPECT_FALSE(bridge->prepareMailbox(&mailbox, 0)); |
| 1044 EXPECT_TRUE(bridge->checkSurfaceValid()); | 1096 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 1045 | 1097 |
| 1046 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 1098 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 1047 // without crashing due to thread checks | 1099 // without crashing due to thread checks |
| 1048 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 1100 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 1049 } | 1101 } |
| 1050 | 1102 |
| 1051 } // namespace blink | 1103 } // namespace blink |
| OLD | NEW |