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

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

Issue 2494333002: Replace wrapUnique(new T(args)) by makeUnique<T>(args) in Blink (Closed)
Patch Set: Drop redundant WTF:: Created 4 years, 1 month 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 void(Canvas2DLayerBridge::HibernationEvent)); 340 void(Canvas2DLayerBridge::HibernationEvent));
341 MOCK_METHOD0(didStartHibernating, void()); 341 MOCK_METHOD0(didStartHibernating, void());
342 virtual ~MockLogger() {} 342 virtual ~MockLogger() {}
343 }; 343 };
344 344
345 void runCreateBridgeTask(Canvas2DLayerBridgePtr* bridgePtr, 345 void runCreateBridgeTask(Canvas2DLayerBridgePtr* bridgePtr,
346 gpu::gles2::GLES2Interface* gl, 346 gpu::gles2::GLES2Interface* gl,
347 Canvas2DLayerBridgeTest* testHost, 347 Canvas2DLayerBridgeTest* testHost,
348 WaitableEvent* doneEvent) { 348 WaitableEvent* doneEvent) {
349 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = 349 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
350 wrapUnique(new FakeWebGraphicsContext3DProvider(gl)); 350 makeUnique<FakeWebGraphicsContext3DProvider>(gl);
351 *bridgePtr = 351 *bridgePtr =
352 testHost->makeBridge(std::move(contextProvider), IntSize(300, 300), 352 testHost->makeBridge(std::move(contextProvider), IntSize(300, 300),
353 Canvas2DLayerBridge::EnableAcceleration); 353 Canvas2DLayerBridge::EnableAcceleration);
354 // draw+flush to trigger the creation of a GPU surface 354 // draw+flush to trigger the creation of a GPU surface
355 (*bridgePtr)->didDraw(FloatRect(0, 0, 1, 1)); 355 (*bridgePtr)->didDraw(FloatRect(0, 0, 1, 1));
356 (*bridgePtr)->finalizeFrame(FloatRect(0, 0, 1, 1)); 356 (*bridgePtr)->finalizeFrame(FloatRect(0, 0, 1, 1));
357 (*bridgePtr)->flush(); 357 (*bridgePtr)->flush();
358 doneEvent->signal(); 358 doneEvent->signal();
359 } 359 }
360 360
361 void postAndWaitCreateBridgeTask(const WebTraceLocation& location, 361 void postAndWaitCreateBridgeTask(const WebTraceLocation& location,
362 WebThread* testThread, 362 WebThread* testThread,
363 Canvas2DLayerBridgePtr* bridgePtr, 363 Canvas2DLayerBridgePtr* bridgePtr,
364 gpu::gles2::GLES2Interface* gl, 364 gpu::gles2::GLES2Interface* gl,
365 Canvas2DLayerBridgeTest* testHost) { 365 Canvas2DLayerBridgeTest* testHost) {
366 std::unique_ptr<WaitableEvent> bridgeCreatedEvent = 366 std::unique_ptr<WaitableEvent> bridgeCreatedEvent =
367 wrapUnique(new WaitableEvent()); 367 makeUnique<WaitableEvent>();
368 testThread->getWebTaskRunner()->postTask( 368 testThread->getWebTaskRunner()->postTask(
369 location, crossThreadBind( 369 location, crossThreadBind(
370 &runCreateBridgeTask, crossThreadUnretained(bridgePtr), 370 &runCreateBridgeTask, crossThreadUnretained(bridgePtr),
371 crossThreadUnretained(gl), crossThreadUnretained(testHost), 371 crossThreadUnretained(gl), crossThreadUnretained(testHost),
372 crossThreadUnretained(bridgeCreatedEvent.get()))); 372 crossThreadUnretained(bridgeCreatedEvent.get())));
373 bridgeCreatedEvent->wait(); 373 bridgeCreatedEvent->wait();
374 } 374 }
375 375
376 void runDestroyBridgeTask(Canvas2DLayerBridgePtr* bridgePtr, 376 void runDestroyBridgeTask(Canvas2DLayerBridgePtr* bridgePtr,
377 WaitableEvent* doneEvent) { 377 WaitableEvent* doneEvent) {
378 bridgePtr->clear(); 378 bridgePtr->clear();
379 if (doneEvent) 379 if (doneEvent)
380 doneEvent->signal(); 380 doneEvent->signal();
381 } 381 }
382 382
383 void postDestroyBridgeTask(const WebTraceLocation& location, 383 void postDestroyBridgeTask(const WebTraceLocation& location,
384 WebThread* testThread, 384 WebThread* testThread,
385 Canvas2DLayerBridgePtr* bridgePtr) { 385 Canvas2DLayerBridgePtr* bridgePtr) {
386 testThread->getWebTaskRunner()->postTask( 386 testThread->getWebTaskRunner()->postTask(
387 location, crossThreadBind(&runDestroyBridgeTask, 387 location, crossThreadBind(&runDestroyBridgeTask,
388 crossThreadUnretained(bridgePtr), nullptr)); 388 crossThreadUnretained(bridgePtr), nullptr));
389 } 389 }
390 390
391 void postAndWaitDestroyBridgeTask(const WebTraceLocation& location, 391 void postAndWaitDestroyBridgeTask(const WebTraceLocation& location,
392 WebThread* testThread, 392 WebThread* testThread,
393 Canvas2DLayerBridgePtr* bridgePtr) { 393 Canvas2DLayerBridgePtr* bridgePtr) {
394 std::unique_ptr<WaitableEvent> bridgeDestroyedEvent = 394 std::unique_ptr<WaitableEvent> bridgeDestroyedEvent =
395 wrapUnique(new WaitableEvent()); 395 makeUnique<WaitableEvent>();
396 testThread->getWebTaskRunner()->postTask( 396 testThread->getWebTaskRunner()->postTask(
397 location, 397 location,
398 crossThreadBind(&runDestroyBridgeTask, crossThreadUnretained(bridgePtr), 398 crossThreadBind(&runDestroyBridgeTask, crossThreadUnretained(bridgePtr),
399 crossThreadUnretained(bridgeDestroyedEvent.get()))); 399 crossThreadUnretained(bridgeDestroyedEvent.get())));
400 bridgeDestroyedEvent->wait(); 400 bridgeDestroyedEvent->wait();
401 } 401 }
402 402
403 void runSetIsHiddenTask(Canvas2DLayerBridge* bridge, 403 void runSetIsHiddenTask(Canvas2DLayerBridge* bridge,
404 bool value, 404 bool value,
405 WaitableEvent* doneEvent) { 405 WaitableEvent* doneEvent) {
(...skipping 10 matching lines...) Expand all
416 testThread->getWebTaskRunner()->postTask( 416 testThread->getWebTaskRunner()->postTask(
417 location, 417 location,
418 crossThreadBind(&runSetIsHiddenTask, crossThreadUnretained(bridge), value, 418 crossThreadBind(&runSetIsHiddenTask, crossThreadUnretained(bridge), value,
419 crossThreadUnretained(doneEvent))); 419 crossThreadUnretained(doneEvent)));
420 } 420 }
421 421
422 void postAndWaitSetIsHiddenTask(const WebTraceLocation& location, 422 void postAndWaitSetIsHiddenTask(const WebTraceLocation& location,
423 WebThread* testThread, 423 WebThread* testThread,
424 Canvas2DLayerBridge* bridge, 424 Canvas2DLayerBridge* bridge,
425 bool value) { 425 bool value) {
426 std::unique_ptr<WaitableEvent> doneEvent = wrapUnique(new WaitableEvent()); 426 std::unique_ptr<WaitableEvent> doneEvent = makeUnique<WaitableEvent>();
427 postSetIsHiddenTask(location, testThread, bridge, value, doneEvent.get()); 427 postSetIsHiddenTask(location, testThread, bridge, value, doneEvent.get());
428 doneEvent->wait(); 428 doneEvent->wait();
429 } 429 }
430 430
431 class MockImageBuffer : public ImageBuffer { 431 class MockImageBuffer : public ImageBuffer {
432 public: 432 public:
433 MockImageBuffer() 433 MockImageBuffer()
434 : ImageBuffer( 434 : ImageBuffer(
435 wrapUnique(new UnacceleratedImageBufferSurface(IntSize(1, 1)))) {} 435 wrapUnique(new UnacceleratedImageBufferSurface(IntSize(1, 1)))) {}
436 436
(...skipping 18 matching lines...) Expand all
455 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl, 455 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
456 this); 456 this);
457 457
458 // Register an alternate Logger for tracking hibernation events 458 // Register an alternate Logger for tracking hibernation events
459 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger); 459 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
460 MockLogger* mockLoggerPtr = mockLogger.get(); 460 MockLogger* mockLoggerPtr = mockLogger.get();
461 bridge->setLoggerForTesting(std::move(mockLogger)); 461 bridge->setLoggerForTesting(std::move(mockLogger));
462 462
463 // Test entering hibernation 463 // Test entering hibernation
464 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 464 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
465 wrapUnique(new WaitableEvent()); 465 makeUnique<WaitableEvent>();
466 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 466 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
467 Canvas2DLayerBridge::HibernationScheduled)); 467 Canvas2DLayerBridge::HibernationScheduled));
468 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 468 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
469 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 469 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
470 &WaitableEvent::signal)); 470 &WaitableEvent::signal));
471 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 471 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
472 hibernationStartedEvent->wait(); 472 hibernationStartedEvent->wait();
473 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 473 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
474 EXPECT_FALSE(bridge->isAccelerated()); 474 EXPECT_FALSE(bridge->isAccelerated());
475 EXPECT_TRUE(bridge->isHibernating()); 475 EXPECT_TRUE(bridge->isHibernating());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl, 507 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
508 this); 508 this);
509 509
510 // Register an alternate Logger for tracking hibernation events 510 // Register an alternate Logger for tracking hibernation events
511 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger); 511 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
512 MockLogger* mockLoggerPtr = mockLogger.get(); 512 MockLogger* mockLoggerPtr = mockLogger.get();
513 bridge->setLoggerForTesting(std::move(mockLogger)); 513 bridge->setLoggerForTesting(std::move(mockLogger));
514 514
515 // Test entering hibernation 515 // Test entering hibernation
516 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 516 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
517 wrapUnique(new WaitableEvent()); 517 makeUnique<WaitableEvent>();
518 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 518 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
519 Canvas2DLayerBridge::HibernationScheduled)); 519 Canvas2DLayerBridge::HibernationScheduled));
520 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 520 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
521 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 521 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
522 &WaitableEvent::signal)); 522 &WaitableEvent::signal));
523 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 523 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
524 // Toggle visibility before the task that enters hibernation gets a 524 // Toggle visibility before the task that enters hibernation gets a
525 // chance to run. 525 // chance to run.
526 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), false); 526 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), false);
527 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 527 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber()); 570 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber());
571 bridge->setImageBuffer(&mockImageBuffer); 571 bridge->setImageBuffer(&mockImageBuffer);
572 572
573 // Register an alternate Logger for tracking hibernation events 573 // Register an alternate Logger for tracking hibernation events
574 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger); 574 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
575 MockLogger* mockLoggerPtr = mockLogger.get(); 575 MockLogger* mockLoggerPtr = mockLogger.get();
576 bridge->setLoggerForTesting(std::move(mockLogger)); 576 bridge->setLoggerForTesting(std::move(mockLogger));
577 577
578 // Test entering hibernation 578 // Test entering hibernation
579 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 579 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
580 wrapUnique(new WaitableEvent()); 580 makeUnique<WaitableEvent>();
581 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 581 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
582 Canvas2DLayerBridge::HibernationScheduled)); 582 Canvas2DLayerBridge::HibernationScheduled));
583 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 583 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
584 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 584 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
585 &WaitableEvent::signal)); 585 &WaitableEvent::signal));
586 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 586 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
587 hibernationStartedEvent->wait(); 587 hibernationStartedEvent->wait();
588 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 588 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
589 ::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer); 589 ::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer);
590 EXPECT_FALSE(bridge->isAccelerated()); 590 EXPECT_FALSE(bridge->isAccelerated());
(...skipping 22 matching lines...) Expand all
613 void runRenderingTask(Canvas2DLayerBridge* bridge, WaitableEvent* doneEvent) { 613 void runRenderingTask(Canvas2DLayerBridge* bridge, WaitableEvent* doneEvent) {
614 bridge->didDraw(FloatRect(0, 0, 1, 1)); 614 bridge->didDraw(FloatRect(0, 0, 1, 1));
615 bridge->finalizeFrame(FloatRect(0, 0, 1, 1)); 615 bridge->finalizeFrame(FloatRect(0, 0, 1, 1));
616 bridge->flush(); 616 bridge->flush();
617 doneEvent->signal(); 617 doneEvent->signal();
618 } 618 }
619 619
620 void postAndWaitRenderingTask(const WebTraceLocation& location, 620 void postAndWaitRenderingTask(const WebTraceLocation& location,
621 WebThread* testThread, 621 WebThread* testThread,
622 Canvas2DLayerBridge* bridge) { 622 Canvas2DLayerBridge* bridge) {
623 std::unique_ptr<WaitableEvent> doneEvent = wrapUnique(new WaitableEvent()); 623 std::unique_ptr<WaitableEvent> doneEvent = makeUnique<WaitableEvent>();
624 testThread->getWebTaskRunner()->postTask( 624 testThread->getWebTaskRunner()->postTask(
625 location, 625 location,
626 crossThreadBind(&runRenderingTask, crossThreadUnretained(bridge), 626 crossThreadBind(&runRenderingTask, crossThreadUnretained(bridge),
627 crossThreadUnretained(doneEvent.get()))); 627 crossThreadUnretained(doneEvent.get())));
628 doneEvent->wait(); 628 doneEvent->wait();
629 } 629 }
630 630
631 #if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU 631 #if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU
632 TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernating) 632 TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernating)
633 #else 633 #else
(...skipping 10 matching lines...) Expand all
644 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl, 644 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
645 this); 645 this);
646 646
647 // Register an alternate Logger for tracking hibernation events 647 // Register an alternate Logger for tracking hibernation events
648 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger); 648 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
649 MockLogger* mockLoggerPtr = mockLogger.get(); 649 MockLogger* mockLoggerPtr = mockLogger.get();
650 bridge->setLoggerForTesting(std::move(mockLogger)); 650 bridge->setLoggerForTesting(std::move(mockLogger));
651 651
652 // Test entering hibernation 652 // Test entering hibernation
653 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 653 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
654 wrapUnique(new WaitableEvent()); 654 makeUnique<WaitableEvent>();
655 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 655 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
656 Canvas2DLayerBridge::HibernationScheduled)); 656 Canvas2DLayerBridge::HibernationScheduled));
657 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 657 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
658 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 658 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
659 &WaitableEvent::signal)); 659 &WaitableEvent::signal));
660 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 660 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
661 hibernationStartedEvent->wait(); 661 hibernationStartedEvent->wait();
662 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 662 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
663 EXPECT_FALSE(bridge->isAccelerated()); 663 EXPECT_FALSE(bridge->isAccelerated());
664 EXPECT_TRUE(bridge->isHibernating()); 664 EXPECT_TRUE(bridge->isHibernating());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 bridge->setImageBuffer(&mockImageBuffer); 712 bridge->setImageBuffer(&mockImageBuffer);
713 bridge->disableDeferral(DisableDeferralReasonUnknown); 713 bridge->disableDeferral(DisableDeferralReasonUnknown);
714 714
715 // Register an alternate Logger for tracking hibernation events 715 // Register an alternate Logger for tracking hibernation events
716 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger); 716 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
717 MockLogger* mockLoggerPtr = mockLogger.get(); 717 MockLogger* mockLoggerPtr = mockLogger.get();
718 bridge->setLoggerForTesting(std::move(mockLogger)); 718 bridge->setLoggerForTesting(std::move(mockLogger));
719 719
720 // Test entering hibernation 720 // Test entering hibernation
721 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 721 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
722 wrapUnique(new WaitableEvent()); 722 makeUnique<WaitableEvent>();
723 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 723 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
724 Canvas2DLayerBridge::HibernationScheduled)); 724 Canvas2DLayerBridge::HibernationScheduled));
725 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 725 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
726 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 726 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
727 &WaitableEvent::signal)); 727 &WaitableEvent::signal));
728 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 728 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
729 hibernationStartedEvent->wait(); 729 hibernationStartedEvent->wait();
730 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 730 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
731 ::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer); 731 ::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer);
732 EXPECT_FALSE(bridge->isAccelerated()); 732 EXPECT_FALSE(bridge->isAccelerated());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber()); 783 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber());
784 bridge->setImageBuffer(&mockImageBuffer); 784 bridge->setImageBuffer(&mockImageBuffer);
785 785
786 // Register an alternate Logger for tracking hibernation events 786 // Register an alternate Logger for tracking hibernation events
787 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger); 787 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
788 MockLogger* mockLoggerPtr = mockLogger.get(); 788 MockLogger* mockLoggerPtr = mockLogger.get();
789 bridge->setLoggerForTesting(std::move(mockLogger)); 789 bridge->setLoggerForTesting(std::move(mockLogger));
790 790
791 // Test entering hibernation 791 // Test entering hibernation
792 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 792 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
793 wrapUnique(new WaitableEvent()); 793 makeUnique<WaitableEvent>();
794 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 794 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
795 Canvas2DLayerBridge::HibernationScheduled)); 795 Canvas2DLayerBridge::HibernationScheduled));
796 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 796 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
797 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 797 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
798 &WaitableEvent::signal)); 798 &WaitableEvent::signal));
799 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 799 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
800 hibernationStartedEvent->wait(); 800 hibernationStartedEvent->wait();
801 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 801 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
802 ::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer); 802 ::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer);
803 EXPECT_FALSE(bridge->isAccelerated()); 803 EXPECT_FALSE(bridge->isAccelerated());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl, 850 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
851 this); 851 this);
852 852
853 // Register an alternate Logger for tracking hibernation events 853 // Register an alternate Logger for tracking hibernation events
854 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger); 854 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
855 MockLogger* mockLoggerPtr = mockLogger.get(); 855 MockLogger* mockLoggerPtr = mockLogger.get();
856 bridge->setLoggerForTesting(std::move(mockLogger)); 856 bridge->setLoggerForTesting(std::move(mockLogger));
857 857
858 // Test entering hibernation 858 // Test entering hibernation
859 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 859 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
860 wrapUnique(new WaitableEvent()); 860 makeUnique<WaitableEvent>();
861 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 861 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
862 Canvas2DLayerBridge::HibernationScheduled)); 862 Canvas2DLayerBridge::HibernationScheduled));
863 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 863 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
864 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 864 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
865 &WaitableEvent::signal)); 865 &WaitableEvent::signal));
866 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 866 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
867 hibernationStartedEvent->wait(); 867 hibernationStartedEvent->wait();
868 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 868 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
869 EXPECT_FALSE(bridge->isAccelerated()); 869 EXPECT_FALSE(bridge->isAccelerated());
870 EXPECT_TRUE(bridge->isHibernating()); 870 EXPECT_TRUE(bridge->isHibernating());
(...skipping 22 matching lines...) Expand all
893 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl, 893 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
894 this); 894 this);
895 895
896 // Register an alternate Logger for tracking hibernation events 896 // Register an alternate Logger for tracking hibernation events
897 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger); 897 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
898 MockLogger* mockLoggerPtr = mockLogger.get(); 898 MockLogger* mockLoggerPtr = mockLogger.get();
899 bridge->setLoggerForTesting(std::move(mockLogger)); 899 bridge->setLoggerForTesting(std::move(mockLogger));
900 900
901 // Test entering hibernation 901 // Test entering hibernation
902 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 902 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
903 wrapUnique(new WaitableEvent()); 903 makeUnique<WaitableEvent>();
904 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 904 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
905 Canvas2DLayerBridge::HibernationScheduled)); 905 Canvas2DLayerBridge::HibernationScheduled));
906 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 906 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
907 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 907 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
908 &WaitableEvent::signal)); 908 &WaitableEvent::signal));
909 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 909 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
910 hibernationStartedEvent->wait(); 910 hibernationStartedEvent->wait();
911 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 911 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
912 EXPECT_FALSE(bridge->isAccelerated()); 912 EXPECT_FALSE(bridge->isAccelerated());
913 EXPECT_TRUE(bridge->isHibernating()); 913 EXPECT_TRUE(bridge->isHibernating());
914 EXPECT_TRUE(bridge->checkSurfaceValid()); 914 EXPECT_TRUE(bridge->checkSurfaceValid());
915 915
916 // Take a snapshot and verify that it is not accelerated due to hibernation 916 // Take a snapshot and verify that it is not accelerated due to hibernation
917 sk_sp<SkImage> image = 917 sk_sp<SkImage> image =
918 bridge->newImageSnapshot(PreferAcceleration, SnapshotReasonUnitTests); 918 bridge->newImageSnapshot(PreferAcceleration, SnapshotReasonUnitTests);
919 EXPECT_FALSE(image->isTextureBacked()); 919 EXPECT_FALSE(image->isTextureBacked());
920 image.reset(); 920 image.reset();
921 921
922 // Verify that taking a snapshot did not affect the state of bridge 922 // Verify that taking a snapshot did not affect the state of bridge
923 EXPECT_FALSE(bridge->isAccelerated()); 923 EXPECT_FALSE(bridge->isAccelerated());
924 EXPECT_TRUE(bridge->isHibernating()); 924 EXPECT_TRUE(bridge->isHibernating());
925 EXPECT_TRUE(bridge->checkSurfaceValid()); 925 EXPECT_TRUE(bridge->checkSurfaceValid());
926 926
927 // End hibernation normally 927 // End hibernation normally
928 std::unique_ptr<WaitableEvent> hibernationEndedEvent = 928 std::unique_ptr<WaitableEvent> hibernationEndedEvent =
929 wrapUnique(new WaitableEvent()); 929 makeUnique<WaitableEvent>();
930 EXPECT_CALL( 930 EXPECT_CALL(
931 *mockLoggerPtr, 931 *mockLoggerPtr,
932 reportHibernationEvent(Canvas2DLayerBridge::HibernationEndedNormally)) 932 reportHibernationEvent(Canvas2DLayerBridge::HibernationEndedNormally))
933 .WillOnce(testing::InvokeWithoutArgs(hibernationEndedEvent.get(), 933 .WillOnce(testing::InvokeWithoutArgs(hibernationEndedEvent.get(),
934 &WaitableEvent::signal)); 934 &WaitableEvent::signal));
935 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), false); 935 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), false);
936 hibernationEndedEvent->wait(); 936 hibernationEndedEvent->wait();
937 937
938 // Tear down the bridge while hibernating 938 // Tear down the bridge while hibernating
939 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); 939 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
(...skipping 15 matching lines...) Expand all
955 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl, 955 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
956 this); 956 this);
957 957
958 // Register an alternate Logger for tracking hibernation events 958 // Register an alternate Logger for tracking hibernation events
959 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger); 959 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
960 MockLogger* mockLoggerPtr = mockLogger.get(); 960 MockLogger* mockLoggerPtr = mockLogger.get();
961 bridge->setLoggerForTesting(std::move(mockLogger)); 961 bridge->setLoggerForTesting(std::move(mockLogger));
962 962
963 // Test entering hibernation 963 // Test entering hibernation
964 std::unique_ptr<WaitableEvent> hibernationScheduledEvent = 964 std::unique_ptr<WaitableEvent> hibernationScheduledEvent =
965 wrapUnique(new WaitableEvent()); 965 makeUnique<WaitableEvent>();
966 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 966 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
967 Canvas2DLayerBridge::HibernationScheduled)); 967 Canvas2DLayerBridge::HibernationScheduled));
968 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true, 968 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true,
969 hibernationScheduledEvent.get()); 969 hibernationScheduledEvent.get());
970 postDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); 970 postDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
971 // In production, we would expect a 971 // In production, we would expect a
972 // HibernationAbortedDueToDestructionWhileHibernatePending event to be 972 // HibernationAbortedDueToDestructionWhileHibernatePending event to be
973 // fired, but that signal is lost in the unit test due to no longer having 973 // fired, but that signal is lost in the unit test due to no longer having
974 // a bridge to hold the mockLogger. 974 // a bridge to hold the mockLogger.
975 hibernationScheduledEvent->wait(); 975 hibernationScheduledEvent->wait();
976 // Once we know the hibernation task is scheduled, we can schedule a fence. 976 // Once we know the hibernation task is scheduled, we can schedule a fence.
977 // Assuming tasks are guaranteed to run in the order they were 977 // Assuming tasks are guaranteed to run in the order they were
978 // submitted, this fence will guarantee the attempt to hibernate runs to 978 // submitted, this fence will guarantee the attempt to hibernate runs to
979 // completion before the thread is destroyed. 979 // completion before the thread is destroyed.
980 // This test passes by not crashing, which proves that the WeakPtr logic 980 // This test passes by not crashing, which proves that the WeakPtr logic
981 // is sound. 981 // is sound.
982 std::unique_ptr<WaitableEvent> fenceEvent = wrapUnique(new WaitableEvent()); 982 std::unique_ptr<WaitableEvent> fenceEvent = makeUnique<WaitableEvent>();
983 testThread->getWebTaskRunner()->postTask( 983 testThread->getWebTaskRunner()->postTask(
984 BLINK_FROM_HERE, 984 BLINK_FROM_HERE,
985 WTF::bind(&WaitableEvent::signal, unretained(fenceEvent.get()))); 985 WTF::bind(&WaitableEvent::signal, unretained(fenceEvent.get())));
986 fenceEvent->wait(); 986 fenceEvent->wait();
987 } 987 }
988 988
989 #if CANVAS2D_HIBERNATION_ENABLED 989 #if CANVAS2D_HIBERNATION_ENABLED
990 TEST_F(Canvas2DLayerBridgeTest, HibernationAbortedDueToPendingTeardown) 990 TEST_F(Canvas2DLayerBridgeTest, HibernationAbortedDueToPendingTeardown)
991 #else 991 #else
992 TEST_F(Canvas2DLayerBridgeTest, DISABLED_HibernationAbortedDueToPendingTeardown) 992 TEST_F(Canvas2DLayerBridgeTest, DISABLED_HibernationAbortedDueToPendingTeardown)
993 #endif 993 #endif
994 { 994 {
995 FakeGLES2Interface gl; 995 FakeGLES2Interface gl;
996 std::unique_ptr<WebThread> testThread = 996 std::unique_ptr<WebThread> testThread =
997 wrapUnique(Platform::current()->createThread("TestThread")); 997 wrapUnique(Platform::current()->createThread("TestThread"));
998 998
999 // The Canvas2DLayerBridge has to be created on the thread that will use it 999 // The Canvas2DLayerBridge has to be created on the thread that will use it
1000 // to avoid WeakPtr thread check issues. 1000 // to avoid WeakPtr thread check issues.
1001 Canvas2DLayerBridgePtr bridge; 1001 Canvas2DLayerBridgePtr bridge;
1002 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl, 1002 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
1003 this); 1003 this);
1004 1004
1005 // Register an alternate Logger for tracking hibernation events 1005 // Register an alternate Logger for tracking hibernation events
1006 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger); 1006 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
1007 MockLogger* mockLoggerPtr = mockLogger.get(); 1007 MockLogger* mockLoggerPtr = mockLogger.get();
1008 bridge->setLoggerForTesting(std::move(mockLogger)); 1008 bridge->setLoggerForTesting(std::move(mockLogger));
1009 1009
1010 // Test entering hibernation 1010 // Test entering hibernation
1011 std::unique_ptr<WaitableEvent> hibernationAbortedEvent = 1011 std::unique_ptr<WaitableEvent> hibernationAbortedEvent =
1012 wrapUnique(new WaitableEvent()); 1012 makeUnique<WaitableEvent>();
1013 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 1013 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
1014 Canvas2DLayerBridge::HibernationScheduled)); 1014 Canvas2DLayerBridge::HibernationScheduled));
1015 EXPECT_CALL( 1015 EXPECT_CALL(
1016 *mockLoggerPtr, 1016 *mockLoggerPtr,
1017 reportHibernationEvent( 1017 reportHibernationEvent(
1018 Canvas2DLayerBridge::HibernationAbortedDueToPendingDestruction)) 1018 Canvas2DLayerBridge::HibernationAbortedDueToPendingDestruction))
1019 .WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(), 1019 .WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(),
1020 &WaitableEvent::signal)); 1020 &WaitableEvent::signal));
1021 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 1021 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
1022 testThread->getWebTaskRunner()->postTask( 1022 testThread->getWebTaskRunner()->postTask(
(...skipping 24 matching lines...) Expand all
1047 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl, 1047 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
1048 this); 1048 this);
1049 1049
1050 // Register an alternate Logger for tracking hibernation events 1050 // Register an alternate Logger for tracking hibernation events
1051 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger); 1051 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
1052 MockLogger* mockLoggerPtr = mockLogger.get(); 1052 MockLogger* mockLoggerPtr = mockLogger.get();
1053 bridge->setLoggerForTesting(std::move(mockLogger)); 1053 bridge->setLoggerForTesting(std::move(mockLogger));
1054 1054
1055 // Test entering hibernation 1055 // Test entering hibernation
1056 std::unique_ptr<WaitableEvent> hibernationAbortedEvent = 1056 std::unique_ptr<WaitableEvent> hibernationAbortedEvent =
1057 wrapUnique(new WaitableEvent()); 1057 makeUnique<WaitableEvent>();
1058 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 1058 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
1059 Canvas2DLayerBridge::HibernationScheduled)); 1059 Canvas2DLayerBridge::HibernationScheduled));
1060 EXPECT_CALL(*mockLoggerPtr, 1060 EXPECT_CALL(*mockLoggerPtr,
1061 reportHibernationEvent( 1061 reportHibernationEvent(
1062 Canvas2DLayerBridge::HibernationAbortedDueToVisibilityChange)) 1062 Canvas2DLayerBridge::HibernationAbortedDueToVisibilityChange))
1063 .WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(), 1063 .WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(),
1064 &WaitableEvent::signal)); 1064 &WaitableEvent::signal));
1065 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 1065 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
1066 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), false); 1066 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), false);
1067 hibernationAbortedEvent->wait(); 1067 hibernationAbortedEvent->wait();
(...skipping 24 matching lines...) Expand all
1092 this); 1092 this);
1093 1093
1094 // Register an alternate Logger for tracking hibernation events 1094 // Register an alternate Logger for tracking hibernation events
1095 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger); 1095 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
1096 MockLogger* mockLoggerPtr = mockLogger.get(); 1096 MockLogger* mockLoggerPtr = mockLogger.get();
1097 bridge->setLoggerForTesting(std::move(mockLogger)); 1097 bridge->setLoggerForTesting(std::move(mockLogger));
1098 1098
1099 gl.setIsContextLost(true); 1099 gl.setIsContextLost(true);
1100 // Test entering hibernation 1100 // Test entering hibernation
1101 std::unique_ptr<WaitableEvent> hibernationAbortedEvent = 1101 std::unique_ptr<WaitableEvent> hibernationAbortedEvent =
1102 wrapUnique(new WaitableEvent()); 1102 makeUnique<WaitableEvent>();
1103 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 1103 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
1104 Canvas2DLayerBridge::HibernationScheduled)); 1104 Canvas2DLayerBridge::HibernationScheduled));
1105 EXPECT_CALL(*mockLoggerPtr, 1105 EXPECT_CALL(*mockLoggerPtr,
1106 reportHibernationEvent( 1106 reportHibernationEvent(
1107 Canvas2DLayerBridge::HibernationAbortedDueGpuContextLoss)) 1107 Canvas2DLayerBridge::HibernationAbortedDueGpuContextLoss))
1108 .WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(), 1108 .WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(),
1109 &WaitableEvent::signal)); 1109 &WaitableEvent::signal));
1110 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 1110 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
1111 hibernationAbortedEvent->wait(); 1111 hibernationAbortedEvent->wait();
1112 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 1112 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
(...skipping 20 matching lines...) Expand all
1133 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl, 1133 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
1134 this); 1134 this);
1135 1135
1136 // Register an alternate Logger for tracking hibernation events 1136 // Register an alternate Logger for tracking hibernation events
1137 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger); 1137 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
1138 MockLogger* mockLoggerPtr = mockLogger.get(); 1138 MockLogger* mockLoggerPtr = mockLogger.get();
1139 bridge->setLoggerForTesting(std::move(mockLogger)); 1139 bridge->setLoggerForTesting(std::move(mockLogger));
1140 1140
1141 // Test entering hibernation 1141 // Test entering hibernation
1142 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 1142 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
1143 wrapUnique(new WaitableEvent()); 1143 makeUnique<WaitableEvent>();
1144 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 1144 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
1145 Canvas2DLayerBridge::HibernationScheduled)); 1145 Canvas2DLayerBridge::HibernationScheduled));
1146 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 1146 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
1147 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 1147 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
1148 &WaitableEvent::signal)); 1148 &WaitableEvent::signal));
1149 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 1149 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
1150 hibernationStartedEvent->wait(); 1150 hibernationStartedEvent->wait();
1151 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 1151 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
1152 1152
1153 // Test prepareMailbox while hibernating 1153 // Test prepareMailbox while hibernating
(...skipping 27 matching lines...) Expand all
1181 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl, 1181 postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
1182 this); 1182 this);
1183 1183
1184 // Register an alternate Logger for tracking hibernation events 1184 // Register an alternate Logger for tracking hibernation events
1185 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger); 1185 std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
1186 MockLogger* mockLoggerPtr = mockLogger.get(); 1186 MockLogger* mockLoggerPtr = mockLogger.get();
1187 bridge->setLoggerForTesting(std::move(mockLogger)); 1187 bridge->setLoggerForTesting(std::move(mockLogger));
1188 1188
1189 // Test entering hibernation 1189 // Test entering hibernation
1190 std::unique_ptr<WaitableEvent> hibernationStartedEvent = 1190 std::unique_ptr<WaitableEvent> hibernationStartedEvent =
1191 wrapUnique(new WaitableEvent()); 1191 makeUnique<WaitableEvent>();
1192 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent( 1192 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
1193 Canvas2DLayerBridge::HibernationScheduled)); 1193 Canvas2DLayerBridge::HibernationScheduled));
1194 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 1194 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
1195 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), 1195 .WillOnce(testing::Invoke(hibernationStartedEvent.get(),
1196 &WaitableEvent::signal)); 1196 &WaitableEvent::signal));
1197 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 1197 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
1198 hibernationStartedEvent->wait(); 1198 hibernationStartedEvent->wait();
1199 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 1199 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
1200 1200
1201 // Rendering in the background -> temp switch to SW 1201 // Rendering in the background -> temp switch to SW
(...skipping 13 matching lines...) Expand all
1215 EXPECT_FALSE( 1215 EXPECT_FALSE(
1216 bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback)); 1216 bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback));
1217 EXPECT_TRUE(bridge->checkSurfaceValid()); 1217 EXPECT_TRUE(bridge->checkSurfaceValid());
1218 1218
1219 // Tear down the bridge on the thread so that 'bridge' can go out of scope 1219 // Tear down the bridge on the thread so that 'bridge' can go out of scope
1220 // without crashing due to thread checks 1220 // without crashing due to thread checks
1221 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); 1221 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
1222 } 1222 }
1223 1223
1224 } // namespace blink 1224 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698