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

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

Issue 20185002: ContextProvider in OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: contextprovider: don't access Context3d() in OutputSurface contructors, it's not bound yet Created 7 years, 4 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/video_resource_updater.cc ('k') | cc/test/fake_context_provider.cc » ('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/debug/test_web_graphics_context_3d.h" 8 #include "cc/debug/test_web_graphics_context_3d.h"
9 #include "cc/resources/resource_provider.h" 9 #include "cc/resources/resource_provider.h"
10 #include "cc/test/fake_output_surface.h" 10 #include "cc/test/fake_output_surface.h"
11 #include "cc/test/fake_output_surface_client.h"
11 #include "media/base/video_frame.h" 12 #include "media/base/video_frame.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace cc { 15 namespace cc {
15 namespace { 16 namespace {
16 17
17 class VideoResourceUpdaterTest : public testing::Test { 18 class VideoResourceUpdaterTest : public testing::Test {
18 protected: 19 protected:
19 VideoResourceUpdaterTest() { 20 VideoResourceUpdaterTest() {
20 scoped_ptr<TestWebGraphicsContext3D> context3d = 21 scoped_ptr<TestWebGraphicsContext3D> context3d =
21 TestWebGraphicsContext3D::Create(); 22 TestWebGraphicsContext3D::Create();
22 context3d_ = context3d.get(); 23 context3d_ = context3d.get();
23 24
24 output_surface3d_ = FakeOutputSurface::Create3d( 25 output_surface3d_ =
25 context3d.PassAs<WebKit::WebGraphicsContext3D>()); 26 FakeOutputSurface::Create3d(context3d.Pass());
27 CHECK(output_surface3d_->BindToClient(&client_));
26 resource_provider3d_ = 28 resource_provider3d_ =
27 ResourceProvider::Create(output_surface3d_.get(), 0); 29 ResourceProvider::Create(output_surface3d_.get(), 0);
28 } 30 }
29 31
30 scoped_refptr<media::VideoFrame> CreateTestYUVVideoFrame() { 32 scoped_refptr<media::VideoFrame> CreateTestYUVVideoFrame() {
31 const int kDimension = 10; 33 const int kDimension = 10;
32 gfx::Size size(kDimension, kDimension); 34 gfx::Size size(kDimension, kDimension);
33 static uint8 y_data[kDimension * kDimension] = { 0 }; 35 static uint8 y_data[kDimension * kDimension] = { 0 };
34 static uint8 u_data[kDimension * kDimension / 2] = { 0 }; 36 static uint8 u_data[kDimension * kDimension / 2] = { 0 };
35 static uint8 v_data[kDimension * kDimension / 2] = { 0 }; 37 static uint8 v_data[kDimension * kDimension / 2] = { 0 };
36 38
37 return media::VideoFrame::WrapExternalYuvData( 39 return media::VideoFrame::WrapExternalYuvData(
38 media::VideoFrame::YV16, // format 40 media::VideoFrame::YV16, // format
39 size, // coded_size 41 size, // coded_size
40 gfx::Rect(size), // visible_rect 42 gfx::Rect(size), // visible_rect
41 size, // natural_size 43 size, // natural_size
42 size.width(), // y_stride 44 size.width(), // y_stride
43 size.width() / 2, // u_stride 45 size.width() / 2, // u_stride
44 size.width() / 2, // v_stride 46 size.width() / 2, // v_stride
45 y_data, // y_data 47 y_data, // y_data
46 u_data, // u_data 48 u_data, // u_data
47 v_data, // v_data 49 v_data, // v_data
48 base::TimeDelta(), // timestamp, 50 base::TimeDelta(), // timestamp,
49 base::Closure()); // no_longer_needed_cb 51 base::Closure()); // no_longer_needed_cb
50 } 52 }
51 53
52 TestWebGraphicsContext3D* context3d_; 54 TestWebGraphicsContext3D* context3d_;
55 FakeOutputSurfaceClient client_;
53 scoped_ptr<FakeOutputSurface> output_surface3d_; 56 scoped_ptr<FakeOutputSurface> output_surface3d_;
54 scoped_ptr<ResourceProvider> resource_provider3d_; 57 scoped_ptr<ResourceProvider> resource_provider3d_;
55 }; 58 };
56 59
57 TEST_F(VideoResourceUpdaterTest, SoftwareFrame) { 60 TEST_F(VideoResourceUpdaterTest, SoftwareFrame) {
58 VideoResourceUpdater updater(resource_provider3d_.get()); 61 VideoResourceUpdater updater(output_surface3d_->context_provider().get(),
62 resource_provider3d_.get());
59 scoped_refptr<media::VideoFrame> video_frame = CreateTestYUVVideoFrame(); 63 scoped_refptr<media::VideoFrame> video_frame = CreateTestYUVVideoFrame();
60 64
61 VideoFrameExternalResources resources = 65 VideoFrameExternalResources resources =
62 updater.CreateExternalResourcesFromVideoFrame(video_frame); 66 updater.CreateExternalResourcesFromVideoFrame(video_frame);
63 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); 67 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type);
64 } 68 }
65 69
66 TEST_F(VideoResourceUpdaterTest, LostContextForSoftwareFrame) { 70 TEST_F(VideoResourceUpdaterTest, LostContextForSoftwareFrame) {
67 VideoResourceUpdater updater(resource_provider3d_.get()); 71 VideoResourceUpdater updater(output_surface3d_->context_provider().get(),
72 resource_provider3d_.get());
68 scoped_refptr<media::VideoFrame> video_frame = CreateTestYUVVideoFrame(); 73 scoped_refptr<media::VideoFrame> video_frame = CreateTestYUVVideoFrame();
69 74
70 // Fail while creating the mailbox for the second YUV plane. 75 // Fail while creating the mailbox for the second YUV plane.
71 context3d_->set_times_gen_mailbox_succeeds(1); 76 context3d_->set_times_gen_mailbox_succeeds(1);
72 77
73 VideoFrameExternalResources resources = 78 VideoFrameExternalResources resources =
74 updater.CreateExternalResourcesFromVideoFrame(video_frame); 79 updater.CreateExternalResourcesFromVideoFrame(video_frame);
75 EXPECT_EQ(VideoFrameExternalResources::NONE, resources.type); 80 EXPECT_EQ(VideoFrameExternalResources::NONE, resources.type);
76 } 81 }
77 82
78 } // namespace 83 } // namespace
79 } // namespace cc 84 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/video_resource_updater.cc ('k') | cc/test/fake_context_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698