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

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

Issue 638353002: [C++11 Allowed Features] Declares a type-safe null pointer converting from NULL to nullptr in src/… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formating. Created 6 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/texture_uploader.h" 5 #include "cc/resources/texture_uploader.h"
6 6
7 #include "cc/base/util.h" 7 #include "cc/base/util.h"
8 #include "cc/resources/prioritized_resource.h" 8 #include "cc/resources/prioritized_resource.h"
9 #include "gpu/command_buffer/client/gles2_interface_stub.h" 9 #include "gpu/command_buffer/client/gles2_interface_stub.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 case GL_LUMINANCE: 108 case GL_LUMINANCE:
109 EXPECT_EQ(static_cast<unsigned>(GL_UNSIGNED_BYTE), type); 109 EXPECT_EQ(static_cast<unsigned>(GL_UNSIGNED_BYTE), type);
110 bytes_per_pixel = 1; 110 bytes_per_pixel = 1;
111 break; 111 break;
112 case GL_LUMINANCE_ALPHA: 112 case GL_LUMINANCE_ALPHA:
113 EXPECT_EQ(static_cast<unsigned>(GL_UNSIGNED_BYTE), type); 113 EXPECT_EQ(static_cast<unsigned>(GL_UNSIGNED_BYTE), type);
114 bytes_per_pixel = 2; 114 bytes_per_pixel = 2;
115 break; 115 break;
116 } 116 }
117 117
118 // If NULL, we aren't checking texture contents. 118 // If nullptr, we aren't checking texture contents.
danakj 2014/10/10 17:28:46 just use null
119 if (pixels == NULL) 119 if (pixels == nullptr)
120 return; 120 return;
121 121
122 const uint8* bytes = static_cast<const uint8*>(pixels); 122 const uint8* bytes = static_cast<const uint8*>(pixels);
123 // We'll expect the first byte of every row to be 0x1, and the last byte to 123 // We'll expect the first byte of every row to be 0x1, and the last byte to
124 // be 0x2. 124 // be 0x2.
125 const unsigned int stride = 125 const unsigned int stride =
126 RoundUp(bytes_per_pixel * width, unpack_alignment_); 126 RoundUp(bytes_per_pixel * width, unpack_alignment_);
127 for (GLsizei row = 0; row < height; ++row) { 127 for (GLsizei row = 0; row < height; ++row) {
128 const uint8* row_bytes = 128 const uint8* row_bytes =
129 bytes + (xoffset * bytes_per_pixel + (yoffset + row) * stride); 129 bytes + (xoffset * bytes_per_pixel + (yoffset + row) * stride);
(...skipping 20 matching lines...) Expand all
150 uploader->Upload( 150 uploader->Upload(
151 data, gfx::Rect(size), gfx::Rect(size), gfx::Vector2d(), format, size); 151 data, gfx::Rect(size), gfx::Rect(size), gfx::Vector2d(), format, size);
152 } 152 }
153 153
154 TEST(TextureUploaderTest, NumBlockingUploads) { 154 TEST(TextureUploaderTest, NumBlockingUploads) {
155 TextureUploadTestContext context; 155 TextureUploadTestContext context;
156 scoped_ptr<TextureUploader> uploader = TextureUploader::Create(&context); 156 scoped_ptr<TextureUploader> uploader = TextureUploader::Create(&context);
157 157
158 context.SetResultAvailable(0); 158 context.SetResultAvailable(0);
159 EXPECT_EQ(0u, uploader->NumBlockingUploads()); 159 EXPECT_EQ(0u, uploader->NumBlockingUploads());
160 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), NULL); 160 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), nullptr);
161 EXPECT_EQ(1u, uploader->NumBlockingUploads()); 161 EXPECT_EQ(1u, uploader->NumBlockingUploads());
162 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), NULL); 162 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), nullptr);
163 EXPECT_EQ(2u, uploader->NumBlockingUploads()); 163 EXPECT_EQ(2u, uploader->NumBlockingUploads());
164 164
165 context.SetResultAvailable(1); 165 context.SetResultAvailable(1);
166 EXPECT_EQ(0u, uploader->NumBlockingUploads()); 166 EXPECT_EQ(0u, uploader->NumBlockingUploads());
167 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), NULL); 167 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), nullptr);
168 EXPECT_EQ(0u, uploader->NumBlockingUploads()); 168 EXPECT_EQ(0u, uploader->NumBlockingUploads());
169 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), NULL); 169 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), nullptr);
170 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), NULL); 170 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), nullptr);
171 EXPECT_EQ(0u, uploader->NumBlockingUploads()); 171 EXPECT_EQ(0u, uploader->NumBlockingUploads());
172 } 172 }
173 173
174 TEST(TextureUploaderTest, MarkPendingUploadsAsNonBlocking) { 174 TEST(TextureUploaderTest, MarkPendingUploadsAsNonBlocking) {
175 TextureUploadTestContext context; 175 TextureUploadTestContext context;
176 scoped_ptr<TextureUploader> uploader = TextureUploader::Create(&context); 176 scoped_ptr<TextureUploader> uploader = TextureUploader::Create(&context);
177 177
178 context.SetResultAvailable(0); 178 context.SetResultAvailable(0);
179 EXPECT_EQ(0u, uploader->NumBlockingUploads()); 179 EXPECT_EQ(0u, uploader->NumBlockingUploads());
180 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), NULL); 180 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), nullptr);
181 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), NULL); 181 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), nullptr);
182 EXPECT_EQ(2u, uploader->NumBlockingUploads()); 182 EXPECT_EQ(2u, uploader->NumBlockingUploads());
183 183
184 uploader->MarkPendingUploadsAsNonBlocking(); 184 uploader->MarkPendingUploadsAsNonBlocking();
185 EXPECT_EQ(0u, uploader->NumBlockingUploads()); 185 EXPECT_EQ(0u, uploader->NumBlockingUploads());
186 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), NULL); 186 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), nullptr);
187 EXPECT_EQ(1u, uploader->NumBlockingUploads()); 187 EXPECT_EQ(1u, uploader->NumBlockingUploads());
188 188
189 context.SetResultAvailable(1); 189 context.SetResultAvailable(1);
190 EXPECT_EQ(0u, uploader->NumBlockingUploads()); 190 EXPECT_EQ(0u, uploader->NumBlockingUploads());
191 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), NULL); 191 UploadTexture(uploader.get(), RGBA_8888, gfx::Size(), nullptr);
192 uploader->MarkPendingUploadsAsNonBlocking(); 192 uploader->MarkPendingUploadsAsNonBlocking();
193 EXPECT_EQ(0u, uploader->NumBlockingUploads()); 193 EXPECT_EQ(0u, uploader->NumBlockingUploads());
194 } 194 }
195 195
196 TEST(TextureUploaderTest, UploadContentsTest) { 196 TEST(TextureUploaderTest, UploadContentsTest) {
197 TextureUploadTestContext context; 197 TextureUploadTestContext context;
198 scoped_ptr<TextureUploader> uploader = TextureUploader::Create(&context); 198 scoped_ptr<TextureUploader> uploader = TextureUploader::Create(&context);
199 199
200 uint8 buffer[256 * 256 * 4]; 200 uint8 buffer[256 * 256 * 4];
201 201
(...skipping 29 matching lines...) Expand all
231 for (int i = 0; i < 86; ++i) { 231 for (int i = 0; i < 86; ++i) {
232 // Mark the beginning and end of each row, for the test. 232 // Mark the beginning and end of each row, for the test.
233 buffer[i * 1 * 82] = 0x1; 233 buffer[i * 1 * 82] = 0x1;
234 buffer[(i + 1) * 82 - 1] = 0x2; 234 buffer[(i + 1) * 82 - 1] = 0x2;
235 } 235 }
236 UploadTexture(uploader.get(), LUMINANCE_8, gfx::Size(82, 86), buffer); 236 UploadTexture(uploader.get(), LUMINANCE_8, gfx::Size(82, 86), buffer);
237 } 237 }
238 238
239 } // namespace 239 } // namespace
240 } // namespace cc 240 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698