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

Side by Side Diff: cc/resources/video_resource_updater_unittest.cc

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 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/resources/video_resource_updater.h ('k') | cc/scheduler/begin_frame_source.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/resources/video_resource_updater.h" 5 #include "cc/resources/video_resource_updater.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/memory/ptr_util.h"
10 #include "cc/resources/resource_provider.h" 11 #include "cc/resources/resource_provider.h"
11 #include "cc/test/fake_output_surface.h" 12 #include "cc/test/fake_output_surface.h"
12 #include "cc/test/fake_output_surface_client.h" 13 #include "cc/test/fake_output_surface_client.h"
13 #include "cc/test/fake_resource_provider.h" 14 #include "cc/test/fake_resource_provider.h"
14 #include "cc/test/test_shared_bitmap_manager.h" 15 #include "cc/test/test_shared_bitmap_manager.h"
15 #include "cc/test/test_web_graphics_context_3d.h" 16 #include "cc/test/test_web_graphics_context_3d.h"
16 #include "cc/trees/blocking_task_runner.h" 17 #include "cc/trees/blocking_task_runner.h"
17 #include "gpu/GLES2/gl2extchromium.h" 18 #include "gpu/GLES2/gl2extchromium.h"
18 #include "media/base/video_frame.h" 19 #include "media/base/video_frame.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 void ResetImmutableTextureCreated() { immutable_texture_created_ = false; } 64 void ResetImmutableTextureCreated() { immutable_texture_created_ = false; }
64 65
65 private: 66 private:
66 int upload_count_; 67 int upload_count_;
67 int created_texture_count_; 68 int created_texture_count_;
68 bool immutable_texture_created_; 69 bool immutable_texture_created_;
69 }; 70 };
70 71
71 class SharedBitmapManagerAllocationCounter : public TestSharedBitmapManager { 72 class SharedBitmapManagerAllocationCounter : public TestSharedBitmapManager {
72 public: 73 public:
73 scoped_ptr<SharedBitmap> AllocateSharedBitmap( 74 std::unique_ptr<SharedBitmap> AllocateSharedBitmap(
74 const gfx::Size& size) override { 75 const gfx::Size& size) override {
75 ++allocation_count_; 76 ++allocation_count_;
76 return TestSharedBitmapManager::AllocateSharedBitmap(size); 77 return TestSharedBitmapManager::AllocateSharedBitmap(size);
77 } 78 }
78 79
79 int AllocationCount() { return allocation_count_; } 80 int AllocationCount() { return allocation_count_; }
80 void ResetAllocationCount() { allocation_count_ = 0; } 81 void ResetAllocationCount() { allocation_count_ = 0; }
81 82
82 private: 83 private:
83 int allocation_count_; 84 int allocation_count_;
84 }; 85 };
85 86
86 class VideoResourceUpdaterTest : public testing::Test { 87 class VideoResourceUpdaterTest : public testing::Test {
87 protected: 88 protected:
88 VideoResourceUpdaterTest() { 89 VideoResourceUpdaterTest() {
89 scoped_ptr<WebGraphicsContext3DUploadCounter> context3d( 90 std::unique_ptr<WebGraphicsContext3DUploadCounter> context3d(
90 new WebGraphicsContext3DUploadCounter()); 91 new WebGraphicsContext3DUploadCounter());
91 92
92 context3d_ = context3d.get(); 93 context3d_ = context3d.get();
93 context3d_->set_support_texture_storage(true); 94 context3d_->set_support_texture_storage(true);
94 95
95 output_surface3d_ = FakeOutputSurface::Create3d(std::move(context3d)); 96 output_surface3d_ = FakeOutputSurface::Create3d(std::move(context3d));
96 CHECK(output_surface3d_->BindToClient(&client_)); 97 CHECK(output_surface3d_->BindToClient(&client_));
97 } 98 }
98 99
99 void SetUp() override { 100 void SetUp() override {
100 testing::Test::SetUp(); 101 testing::Test::SetUp();
101 102
102 output_surface_software_ = FakeOutputSurface::CreateSoftware( 103 output_surface_software_ = FakeOutputSurface::CreateSoftware(
103 make_scoped_ptr(new SoftwareOutputDevice)); 104 base::WrapUnique(new SoftwareOutputDevice));
104 CHECK(output_surface_software_->BindToClient(&client_)); 105 CHECK(output_surface_software_->BindToClient(&client_));
105 106
106 shared_bitmap_manager_.reset(new SharedBitmapManagerAllocationCounter()); 107 shared_bitmap_manager_.reset(new SharedBitmapManagerAllocationCounter());
107 resource_provider3d_ = FakeResourceProvider::Create( 108 resource_provider3d_ = FakeResourceProvider::Create(
108 output_surface3d_.get(), shared_bitmap_manager_.get()); 109 output_surface3d_.get(), shared_bitmap_manager_.get());
109 110
110 resource_provider_software_ = FakeResourceProvider::Create( 111 resource_provider_software_ = FakeResourceProvider::Create(
111 output_surface_software_.get(), shared_bitmap_manager_.get()); 112 output_surface_software_.get(), shared_bitmap_manager_.get());
112 } 113 }
113 114
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 size, // coded_size 237 size, // coded_size
237 gfx::Rect(size), // visible_rect 238 gfx::Rect(size), // visible_rect
238 size, // natural_size 239 size, // natural_size
239 base::TimeDelta()); // timestamp 240 base::TimeDelta()); // timestamp
240 EXPECT_TRUE(video_frame); 241 EXPECT_TRUE(video_frame);
241 return video_frame; 242 return video_frame;
242 } 243 }
243 244
244 WebGraphicsContext3DUploadCounter* context3d_; 245 WebGraphicsContext3DUploadCounter* context3d_;
245 FakeOutputSurfaceClient client_; 246 FakeOutputSurfaceClient client_;
246 scoped_ptr<FakeOutputSurface> output_surface3d_; 247 std::unique_ptr<FakeOutputSurface> output_surface3d_;
247 scoped_ptr<FakeOutputSurface> output_surface_software_; 248 std::unique_ptr<FakeOutputSurface> output_surface_software_;
248 scoped_ptr<SharedBitmapManagerAllocationCounter> shared_bitmap_manager_; 249 std::unique_ptr<SharedBitmapManagerAllocationCounter> shared_bitmap_manager_;
249 scoped_ptr<ResourceProvider> resource_provider3d_; 250 std::unique_ptr<ResourceProvider> resource_provider3d_;
250 scoped_ptr<ResourceProvider> resource_provider_software_; 251 std::unique_ptr<ResourceProvider> resource_provider_software_;
251 }; 252 };
252 253
253 TEST_F(VideoResourceUpdaterTest, SoftwareFrame) { 254 TEST_F(VideoResourceUpdaterTest, SoftwareFrame) {
254 VideoResourceUpdater updater(output_surface3d_->context_provider(), 255 VideoResourceUpdater updater(output_surface3d_->context_provider(),
255 resource_provider3d_.get()); 256 resource_provider3d_.get());
256 scoped_refptr<media::VideoFrame> video_frame = CreateTestYUVVideoFrame(); 257 scoped_refptr<media::VideoFrame> video_frame = CreateTestYUVVideoFrame();
257 258
258 VideoFrameExternalResources resources = 259 VideoFrameExternalResources resources =
259 updater.CreateExternalResourcesFromVideoFrame(video_frame); 260 updater.CreateExternalResourcesFromVideoFrame(video_frame);
260 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); 261 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 // The texture copy path requires the use of CopyTextureCHROMIUM, which 507 // The texture copy path requires the use of CopyTextureCHROMIUM, which
507 // enforces that the target texture not be immutable, as it may need 508 // enforces that the target texture not be immutable, as it may need
508 // to alter the storage of the texture. Therefore, this test asserts 509 // to alter the storage of the texture. Therefore, this test asserts
509 // that an immutable texture wasn't created by glTexStorage2DEXT, when 510 // that an immutable texture wasn't created by glTexStorage2DEXT, when
510 // that extension is supported. 511 // that extension is supported.
511 EXPECT_FALSE(context3d_->WasImmutableTextureCreated()); 512 EXPECT_FALSE(context3d_->WasImmutableTextureCreated());
512 } 513 }
513 514
514 } // namespace 515 } // namespace
515 } // namespace cc 516 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/video_resource_updater.h ('k') | cc/scheduler/begin_frame_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698