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

Side by Side Diff: cc/output/output_surface_unittest.cc

Issue 18796008: Implement shareResources==true in TestWebGraphicsContext3D (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 5 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
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/output/output_surface.h" 5 #include "cc/output/output_surface.h"
6 6
7 #include "base/test/test_simple_task_runner.h" 7 #include "base/test/test_simple_task_runner.h"
8 #include "cc/output/managed_memory_policy.h" 8 #include "cc/output/managed_memory_policy.h"
9 #include "cc/output/output_surface_client.h" 9 #include "cc/output/output_surface_client.h"
10 #include "cc/output/software_output_device.h" 10 #include "cc/output/software_output_device.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 virtual base::TimeDelta RetroactiveBeginFramePeriod() OVERRIDE { 80 virtual base::TimeDelta RetroactiveBeginFramePeriod() OVERRIDE {
81 return retroactive_begin_frame_period_; 81 return retroactive_begin_frame_period_;
82 } 82 }
83 83
84 base::TimeDelta retroactive_begin_frame_period_; 84 base::TimeDelta retroactive_begin_frame_period_;
85 }; 85 };
86 86
87 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientSuccess) { 87 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientSuccess) {
88 scoped_ptr<TestWebGraphicsContext3D> context3d = 88 scoped_ptr<TestWebGraphicsContext3D> context3d =
89 TestWebGraphicsContext3D::Create(); 89 TestWebGraphicsContext3D::CreateShared();
90 90
91 TestOutputSurface output_surface( 91 TestOutputSurface output_surface(
92 context3d.PassAs<WebKit::WebGraphicsContext3D>()); 92 context3d.PassAs<WebKit::WebGraphicsContext3D>());
93 EXPECT_FALSE(output_surface.HasClientForTesting()); 93 EXPECT_FALSE(output_surface.HasClientForTesting());
94 94
95 FakeOutputSurfaceClient client; 95 FakeOutputSurfaceClient client;
96 EXPECT_TRUE(output_surface.BindToClient(&client)); 96 EXPECT_TRUE(output_surface.BindToClient(&client));
97 EXPECT_TRUE(output_surface.HasClientForTesting()); 97 EXPECT_TRUE(output_surface.HasClientForTesting());
98 EXPECT_FALSE(client.deferred_initialize_called()); 98 EXPECT_FALSE(client.deferred_initialize_called());
99 99
100 // Verify DidLoseOutputSurface callback is hooked up correctly. 100 // Verify DidLoseOutputSurface callback is hooked up correctly.
101 EXPECT_FALSE(client.did_lose_output_surface_called()); 101 EXPECT_FALSE(client.did_lose_output_surface_called());
102 output_surface.context3d()->loseContextCHROMIUM( 102 output_surface.context3d()->loseContextCHROMIUM(
103 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); 103 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB);
104 EXPECT_TRUE(client.did_lose_output_surface_called()); 104 EXPECT_TRUE(client.did_lose_output_surface_called());
105 } 105 }
106 106
107 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientFailure) { 107 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientFailure) {
108 scoped_ptr<TestWebGraphicsContext3D> context3d = 108 scoped_ptr<TestWebGraphicsContext3D> context3d =
109 TestWebGraphicsContext3D::Create(); 109 TestWebGraphicsContext3D::CreateShared();
110 110
111 // Lose the context so BindToClient fails. 111 // Lose the context so BindToClient fails.
112 context3d->set_times_make_current_succeeds(0); 112 context3d->set_times_make_current_succeeds(0);
113 113
114 TestOutputSurface output_surface( 114 TestOutputSurface output_surface(
115 context3d.PassAs<WebKit::WebGraphicsContext3D>()); 115 context3d.PassAs<WebKit::WebGraphicsContext3D>());
116 EXPECT_FALSE(output_surface.HasClientForTesting()); 116 EXPECT_FALSE(output_surface.HasClientForTesting());
117 117
118 FakeOutputSurfaceClient client; 118 FakeOutputSurfaceClient client;
119 EXPECT_FALSE(output_surface.BindToClient(&client)); 119 EXPECT_FALSE(output_surface.BindToClient(&client));
120 EXPECT_FALSE(output_surface.HasClientForTesting()); 120 EXPECT_FALSE(output_surface.HasClientForTesting());
121 } 121 }
122 122
123 class InitializeNewContext3D : public ::testing::Test { 123 class InitializeNewContext3D : public ::testing::Test {
124 public: 124 public:
125 InitializeNewContext3D() 125 InitializeNewContext3D()
126 : context3d_(TestWebGraphicsContext3D::Create()), 126 : context3d_(TestWebGraphicsContext3D::CreateShared()),
127 output_surface_( 127 output_surface_(
128 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)) {} 128 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)) {}
129 129
130 protected: 130 protected:
131 void BindOutputSurface() { 131 void BindOutputSurface() {
132 EXPECT_TRUE(output_surface_.BindToClient(&client_)); 132 EXPECT_TRUE(output_surface_.BindToClient(&client_));
133 EXPECT_TRUE(output_surface_.HasClientForTesting()); 133 EXPECT_TRUE(output_surface_.HasClientForTesting());
134 } 134 }
135 135
136 void InitializeNewContextExpectFail() { 136 void InitializeNewContextExpectFail() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 172
173 TEST_F(InitializeNewContext3D, ClientDeferredInitializeFails) { 173 TEST_F(InitializeNewContext3D, ClientDeferredInitializeFails) {
174 BindOutputSurface(); 174 BindOutputSurface();
175 client_.set_deferred_initialize_result(false); 175 client_.set_deferred_initialize_result(false);
176 InitializeNewContextExpectFail(); 176 InitializeNewContextExpectFail();
177 } 177 }
178 178
179 TEST(OutputSurfaceTest, BeginFrameEmulation) { 179 TEST(OutputSurfaceTest, BeginFrameEmulation) {
180 scoped_ptr<TestWebGraphicsContext3D> context3d = 180 scoped_ptr<TestWebGraphicsContext3D> context3d =
181 TestWebGraphicsContext3D::Create(); 181 TestWebGraphicsContext3D::CreateShared();
182 182
183 TestOutputSurface output_surface( 183 TestOutputSurface output_surface(
184 context3d.PassAs<WebKit::WebGraphicsContext3D>()); 184 context3d.PassAs<WebKit::WebGraphicsContext3D>());
185 EXPECT_FALSE(output_surface.HasClientForTesting()); 185 EXPECT_FALSE(output_surface.HasClientForTesting());
186 186
187 FakeOutputSurfaceClient client; 187 FakeOutputSurfaceClient client;
188 EXPECT_TRUE(output_surface.BindToClient(&client)); 188 EXPECT_TRUE(output_surface.BindToClient(&client));
189 EXPECT_TRUE(output_surface.HasClientForTesting()); 189 EXPECT_TRUE(output_surface.HasClientForTesting());
190 EXPECT_FALSE(client.deferred_initialize_called()); 190 EXPECT_FALSE(client.deferred_initialize_called());
191 191
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // Disabling SetNeedsBeginFrame should prevent further BeginFrames. 258 // Disabling SetNeedsBeginFrame should prevent further BeginFrames.
259 output_surface.SetNeedsBeginFrame(false); 259 output_surface.SetNeedsBeginFrame(false);
260 task_runner->RunPendingTasks(); 260 task_runner->RunPendingTasks();
261 EXPECT_FALSE(task_runner->HasPendingTask()); 261 EXPECT_FALSE(task_runner->HasPendingTask());
262 EXPECT_EQ(client.begin_frame_count(), 4); 262 EXPECT_EQ(client.begin_frame_count(), 4);
263 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); 263 EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
264 } 264 }
265 265
266 TEST(OutputSurfaceTest, OptimisticAndRetroactiveBeginFrames) { 266 TEST(OutputSurfaceTest, OptimisticAndRetroactiveBeginFrames) {
267 scoped_ptr<TestWebGraphicsContext3D> context3d = 267 scoped_ptr<TestWebGraphicsContext3D> context3d =
268 TestWebGraphicsContext3D::Create(); 268 TestWebGraphicsContext3D::CreateShared();
269 269
270 TestOutputSurface output_surface( 270 TestOutputSurface output_surface(
271 context3d.PassAs<WebKit::WebGraphicsContext3D>()); 271 context3d.PassAs<WebKit::WebGraphicsContext3D>());
272 EXPECT_FALSE(output_surface.HasClientForTesting()); 272 EXPECT_FALSE(output_surface.HasClientForTesting());
273 273
274 FakeOutputSurfaceClient client; 274 FakeOutputSurfaceClient client;
275 EXPECT_TRUE(output_surface.BindToClient(&client)); 275 EXPECT_TRUE(output_surface.BindToClient(&client));
276 EXPECT_TRUE(output_surface.HasClientForTesting()); 276 EXPECT_TRUE(output_surface.HasClientForTesting());
277 EXPECT_FALSE(client.deferred_initialize_called()); 277 EXPECT_FALSE(client.deferred_initialize_called());
278 278
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 EXPECT_EQ(output_surface.pending_swap_buffers(), 2); 312 EXPECT_EQ(output_surface.pending_swap_buffers(), 2);
313 output_surface.BeginFrameForTesting(); 313 output_surface.BeginFrameForTesting();
314 EXPECT_EQ(client.begin_frame_count(), 3); 314 EXPECT_EQ(client.begin_frame_count(), 3);
315 // ...and retroactively triggered by OnSwapBuffersComplete 315 // ...and retroactively triggered by OnSwapBuffersComplete
316 output_surface.OnSwapBuffersCompleteForTesting(); 316 output_surface.OnSwapBuffersCompleteForTesting();
317 EXPECT_EQ(client.begin_frame_count(), 4); 317 EXPECT_EQ(client.begin_frame_count(), 4);
318 } 318 }
319 319
320 TEST(OutputSurfaceTest, MemoryAllocation) { 320 TEST(OutputSurfaceTest, MemoryAllocation) {
321 scoped_ptr<TestWebGraphicsContext3D> scoped_context = 321 scoped_ptr<TestWebGraphicsContext3D> scoped_context =
322 TestWebGraphicsContext3D::Create(); 322 TestWebGraphicsContext3D::CreateShared();
323 TestWebGraphicsContext3D* context = scoped_context.get(); 323 TestWebGraphicsContext3D* context = scoped_context.get();
324 324
325 TestOutputSurface output_surface( 325 TestOutputSurface output_surface(
326 scoped_context.PassAs<WebKit::WebGraphicsContext3D>()); 326 scoped_context.PassAs<WebKit::WebGraphicsContext3D>());
327 327
328 FakeOutputSurfaceClient client; 328 FakeOutputSurfaceClient client;
329 EXPECT_TRUE(output_surface.BindToClient(&client)); 329 EXPECT_TRUE(output_surface.BindToClient(&client));
330 330
331 WebGraphicsMemoryAllocation allocation; 331 WebGraphicsMemoryAllocation allocation;
332 allocation.suggestHaveBackbuffer = true; 332 allocation.suggestHaveBackbuffer = true;
(...skipping 24 matching lines...) Expand all
357 WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearby; 357 WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearby;
358 context->SetMemoryAllocation(allocation); 358 context->SetMemoryAllocation(allocation);
359 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, 359 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING,
360 client.memory_policy().priority_cutoff_when_visible); 360 client.memory_policy().priority_cutoff_when_visible);
361 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE, 361 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE,
362 client.memory_policy().priority_cutoff_when_not_visible); 362 client.memory_policy().priority_cutoff_when_not_visible);
363 } 363 }
364 364
365 } // namespace 365 } // namespace
366 } // namespace cc 366 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698