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

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

Issue 202763002: Switch to use SharedBitmapManager all the time in cc_unittests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/tile_manager_unittest.cc ('k') | cc/test/fake_layer_tree_host.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 "base/memory/shared_memory.h" 7 #include "base/memory/shared_memory.h"
8 #include "cc/resources/resource_provider.h" 8 #include "cc/resources/resource_provider.h"
9 #include "cc/test/fake_output_surface.h" 9 #include "cc/test/fake_output_surface.h"
10 #include "cc/test/fake_output_surface_client.h" 10 #include "cc/test/fake_output_surface_client.h"
11 #include "cc/test/test_shared_bitmap_manager.h"
11 #include "cc/test/test_web_graphics_context_3d.h" 12 #include "cc/test/test_web_graphics_context_3d.h"
12 #include "media/base/video_frame.h" 13 #include "media/base/video_frame.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace cc { 16 namespace cc {
16 namespace { 17 namespace {
17 18
18 class VideoResourceUpdaterTest : public testing::Test { 19 class VideoResourceUpdaterTest : public testing::Test {
19 protected: 20 protected:
20 VideoResourceUpdaterTest() { 21 VideoResourceUpdaterTest() {
21 scoped_ptr<TestWebGraphicsContext3D> context3d = 22 scoped_ptr<TestWebGraphicsContext3D> context3d =
22 TestWebGraphicsContext3D::Create(); 23 TestWebGraphicsContext3D::Create();
23 context3d_ = context3d.get(); 24 context3d_ = context3d.get();
24 25
25 output_surface3d_ = 26 output_surface3d_ =
26 FakeOutputSurface::Create3d(context3d.Pass()); 27 FakeOutputSurface::Create3d(context3d.Pass());
27 CHECK(output_surface3d_->BindToClient(&client_)); 28 CHECK(output_surface3d_->BindToClient(&client_));
28 resource_provider3d_ = 29 shared_bitmap_manager_.reset(new TestSharedBitmapManager());
29 ResourceProvider::Create(output_surface3d_.get(), NULL, 0, false, 1); 30 resource_provider3d_ = ResourceProvider::Create(
31 output_surface3d_.get(), shared_bitmap_manager_.get(), 0, false, 1);
30 } 32 }
31 33
32 scoped_refptr<media::VideoFrame> CreateTestYUVVideoFrame() { 34 scoped_refptr<media::VideoFrame> CreateTestYUVVideoFrame() {
33 const int kDimension = 10; 35 const int kDimension = 10;
34 gfx::Size size(kDimension, kDimension); 36 gfx::Size size(kDimension, kDimension);
35 static uint8 y_data[kDimension * kDimension] = { 0 }; 37 static uint8 y_data[kDimension * kDimension] = { 0 };
36 static uint8 u_data[kDimension * kDimension / 2] = { 0 }; 38 static uint8 u_data[kDimension * kDimension / 2] = { 0 };
37 static uint8 v_data[kDimension * kDimension / 2] = { 0 }; 39 static uint8 v_data[kDimension * kDimension / 2] = { 0 };
38 40
39 return media::VideoFrame::WrapExternalYuvData( 41 return media::VideoFrame::WrapExternalYuvData(
40 media::VideoFrame::YV16, // format 42 media::VideoFrame::YV16, // format
41 size, // coded_size 43 size, // coded_size
42 gfx::Rect(size), // visible_rect 44 gfx::Rect(size), // visible_rect
43 size, // natural_size 45 size, // natural_size
44 size.width(), // y_stride 46 size.width(), // y_stride
45 size.width() / 2, // u_stride 47 size.width() / 2, // u_stride
46 size.width() / 2, // v_stride 48 size.width() / 2, // v_stride
47 y_data, // y_data 49 y_data, // y_data
48 u_data, // u_data 50 u_data, // u_data
49 v_data, // v_data 51 v_data, // v_data
50 base::TimeDelta(), // timestamp, 52 base::TimeDelta(), // timestamp,
51 base::Closure()); // no_longer_needed_cb 53 base::Closure()); // no_longer_needed_cb
52 } 54 }
53 55
54 TestWebGraphicsContext3D* context3d_; 56 TestWebGraphicsContext3D* context3d_;
55 FakeOutputSurfaceClient client_; 57 FakeOutputSurfaceClient client_;
56 scoped_ptr<FakeOutputSurface> output_surface3d_; 58 scoped_ptr<FakeOutputSurface> output_surface3d_;
59 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_;
57 scoped_ptr<ResourceProvider> resource_provider3d_; 60 scoped_ptr<ResourceProvider> resource_provider3d_;
58 }; 61 };
59 62
60 TEST_F(VideoResourceUpdaterTest, SoftwareFrame) { 63 TEST_F(VideoResourceUpdaterTest, SoftwareFrame) {
61 VideoResourceUpdater updater(output_surface3d_->context_provider().get(), 64 VideoResourceUpdater updater(output_surface3d_->context_provider().get(),
62 resource_provider3d_.get()); 65 resource_provider3d_.get());
63 scoped_refptr<media::VideoFrame> video_frame = CreateTestYUVVideoFrame(); 66 scoped_refptr<media::VideoFrame> video_frame = CreateTestYUVVideoFrame();
64 67
65 VideoFrameExternalResources resources = 68 VideoFrameExternalResources resources =
66 updater.CreateExternalResourcesFromVideoFrame(video_frame); 69 updater.CreateExternalResourcesFromVideoFrame(video_frame);
67 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); 70 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type);
68 } 71 }
69 72
70 } // namespace 73 } // namespace
71 } // namespace cc 74 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_manager_unittest.cc ('k') | cc/test/fake_layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698