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

Side by Side Diff: gpu/ipc/service/gpu_channel_unittest.cc

Issue 2129043003: Make dynamic mock bindings initialization consistent with other GL implementations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « gpu/command_buffer/service/gpu_service_test.cc ('k') | ui/gl/gl_context.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 (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/memory/shared_memory.h" 7 #include "base/memory/shared_memory.h"
8 #include "base/test/test_message_loop.h" 8 #include "base/test/test_message_loop.h"
9 #include "gpu/ipc/common/gpu_messages.h" 9 #include "gpu/ipc/common/gpu_messages.h"
10 #include "gpu/ipc/service/gpu_channel.h" 10 #include "gpu/ipc/service/gpu_channel.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 SetArrayArgument<1>(kFakeTextureIds, kFakeTextureIds + 1)); 111 SetArrayArgument<1>(kFakeTextureIds, kFakeTextureIds + 1));
112 EXPECT_CALL(*gl_interface_, GenTextures(2, NotNull())) 112 EXPECT_CALL(*gl_interface_, GenTextures(2, NotNull()))
113 .Times(AnyNumber()) 113 .Times(AnyNumber())
114 .WillRepeatedly( 114 .WillRepeatedly(
115 SetArrayArgument<1>(kFakeTextureIds, kFakeTextureIds + 2)); 115 SetArrayArgument<1>(kFakeTextureIds, kFakeTextureIds + 2));
116 // And errors should be squashed. 116 // And errors should be squashed.
117 EXPECT_CALL(*gl_interface_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) 117 EXPECT_CALL(*gl_interface_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
118 .Times(AnyNumber()) 118 .Times(AnyNumber())
119 .WillRepeatedly(Return(GL_FRAMEBUFFER_COMPLETE)); 119 .WillRepeatedly(Return(GL_FRAMEBUFFER_COMPLETE));
120 120
121 // Dynamic bindings must be set up for the GLES2DecoderImpl, which requires
122 // a GLContext. Use a GLContextStub which does nothing but call through to
123 // our |gl_interface| above.
124 stub_context_ = new gl::GLContextStub;
125 stub_surface_ = new gl::GLSurfaceStub;
126 stub_context_->MakeCurrent(stub_surface_.get());
127 gl::GLSurfaceTestSupport::InitializeDynamicMockBindings(
128 stub_context_.get());
129
130 GpuChannelTestCommon::SetUp(); 121 GpuChannelTestCommon::SetUp();
131 } 122 }
132 123
133 void TearDown() override { 124 void TearDown() override {
134 GpuChannelTestCommon::TearDown(); 125 GpuChannelTestCommon::TearDown();
135 126
136 stub_context_ = nullptr;
137 stub_surface_ = nullptr;
138 gl::MockGLInterface::SetGLInterface(nullptr); 127 gl::MockGLInterface::SetGLInterface(nullptr);
139 gl::init::ClearGLBindings(); 128 gl::init::ClearGLBindings();
140 gl_interface_ = nullptr; 129 gl_interface_ = nullptr;
141 } 130 }
142 131
143 GpuChannel* CreateChannel(int32_t client_id, 132 GpuChannel* CreateChannel(int32_t client_id,
144 bool allow_view_command_buffers, 133 bool allow_view_command_buffers,
145 bool allow_real_time_streams) { 134 bool allow_real_time_streams) {
146 DCHECK(channel_manager()); 135 DCHECK(channel_manager());
147 uint64_t kClientTracingId = 1; 136 uint64_t kClientTracingId = 1;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 shared_memory.CreateAnonymous(10); 174 shared_memory.CreateAnonymous(10);
186 base::SharedMemoryHandle shmem_handle; 175 base::SharedMemoryHandle shmem_handle;
187 shared_memory.ShareToProcess(base::GetCurrentProcessHandle(), 176 shared_memory.ShareToProcess(base::GetCurrentProcessHandle(),
188 &shmem_handle); 177 &shmem_handle);
189 return shmem_handle; 178 return shmem_handle;
190 } 179 }
191 180
192 private: 181 private:
193 base::TestMessageLoop message_loop_; 182 base::TestMessageLoop message_loop_;
194 std::unique_ptr<gl::MockGLInterface> gl_interface_; 183 std::unique_ptr<gl::MockGLInterface> gl_interface_;
195 scoped_refptr<gl::GLContextStub> stub_context_;
196 scoped_refptr<gl::GLSurfaceStub> stub_surface_;
197 }; 184 };
198 185
199 #if defined(OS_WIN) 186 #if defined(OS_WIN)
200 const SurfaceHandle kFakeSurfaceHandle = reinterpret_cast<SurfaceHandle>(1); 187 const SurfaceHandle kFakeSurfaceHandle = reinterpret_cast<SurfaceHandle>(1);
201 #else 188 #else
202 const SurfaceHandle kFakeSurfaceHandle = 1; 189 const SurfaceHandle kFakeSurfaceHandle = 1;
203 #endif 190 #endif
204 191
205 TEST_F(GpuChannelTest, CreateViewCommandBufferAllowed) { 192 TEST_F(GpuChannelTest, CreateViewCommandBufferAllowed) {
206 int32_t kClientId = 1; 193 int32_t kClientId = 1;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 EXPECT_TRUE(channel->LookupCommandBuffer(kSharedRouteId)); 493 EXPECT_TRUE(channel->LookupCommandBuffer(kSharedRouteId));
507 494
508 // Destroy the command buffers we initialized before destoying GL. 495 // Destroy the command buffers we initialized before destoying GL.
509 HandleMessage(channel, 496 HandleMessage(channel,
510 new GpuChannelMsg_DestroyCommandBuffer(kFriendlyRouteId)); 497 new GpuChannelMsg_DestroyCommandBuffer(kFriendlyRouteId));
511 HandleMessage(channel, 498 HandleMessage(channel,
512 new GpuChannelMsg_DestroyCommandBuffer(kSharedRouteId)); 499 new GpuChannelMsg_DestroyCommandBuffer(kSharedRouteId));
513 } 500 }
514 501
515 } // namespace gpu 502 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gpu_service_test.cc ('k') | ui/gl/gl_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698