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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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 /* 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 } 422 }
423 423
424 void postAndWaitCreateBridgeTask(const WebTraceLocation& location, 424 void postAndWaitCreateBridgeTask(const WebTraceLocation& location,
425 WebThread* testThread, 425 WebThread* testThread,
426 Canvas2DLayerBridgePtr* bridgePtr, 426 Canvas2DLayerBridgePtr* bridgePtr,
427 gpu::gles2::GLES2Interface* gl, 427 gpu::gles2::GLES2Interface* gl,
428 Canvas2DLayerBridgeTest* testHost) { 428 Canvas2DLayerBridgeTest* testHost) {
429 std::unique_ptr<WaitableEvent> bridgeCreatedEvent = 429 std::unique_ptr<WaitableEvent> bridgeCreatedEvent =
430 WTF::makeUnique<WaitableEvent>(); 430 WTF::makeUnique<WaitableEvent>();
431 testThread->getWebTaskRunner()->postTask( 431 testThread->getWebTaskRunner()->postTask(
432 location, crossThreadBind( 432 location,
433 &runCreateBridgeTask, crossThreadUnretained(bridgePtr), 433 crossThreadBind(&runCreateBridgeTask, crossThreadUnretained(bridgePtr),
434 crossThreadUnretained(gl), crossThreadUnretained(testHost), 434 crossThreadUnretained(gl),
435 crossThreadUnretained(bridgeCreatedEvent.get()))); 435 crossThreadUnretained(testHost),
436 crossThreadUnretained(bridgeCreatedEvent.get())));
436 bridgeCreatedEvent->wait(); 437 bridgeCreatedEvent->wait();
437 } 438 }
438 439
439 void runDestroyBridgeTask(Canvas2DLayerBridgePtr* bridgePtr, 440 void runDestroyBridgeTask(Canvas2DLayerBridgePtr* bridgePtr,
440 WaitableEvent* doneEvent) { 441 WaitableEvent* doneEvent) {
441 bridgePtr->clear(); 442 bridgePtr->clear();
442 if (doneEvent) 443 if (doneEvent)
443 doneEvent->signal(); 444 doneEvent->signal();
444 } 445 }
445 446
446 void postDestroyBridgeTask(const WebTraceLocation& location, 447 void postDestroyBridgeTask(const WebTraceLocation& location,
447 WebThread* testThread, 448 WebThread* testThread,
448 Canvas2DLayerBridgePtr* bridgePtr) { 449 Canvas2DLayerBridgePtr* bridgePtr) {
449 testThread->getWebTaskRunner()->postTask( 450 testThread->getWebTaskRunner()->postTask(
450 location, crossThreadBind(&runDestroyBridgeTask, 451 location,
451 crossThreadUnretained(bridgePtr), nullptr)); 452 crossThreadBind(&runDestroyBridgeTask, crossThreadUnretained(bridgePtr),
453 nullptr));
452 } 454 }
453 455
454 void postAndWaitDestroyBridgeTask(const WebTraceLocation& location, 456 void postAndWaitDestroyBridgeTask(const WebTraceLocation& location,
455 WebThread* testThread, 457 WebThread* testThread,
456 Canvas2DLayerBridgePtr* bridgePtr) { 458 Canvas2DLayerBridgePtr* bridgePtr) {
457 std::unique_ptr<WaitableEvent> bridgeDestroyedEvent = 459 std::unique_ptr<WaitableEvent> bridgeDestroyedEvent =
458 WTF::makeUnique<WaitableEvent>(); 460 WTF::makeUnique<WaitableEvent>();
459 testThread->getWebTaskRunner()->postTask( 461 testThread->getWebTaskRunner()->postTask(
460 location, 462 location,
461 crossThreadBind(&runDestroyBridgeTask, crossThreadUnretained(bridgePtr), 463 crossThreadBind(&runDestroyBridgeTask, crossThreadUnretained(bridgePtr),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 this); 521 this);
520 522
521 // Register an alternate Logger for tracking hibernation events 523 // Register an alternate Logger for tracking hibernation events
522 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger); 524 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger);
523 MockLogger* mockLoggerPtr = mockLogger.get(); 525 MockLogger* mockLoggerPtr = mockLogger.get();
524 bridge->setLoggerForTesting(std::move(mockLogger)); 526 bridge->setLoggerForTesting(std::move(mockLogger));
525 527
526 // Test entering hibernation 528 // Test entering hibernation
527 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 529 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
528 WTF::makeUnique<WaitableEvent>(); 530 WTF::makeUnique<WaitableEvent>();
529 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 531 EXPECT_CALL(
530 Canvas2DLayerBridge::HibernationScheduled)); 532 *mockLoggerPtr,
533 reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
531 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 534 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
532 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 535 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
533 &WaitableEvent::signal)); 536 &WaitableEvent::signal));
534 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 537 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
535 hibernationStartedEvent->wait(); 538 hibernationStartedEvent->wait();
536 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 539 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
537 EXPECT_FALSE(bridge->isAccelerated()); 540 EXPECT_FALSE(bridge->isAccelerated());
538 EXPECT_TRUE(bridge->isHibernating()); 541 EXPECT_TRUE(bridge->isHibernating());
539 EXPECT_TRUE(bridge->checkSurfaceValid()); 542 EXPECT_TRUE(bridge->checkSurfaceValid());
540 543
(...skipping 30 matching lines...) Expand all
571 this); 574 this);
572 575
573 // Register an alternate Logger for tracking hibernation events 576 // Register an alternate Logger for tracking hibernation events
574 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger); 577 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger);
575 MockLogger* mockLoggerPtr = mockLogger.get(); 578 MockLogger* mockLoggerPtr = mockLogger.get();
576 bridge->setLoggerForTesting(std::move(mockLogger)); 579 bridge->setLoggerForTesting(std::move(mockLogger));
577 580
578 // Test entering hibernation 581 // Test entering hibernation
579 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 582 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
580 WTF::makeUnique<WaitableEvent>(); 583 WTF::makeUnique<WaitableEvent>();
581 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 584 EXPECT_CALL(
582 Canvas2DLayerBridge::HibernationScheduled)); 585 *mockLoggerPtr,
586 reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
583 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 587 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
584 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 588 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
585 &WaitableEvent::signal)); 589 &WaitableEvent::signal));
586 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 590 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
587 // Toggle visibility before the task that enters hibernation gets a 591 // Toggle visibility before the task that enters hibernation gets a
588 // chance to run. 592 // chance to run.
589 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), false); 593 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), false);
590 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 594 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
591 595
592 hibernationStartedEvent->wait(); 596 hibernationStartedEvent->wait();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 bridge->setImageBuffer(&mockImageBuffer); 638 bridge->setImageBuffer(&mockImageBuffer);
635 639
636 // Register an alternate Logger for tracking hibernation events 640 // Register an alternate Logger for tracking hibernation events
637 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger); 641 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger);
638 MockLogger* mockLoggerPtr = mockLogger.get(); 642 MockLogger* mockLoggerPtr = mockLogger.get();
639 bridge->setLoggerForTesting(std::move(mockLogger)); 643 bridge->setLoggerForTesting(std::move(mockLogger));
640 644
641 // Test entering hibernation 645 // Test entering hibernation
642 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 646 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
643 WTF::makeUnique<WaitableEvent>(); 647 WTF::makeUnique<WaitableEvent>();
644 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 648 EXPECT_CALL(
645 Canvas2DLayerBridge::HibernationScheduled)); 649 *mockLoggerPtr,
650 reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
646 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 651 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
647 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 652 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
648 &WaitableEvent::signal)); 653 &WaitableEvent::signal));
649 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 654 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
650 hibernationStartedEvent->wait(); 655 hibernationStartedEvent->wait();
651 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 656 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
652 ::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer); 657 ::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer);
653 EXPECT_FALSE(bridge->isAccelerated()); 658 EXPECT_FALSE(bridge->isAccelerated());
654 EXPECT_TRUE(bridge->isHibernating()); 659 EXPECT_TRUE(bridge->isHibernating());
655 EXPECT_TRUE(bridge->checkSurfaceValid()); 660 EXPECT_TRUE(bridge->checkSurfaceValid());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 this); 713 this);
709 714
710 // Register an alternate Logger for tracking hibernation events 715 // Register an alternate Logger for tracking hibernation events
711 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger); 716 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger);
712 MockLogger* mockLoggerPtr = mockLogger.get(); 717 MockLogger* mockLoggerPtr = mockLogger.get();
713 bridge->setLoggerForTesting(std::move(mockLogger)); 718 bridge->setLoggerForTesting(std::move(mockLogger));
714 719
715 // Test entering hibernation 720 // Test entering hibernation
716 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 721 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
717 WTF::makeUnique<WaitableEvent>(); 722 WTF::makeUnique<WaitableEvent>();
718 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 723 EXPECT_CALL(
719 Canvas2DLayerBridge::HibernationScheduled)); 724 *mockLoggerPtr,
725 reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
720 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 726 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
721 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 727 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
722 &WaitableEvent::signal)); 728 &WaitableEvent::signal));
723 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 729 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
724 hibernationStartedEvent->wait(); 730 hibernationStartedEvent->wait();
725 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 731 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
726 EXPECT_FALSE(bridge->isAccelerated()); 732 EXPECT_FALSE(bridge->isAccelerated());
727 EXPECT_TRUE(bridge->isHibernating()); 733 EXPECT_TRUE(bridge->isHibernating());
728 EXPECT_TRUE(bridge->checkSurfaceValid()); 734 EXPECT_TRUE(bridge->checkSurfaceValid());
729 735
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 bridge->disableDeferral(DisableDeferralReasonUnknown); 782 bridge->disableDeferral(DisableDeferralReasonUnknown);
777 783
778 // Register an alternate Logger for tracking hibernation events 784 // Register an alternate Logger for tracking hibernation events
779 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger); 785 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger);
780 MockLogger* mockLoggerPtr = mockLogger.get(); 786 MockLogger* mockLoggerPtr = mockLogger.get();
781 bridge->setLoggerForTesting(std::move(mockLogger)); 787 bridge->setLoggerForTesting(std::move(mockLogger));
782 788
783 // Test entering hibernation 789 // Test entering hibernation
784 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 790 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
785 WTF::makeUnique<WaitableEvent>(); 791 WTF::makeUnique<WaitableEvent>();
786 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 792 EXPECT_CALL(
787 Canvas2DLayerBridge::HibernationScheduled)); 793 *mockLoggerPtr,
794 reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
788 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 795 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
789 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 796 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
790 &WaitableEvent::signal)); 797 &WaitableEvent::signal));
791 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 798 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
792 hibernationStartedEvent->wait(); 799 hibernationStartedEvent->wait();
793 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 800 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
794 ::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer); 801 ::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer);
795 EXPECT_FALSE(bridge->isAccelerated()); 802 EXPECT_FALSE(bridge->isAccelerated());
796 EXPECT_TRUE(bridge->isHibernating()); 803 EXPECT_TRUE(bridge->isHibernating());
797 EXPECT_TRUE(bridge->checkSurfaceValid()); 804 EXPECT_TRUE(bridge->checkSurfaceValid());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 bridge->setImageBuffer(&mockImageBuffer); 854 bridge->setImageBuffer(&mockImageBuffer);
848 855
849 // Register an alternate Logger for tracking hibernation events 856 // Register an alternate Logger for tracking hibernation events
850 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger); 857 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger);
851 MockLogger* mockLoggerPtr = mockLogger.get(); 858 MockLogger* mockLoggerPtr = mockLogger.get();
852 bridge->setLoggerForTesting(std::move(mockLogger)); 859 bridge->setLoggerForTesting(std::move(mockLogger));
853 860
854 // Test entering hibernation 861 // Test entering hibernation
855 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 862 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
856 WTF::makeUnique<WaitableEvent>(); 863 WTF::makeUnique<WaitableEvent>();
857 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 864 EXPECT_CALL(
858 Canvas2DLayerBridge::HibernationScheduled)); 865 *mockLoggerPtr,
866 reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
859 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 867 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
860 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 868 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
861 &WaitableEvent::signal)); 869 &WaitableEvent::signal));
862 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 870 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
863 hibernationStartedEvent->wait(); 871 hibernationStartedEvent->wait();
864 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 872 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
865 ::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer); 873 ::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer);
866 EXPECT_FALSE(bridge->isAccelerated()); 874 EXPECT_FALSE(bridge->isAccelerated());
867 EXPECT_TRUE(bridge->isHibernating()); 875 EXPECT_TRUE(bridge->isHibernating());
868 EXPECT_TRUE(bridge->checkSurfaceValid()); 876 EXPECT_TRUE(bridge->checkSurfaceValid());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 this); 922 this);
915 923
916 // Register an alternate Logger for tracking hibernation events 924 // Register an alternate Logger for tracking hibernation events
917 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger); 925 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger);
918 MockLogger* mockLoggerPtr = mockLogger.get(); 926 MockLogger* mockLoggerPtr = mockLogger.get();
919 bridge->setLoggerForTesting(std::move(mockLogger)); 927 bridge->setLoggerForTesting(std::move(mockLogger));
920 928
921 // Test entering hibernation 929 // Test entering hibernation
922 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 930 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
923 WTF::makeUnique<WaitableEvent>(); 931 WTF::makeUnique<WaitableEvent>();
924 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 932 EXPECT_CALL(
925 Canvas2DLayerBridge::HibernationScheduled)); 933 *mockLoggerPtr,
934 reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
926 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 935 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
927 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 936 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
928 &WaitableEvent::signal)); 937 &WaitableEvent::signal));
929 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 938 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
930 hibernationStartedEvent->wait(); 939 hibernationStartedEvent->wait();
931 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 940 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
932 EXPECT_FALSE(bridge->isAccelerated()); 941 EXPECT_FALSE(bridge->isAccelerated());
933 EXPECT_TRUE(bridge->isHibernating()); 942 EXPECT_TRUE(bridge->isHibernating());
934 EXPECT_TRUE(bridge->checkSurfaceValid()); 943 EXPECT_TRUE(bridge->checkSurfaceValid());
935 944
(...skipping 21 matching lines...) Expand all
957 this); 966 this);
958 967
959 // Register an alternate Logger for tracking hibernation events 968 // Register an alternate Logger for tracking hibernation events
960 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger); 969 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger);
961 MockLogger* mockLoggerPtr = mockLogger.get(); 970 MockLogger* mockLoggerPtr = mockLogger.get();
962 bridge->setLoggerForTesting(std::move(mockLogger)); 971 bridge->setLoggerForTesting(std::move(mockLogger));
963 972
964 // Test entering hibernation 973 // Test entering hibernation
965 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 974 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
966 WTF::makeUnique<WaitableEvent>(); 975 WTF::makeUnique<WaitableEvent>();
967 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 976 EXPECT_CALL(
968 Canvas2DLayerBridge::HibernationScheduled)); 977 *mockLoggerPtr,
978 reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
969 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 979 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
970 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 980 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
971 &WaitableEvent::signal)); 981 &WaitableEvent::signal));
972 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 982 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
973 hibernationStartedEvent->wait(); 983 hibernationStartedEvent->wait();
974 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 984 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
975 EXPECT_FALSE(bridge->isAccelerated()); 985 EXPECT_FALSE(bridge->isAccelerated());
976 EXPECT_TRUE(bridge->isHibernating()); 986 EXPECT_TRUE(bridge->isHibernating());
977 EXPECT_TRUE(bridge->checkSurfaceValid()); 987 EXPECT_TRUE(bridge->checkSurfaceValid());
978 988
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 this); 1029 this);
1020 1030
1021 // Register an alternate Logger for tracking hibernation events 1031 // Register an alternate Logger for tracking hibernation events
1022 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger); 1032 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger);
1023 MockLogger* mockLoggerPtr = mockLogger.get(); 1033 MockLogger* mockLoggerPtr = mockLogger.get();
1024 bridge->setLoggerForTesting(std::move(mockLogger)); 1034 bridge->setLoggerForTesting(std::move(mockLogger));
1025 1035
1026 // Test entering hibernation 1036 // Test entering hibernation
1027 std::unique_ptr<WaitableEvent> hibernationScheduledEvent = 1037 std::unique_ptr<WaitableEvent> hibernationScheduledEvent =
1028 WTF::makeUnique<WaitableEvent>(); 1038 WTF::makeUnique<WaitableEvent>();
1029 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 1039 EXPECT_CALL(
1030 Canvas2DLayerBridge::HibernationScheduled)); 1040 *mockLoggerPtr,
1041 reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
1031 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true, 1042 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true,
1032 hibernationScheduledEvent.get()); 1043 hibernationScheduledEvent.get());
1033 postDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); 1044 postDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
1034 // In production, we would expect a 1045 // In production, we would expect a
1035 // HibernationAbortedDueToDestructionWhileHibernatePending event to be 1046 // HibernationAbortedDueToDestructionWhileHibernatePending event to be
1036 // fired, but that signal is lost in the unit test due to no longer having 1047 // fired, but that signal is lost in the unit test due to no longer having
1037 // a bridge to hold the mockLogger. 1048 // a bridge to hold the mockLogger.
1038 hibernationScheduledEvent->wait(); 1049 hibernationScheduledEvent->wait();
1039 // Once we know the hibernation task is scheduled, we can schedule a fence. 1050 // Once we know the hibernation task is scheduled, we can schedule a fence.
1040 // Assuming tasks are guaranteed to run in the order they were 1051 // Assuming tasks are guaranteed to run in the order they were
(...skipping 25 matching lines...) Expand all
1066 this); 1077 this);
1067 1078
1068 // Register an alternate Logger for tracking hibernation events 1079 // Register an alternate Logger for tracking hibernation events
1069 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger); 1080 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger);
1070 MockLogger* mockLoggerPtr = mockLogger.get(); 1081 MockLogger* mockLoggerPtr = mockLogger.get();
1071 bridge->setLoggerForTesting(std::move(mockLogger)); 1082 bridge->setLoggerForTesting(std::move(mockLogger));
1072 1083
1073 // Test entering hibernation 1084 // Test entering hibernation
1074 std::unique_ptr<WaitableEvent> hibernationAbortedEvent = 1085 std::unique_ptr<WaitableEvent> hibernationAbortedEvent =
1075 WTF::makeUnique<WaitableEvent>(); 1086 WTF::makeUnique<WaitableEvent>();
1076 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 1087 EXPECT_CALL(
1077 Canvas2DLayerBridge::HibernationScheduled)); 1088 *mockLoggerPtr,
1089 reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
1078 EXPECT_CALL( 1090 EXPECT_CALL(
1079 *mockLoggerPtr, 1091 *mockLoggerPtr,
1080 reportHibernationEvent( 1092 reportHibernationEvent(
1081 Canvas2DLayerBridge::HibernationAbortedDueToPendingDestruction)) 1093 Canvas2DLayerBridge::HibernationAbortedDueToPendingDestruction))
1082 .WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(), 1094 .WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(),
1083 &WaitableEvent::signal)); 1095 &WaitableEvent::signal));
1084 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 1096 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
1085 testThread->getWebTaskRunner()->postTask( 1097 testThread->getWebTaskRunner()->postTask(
1086 BLINK_FROM_HERE, crossThreadBind(&Canvas2DLayerBridge::beginDestruction, 1098 BLINK_FROM_HERE,
1087 crossThreadUnretained(bridge.get()))); 1099 crossThreadBind(&Canvas2DLayerBridge::beginDestruction,
1100 crossThreadUnretained(bridge.get())));
1088 hibernationAbortedEvent->wait(); 1101 hibernationAbortedEvent->wait();
1089 1102
1090 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 1103 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
1091 1104
1092 // Tear down bridge on thread 1105 // Tear down bridge on thread
1093 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); 1106 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
1094 } 1107 }
1095 1108
1096 #if CANVAS2D_HIBERNATION_ENABLED 1109 #if CANVAS2D_HIBERNATION_ENABLED
1097 TEST_F(Canvas2DLayerBridgeTest, HibernationAbortedDueToVisibilityChange) 1110 TEST_F(Canvas2DLayerBridgeTest, HibernationAbortedDueToVisibilityChange)
(...skipping 13 matching lines...) Expand all
1111 this); 1124 this);
1112 1125
1113 // Register an alternate Logger for tracking hibernation events 1126 // Register an alternate Logger for tracking hibernation events
1114 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger); 1127 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger);
1115 MockLogger* mockLoggerPtr = mockLogger.get(); 1128 MockLogger* mockLoggerPtr = mockLogger.get();
1116 bridge->setLoggerForTesting(std::move(mockLogger)); 1129 bridge->setLoggerForTesting(std::move(mockLogger));
1117 1130
1118 // Test entering hibernation 1131 // Test entering hibernation
1119 std::unique_ptr<WaitableEvent> hibernationAbortedEvent = 1132 std::unique_ptr<WaitableEvent> hibernationAbortedEvent =
1120 WTF::makeUnique<WaitableEvent>(); 1133 WTF::makeUnique<WaitableEvent>();
1121 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 1134 EXPECT_CALL(
1122 Canvas2DLayerBridge::HibernationScheduled)); 1135 *mockLoggerPtr,
1136 reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
1123 EXPECT_CALL(*mockLoggerPtr, 1137 EXPECT_CALL(*mockLoggerPtr,
1124 reportHibernationEvent( 1138 reportHibernationEvent(
1125 Canvas2DLayerBridge::HibernationAbortedDueToVisibilityChange)) 1139 Canvas2DLayerBridge::HibernationAbortedDueToVisibilityChange))
1126 .WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(), 1140 .WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(),
1127 &WaitableEvent::signal)); 1141 &WaitableEvent::signal));
1128 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 1142 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
1129 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), false); 1143 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), false);
1130 hibernationAbortedEvent->wait(); 1144 hibernationAbortedEvent->wait();
1131 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 1145 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
1132 EXPECT_TRUE(bridge->isAccelerated()); 1146 EXPECT_TRUE(bridge->isAccelerated());
(...skipping 23 matching lines...) Expand all
1156 1170
1157 // Register an alternate Logger for tracking hibernation events 1171 // Register an alternate Logger for tracking hibernation events
1158 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger); 1172 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger);
1159 MockLogger* mockLoggerPtr = mockLogger.get(); 1173 MockLogger* mockLoggerPtr = mockLogger.get();
1160 bridge->setLoggerForTesting(std::move(mockLogger)); 1174 bridge->setLoggerForTesting(std::move(mockLogger));
1161 1175
1162 gl.setIsContextLost(true); 1176 gl.setIsContextLost(true);
1163 // Test entering hibernation 1177 // Test entering hibernation
1164 std::unique_ptr<WaitableEvent> hibernationAbortedEvent = 1178 std::unique_ptr<WaitableEvent> hibernationAbortedEvent =
1165 WTF::makeUnique<WaitableEvent>(); 1179 WTF::makeUnique<WaitableEvent>();
1166 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 1180 EXPECT_CALL(
1167 Canvas2DLayerBridge::HibernationScheduled)); 1181 *mockLoggerPtr,
1182 reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
1168 EXPECT_CALL(*mockLoggerPtr, 1183 EXPECT_CALL(*mockLoggerPtr,
1169 reportHibernationEvent( 1184 reportHibernationEvent(
1170 Canvas2DLayerBridge::HibernationAbortedDueGpuContextLoss)) 1185 Canvas2DLayerBridge::HibernationAbortedDueGpuContextLoss))
1171 .WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(), 1186 .WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(),
1172 &WaitableEvent::signal)); 1187 &WaitableEvent::signal));
1173 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 1188 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
1174 hibernationAbortedEvent->wait(); 1189 hibernationAbortedEvent->wait();
1175 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 1190 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
1176 EXPECT_FALSE(bridge->isHibernating()); 1191 EXPECT_FALSE(bridge->isHibernating());
1177 1192
(...skipping 19 matching lines...) Expand all
1197 this); 1212 this);
1198 1213
1199 // Register an alternate Logger for tracking hibernation events 1214 // Register an alternate Logger for tracking hibernation events
1200 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger); 1215 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger);
1201 MockLogger* mockLoggerPtr = mockLogger.get(); 1216 MockLogger* mockLoggerPtr = mockLogger.get();
1202 bridge->setLoggerForTesting(std::move(mockLogger)); 1217 bridge->setLoggerForTesting(std::move(mockLogger));
1203 1218
1204 // Test entering hibernation 1219 // Test entering hibernation
1205 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 1220 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
1206 WTF::makeUnique<WaitableEvent>(); 1221 WTF::makeUnique<WaitableEvent>();
1207 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 1222 EXPECT_CALL(
1208 Canvas2DLayerBridge::HibernationScheduled)); 1223 *mockLoggerPtr,
1224 reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
1209 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 1225 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
1210 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 1226 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
1211 &WaitableEvent::signal)); 1227 &WaitableEvent::signal));
1212 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 1228 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
1213 hibernationStartedEvent->wait(); 1229 hibernationStartedEvent->wait();
1214 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 1230 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
1215 1231
1216 // Test prepareMailbox while hibernating 1232 // Test prepareMailbox while hibernating
1217 cc::TextureMailbox textureMailbox; 1233 cc::TextureMailbox textureMailbox;
1218 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; 1234 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback;
(...skipping 26 matching lines...) Expand all
1245 this); 1261 this);
1246 1262
1247 // Register an alternate Logger for tracking hibernation events 1263 // Register an alternate Logger for tracking hibernation events
1248 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger); 1264 std::unique_ptr<MockLogger> mockLogger = WTF::wrapUnique(new MockLogger);
1249 MockLogger* mockLoggerPtr = mockLogger.get(); 1265 MockLogger* mockLoggerPtr = mockLogger.get();
1250 bridge->setLoggerForTesting(std::move(mockLogger)); 1266 bridge->setLoggerForTesting(std::move(mockLogger));
1251 1267
1252 // Test entering hibernation 1268 // Test entering hibernation
1253 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 1269 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
1254 WTF::makeUnique<WaitableEvent>(); 1270 WTF::makeUnique<WaitableEvent>();
1255 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 1271 EXPECT_CALL(
1256 Canvas2DLayerBridge::HibernationScheduled)); 1272 *mockLoggerPtr,
1273 reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
1257 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 1274 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
1258 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 1275 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
1259 &WaitableEvent::signal)); 1276 &WaitableEvent::signal));
1260 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 1277 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
1261 hibernationStartedEvent->wait(); 1278 hibernationStartedEvent->wait();
1262 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 1279 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
1263 1280
1264 // Rendering in the background -> temp switch to SW 1281 // Rendering in the background -> temp switch to SW
1265 EXPECT_CALL(*mockLoggerPtr, 1282 EXPECT_CALL(*mockLoggerPtr,
1266 reportHibernationEvent( 1283 reportHibernationEvent(
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 EXPECT_FALSE(bridge->hasRecordedDrawCommands()); 1385 EXPECT_FALSE(bridge->hasRecordedDrawCommands());
1369 ::testing::Mock::VerifyAndClearExpectations(&gl); 1386 ::testing::Mock::VerifyAndClearExpectations(&gl);
1370 1387
1371 EXPECT_CALL(gl, Flush()).Times(1); 1388 EXPECT_CALL(gl, Flush()).Times(1);
1372 bridge->flushGpu(); 1389 bridge->flushGpu();
1373 EXPECT_FALSE(bridge->hasRecordedDrawCommands()); 1390 EXPECT_FALSE(bridge->hasRecordedDrawCommands());
1374 ::testing::Mock::VerifyAndClearExpectations(&gl); 1391 ::testing::Mock::VerifyAndClearExpectations(&gl);
1375 } 1392 }
1376 1393
1377 } // namespace blink 1394 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698