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

Side by Side Diff: cc/surfaces/surface_factory_unittest.cc

Issue 1673783004: Hook up BeginFrameSource to SurfaceFactoryClient via SurfaceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Register id namespace on Android Created 4 years, 9 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
« no previous file with comments | « cc/surfaces/surface_factory_client.h ('k') | cc/surfaces/surface_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/surfaces/surface_factory.h" 5 #include "cc/surfaces/surface_factory.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 18 matching lines...) Expand all
29 class TestSurfaceFactoryClient : public SurfaceFactoryClient { 29 class TestSurfaceFactoryClient : public SurfaceFactoryClient {
30 public: 30 public:
31 TestSurfaceFactoryClient() : begin_frame_source_(nullptr) {} 31 TestSurfaceFactoryClient() : begin_frame_source_(nullptr) {}
32 ~TestSurfaceFactoryClient() override {} 32 ~TestSurfaceFactoryClient() override {}
33 33
34 void ReturnResources(const ReturnedResourceArray& resources) override { 34 void ReturnResources(const ReturnedResourceArray& resources) override {
35 returned_resources_.insert( 35 returned_resources_.insert(
36 returned_resources_.end(), resources.begin(), resources.end()); 36 returned_resources_.end(), resources.begin(), resources.end());
37 } 37 }
38 38
39 void SetBeginFrameSource(SurfaceId surface_id, 39 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {
40 BeginFrameSource* begin_frame_source) override {
41 begin_frame_source_ = begin_frame_source; 40 begin_frame_source_ = begin_frame_source;
42 } 41 }
43 42
44 const ReturnedResourceArray& returned_resources() const { 43 const ReturnedResourceArray& returned_resources() const {
45 return returned_resources_; 44 return returned_resources_;
46 } 45 }
47 46
48 void clear_returned_resources() { returned_resources_.clear(); } 47 void clear_returned_resources() { returned_resources_.clear(); }
49 48
50 BeginFrameSource* begin_frame_source() const { return begin_frame_source_; } 49 BeginFrameSource* begin_frame_source() const { return begin_frame_source_; }
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 EXPECT_FALSE(called2); 586 EXPECT_FALSE(called2);
588 EXPECT_FALSE(called3); 587 EXPECT_FALSE(called3);
589 588
590 factory_->Destroy(surface_id_); 589 factory_->Destroy(surface_id_);
591 surface_id_ = SurfaceId(); 590 surface_id_ = SurfaceId();
592 EXPECT_TRUE(called1); 591 EXPECT_TRUE(called1);
593 EXPECT_TRUE(called2); 592 EXPECT_TRUE(called2);
594 EXPECT_TRUE(called3); 593 EXPECT_TRUE(called3);
595 } 594 }
596 595
597 // Verifies BFS is forwarded to the client.
598 TEST_F(SurfaceFactoryTest, SetBeginFrameSource) {
599 FakeBeginFrameSource bfs1;
600 FakeBeginFrameSource bfs2;
601 EXPECT_EQ(nullptr, client_.begin_frame_source());
602 factory_->SetBeginFrameSource(surface_id_, &bfs1);
603 EXPECT_EQ(&bfs1, client_.begin_frame_source());
604 factory_->SetBeginFrameSource(surface_id_, &bfs2);
605 EXPECT_EQ(&bfs2, client_.begin_frame_source());
606 factory_->SetBeginFrameSource(surface_id_, nullptr);
607 EXPECT_EQ(nullptr, client_.begin_frame_source());
608 }
609
610 TEST_F(SurfaceFactoryTest, BeginFrameSourceRemovedOnFactoryDestruction) {
611 FakeBeginFrameSource bfs;
612 factory_->SetBeginFrameSource(surface_id_, &bfs);
613 EXPECT_EQ(&bfs, client_.begin_frame_source());
614
615 // Prevent the Surface from being destroyed when we destroy the factory.
616 manager_.RegisterSurfaceIdNamespace(0);
617 manager_.GetSurfaceForId(surface_id_)
618 ->AddDestructionDependency(SurfaceSequence(0, 4));
619
620 surface_id_ = SurfaceId();
621 factory_->DestroyAll();
622
623 EXPECT_EQ(&bfs, client_.begin_frame_source());
624 factory_.reset();
625 EXPECT_EQ(nullptr, client_.begin_frame_source());
626 }
627
628 } // namespace 596 } // namespace
629 } // namespace cc 597 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory_client.h ('k') | cc/surfaces/surface_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698