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

Side by Side Diff: cc/CCTextureUpdateControllerTest.cpp

Issue 10916292: Adaptively throttle texture uploads (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix platform specific compile errors. Created 8 years, 3 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 | « cc/CCTextureUpdateController.cpp ('k') | cc/TextureUploader.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "config.h" 5 #include "config.h"
6 6
7 #include "CCTextureUpdateController.h" 7 #include "CCTextureUpdateController.h"
8 8
9 #include "CCSchedulerTestCommon.h" 9 #include "CCSchedulerTestCommon.h"
10 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread 10 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 109
110 m_numDanglingUploads = 0; 110 m_numDanglingUploads = 0;
111 m_numConsecutiveFlushes++; 111 m_numConsecutiveFlushes++;
112 m_numTotalFlushes++; 112 m_numTotalFlushes++;
113 m_numPreviousFlushes++; 113 m_numPreviousFlushes++;
114 } 114 }
115 115
116 void onBeginUploads() 116 void onBeginUploads()
117 { 117 {
118 EXPECT_EQ(0, m_numDanglingUploads) << "Last upload wasn't followed by a flush.";
119
118 m_numPreviousFlushes = 0; 120 m_numPreviousFlushes = 0;
119 m_numPreviousUploads = 0; 121 m_numPreviousUploads = 0;
120 m_numBeginUploads++; 122 m_numBeginUploads++;
121 } 123 }
122 124
123 void onUpload() 125 void onUpload()
124 { 126 {
125 // Check for too many consecutive uploads 127 // Check for too many consecutive uploads
126 if (m_numTotalUploads < m_fullUploadCountExpected) 128 if (m_numTotalUploads < m_fullUploadCountExpected)
127 EXPECT_LT(m_numDanglingUploads, kFlushPeriodFull) << "Too many conse cutive full uploads detected."; 129 EXPECT_LT(m_numDanglingUploads, kFlushPeriodFull) << "Too many conse cutive full uploads detected.";
128 else 130 else
129 EXPECT_LT(m_numDanglingUploads, kFlushPeriodPartial) << "Too many co nsecutive partial uploads detected."; 131 EXPECT_LT(m_numDanglingUploads, kFlushPeriodPartial) << "Too many co nsecutive partial uploads detected.";
130 132
131 m_numConsecutiveFlushes = 0; 133 m_numConsecutiveFlushes = 0;
132 m_numDanglingUploads++; 134 m_numDanglingUploads++;
133 m_numTotalUploads++; 135 m_numTotalUploads++;
134 m_numPreviousUploads++; 136 m_numPreviousUploads++;
135 } 137 }
136 138
137 void onEndUploads() 139 void onEndUploads()
138 { 140 {
139 EXPECT_EQ(0, m_numDanglingUploads) << "Last upload wasn't followed by a flush.";
140
141 // Note: The m_numTotalUploads != m_fullUploadCountExpected comparison 141 // Note: The m_numTotalUploads != m_fullUploadCountExpected comparison
142 // allows for the quota not to be hit in the case where we are trasition ing 142 // allows for the quota not to be hit in the case where we are trasition ing
143 // from full uploads to partial uploads. 143 // from full uploads to partial uploads.
144 if (m_numTotalUploads != m_totalUploadCountExpected && m_numTotalUploads != m_fullUploadCountExpected) { 144 if (m_numTotalUploads != m_totalUploadCountExpected && m_numTotalUploads != m_fullUploadCountExpected) {
145 EXPECT_EQ(m_maxUploadCountPerUpdate, m_numPreviousUploads) 145 EXPECT_EQ(m_maxUploadCountPerUpdate, m_numPreviousUploads)
146 << "endUpload() was called when there are textures to upload, bu t the upload quota hasn't been filled."; 146 << "endUpload() was called when there are textures to upload, bu t the upload quota hasn't been filled.";
147 } 147 }
148 148
149 m_numEndUploads++; 149 m_numEndUploads++;
150 } 150 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // ONE UPLOAD TESTS 254 // ONE UPLOAD TESTS
255 TEST_F(CCTextureUpdateControllerTest, OneFullUpload) 255 TEST_F(CCTextureUpdateControllerTest, OneFullUpload)
256 { 256 {
257 appendFullUploadsToUpdateQueue(1); 257 appendFullUploadsToUpdateQueue(1);
258 appendPartialUploadsToUpdateQueue(0); 258 appendPartialUploadsToUpdateQueue(0);
259 DebugScopedSetImplThread implThread; 259 DebugScopedSetImplThread implThread;
260 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_uploa der, m_queue.get()); 260 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_uploa der, m_queue.get());
261 261
262 EXPECT_EQ(1, m_numPreviousFlushes); 262 EXPECT_EQ(1, m_numPreviousFlushes);
263 EXPECT_EQ(1, m_numPreviousUploads); 263 EXPECT_EQ(1, m_numPreviousUploads);
264 EXPECT_EQ(0, m_numDanglingUploads) << "Last upload wasn't followed by a flus h.";
264 } 265 }
265 266
266 TEST_F(CCTextureUpdateControllerTest, OnePartialUpload) 267 TEST_F(CCTextureUpdateControllerTest, OnePartialUpload)
267 { 268 {
268 appendFullUploadsToUpdateQueue(0); 269 appendFullUploadsToUpdateQueue(0);
269 appendPartialUploadsToUpdateQueue(1); 270 appendPartialUploadsToUpdateQueue(1);
270 DebugScopedSetImplThread implThread; 271 DebugScopedSetImplThread implThread;
271 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_uploa der, m_queue.get()); 272 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_uploa der, m_queue.get());
272 273
273 EXPECT_EQ(1, m_numPreviousFlushes); 274 EXPECT_EQ(1, m_numPreviousFlushes);
274 EXPECT_EQ(1, m_numPreviousUploads); 275 EXPECT_EQ(1, m_numPreviousUploads);
276 EXPECT_EQ(0, m_numDanglingUploads) << "Last upload wasn't followed by a flus h.";
275 } 277 }
276 278
277 TEST_F(CCTextureUpdateControllerTest, OneFullOnePartialUpload) 279 TEST_F(CCTextureUpdateControllerTest, OneFullOnePartialUpload)
278 { 280 {
279 appendFullUploadsToUpdateQueue(1); 281 appendFullUploadsToUpdateQueue(1);
280 appendPartialUploadsToUpdateQueue(1); 282 appendPartialUploadsToUpdateQueue(1);
281 DebugScopedSetImplThread implThread; 283 DebugScopedSetImplThread implThread;
282 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_uploa der, m_queue.get()); 284 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_uploa der, m_queue.get());
283 285
284 EXPECT_EQ(1, m_numPreviousFlushes); 286 EXPECT_EQ(1, m_numPreviousFlushes);
285 EXPECT_EQ(2, m_numPreviousUploads); 287 EXPECT_EQ(2, m_numPreviousUploads);
288 EXPECT_EQ(0, m_numDanglingUploads) << "Last upload wasn't followed by a flus h.";
286 } 289 }
287 290
288 291
289 // This class of tests upload a number of textures that is a multiple of the flu sh period. 292 // This class of tests upload a number of textures that is a multiple of the flu sh period.
290 const int fullUploadFlushMultipler = 7; 293 const int fullUploadFlushMultipler = 7;
291 const int fullCount = fullUploadFlushMultipler * kFlushPeriodFull; 294 const int fullCount = fullUploadFlushMultipler * kFlushPeriodFull;
292 295
293 const int partialUploadFlushMultipler = 11; 296 const int partialUploadFlushMultipler = 11;
294 const int partialCount = partialUploadFlushMultipler * kFlushPeriodPartial; 297 const int partialCount = partialUploadFlushMultipler * kFlushPeriodPartial;
295 298
296 TEST_F(CCTextureUpdateControllerTest, ManyFullUploads) 299 TEST_F(CCTextureUpdateControllerTest, ManyFullUploads)
297 { 300 {
298 appendFullUploadsToUpdateQueue(fullCount); 301 appendFullUploadsToUpdateQueue(fullCount);
299 appendPartialUploadsToUpdateQueue(0); 302 appendPartialUploadsToUpdateQueue(0);
300 DebugScopedSetImplThread implThread; 303 DebugScopedSetImplThread implThread;
301 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_uploa der, m_queue.get()); 304 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_uploa der, m_queue.get());
302 305
303 EXPECT_EQ(fullUploadFlushMultipler, m_numPreviousFlushes); 306 EXPECT_EQ(fullUploadFlushMultipler, m_numPreviousFlushes);
304 EXPECT_EQ(fullCount, m_numPreviousUploads); 307 EXPECT_EQ(fullCount, m_numPreviousUploads);
308 EXPECT_EQ(0, m_numDanglingUploads) << "Last upload wasn't followed by a flus h.";
305 } 309 }
306 310
307 TEST_F(CCTextureUpdateControllerTest, ManyPartialUploads) 311 TEST_F(CCTextureUpdateControllerTest, ManyPartialUploads)
308 { 312 {
309 appendFullUploadsToUpdateQueue(0); 313 appendFullUploadsToUpdateQueue(0);
310 appendPartialUploadsToUpdateQueue(partialCount); 314 appendPartialUploadsToUpdateQueue(partialCount);
311 DebugScopedSetImplThread implThread; 315 DebugScopedSetImplThread implThread;
312 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_uploa der, m_queue.get()); 316 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_uploa der, m_queue.get());
313 317
314 EXPECT_EQ(partialUploadFlushMultipler, m_numPreviousFlushes); 318 EXPECT_EQ(partialUploadFlushMultipler, m_numPreviousFlushes);
315 EXPECT_EQ(partialCount, m_numPreviousUploads); 319 EXPECT_EQ(partialCount, m_numPreviousUploads);
320 EXPECT_EQ(0, m_numDanglingUploads) << "Last upload wasn't followed by a flus h.";
316 } 321 }
317 322
318 TEST_F(CCTextureUpdateControllerTest, ManyFullManyPartialUploads) 323 TEST_F(CCTextureUpdateControllerTest, ManyFullManyPartialUploads)
319 { 324 {
320 appendFullUploadsToUpdateQueue(fullCount); 325 appendFullUploadsToUpdateQueue(fullCount);
321 appendPartialUploadsToUpdateQueue(partialCount); 326 appendPartialUploadsToUpdateQueue(partialCount);
322 DebugScopedSetImplThread implThread; 327 DebugScopedSetImplThread implThread;
323 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_uploa der, m_queue.get()); 328 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_uploa der, m_queue.get());
324 329
325 EXPECT_EQ(fullUploadFlushMultipler + partialUploadFlushMultipler, m_numPrevi ousFlushes); 330 EXPECT_EQ(fullUploadFlushMultipler + partialUploadFlushMultipler, m_numPrevi ousFlushes);
326 EXPECT_EQ(fullCount + partialCount, m_numPreviousUploads); 331 EXPECT_EQ(fullCount + partialCount, m_numPreviousUploads);
332 EXPECT_EQ(0, m_numDanglingUploads) << "Last upload wasn't followed by a flus h.";
327 } 333 }
328 334
329 class FakeCCTextureUpdateControllerClient : public cc::CCTextureUpdateController Client { 335 class FakeCCTextureUpdateControllerClient : public cc::CCTextureUpdateController Client {
330 public: 336 public:
331 FakeCCTextureUpdateControllerClient() { reset(); } 337 FakeCCTextureUpdateControllerClient() { reset(); }
332 void reset() { m_readyToFinalizeCalled = false; } 338 void reset() { m_readyToFinalizeCalled = false; }
333 bool readyToFinalizeCalled() const { return m_readyToFinalizeCalled; } 339 bool readyToFinalizeCalled() const { return m_readyToFinalizeCalled; }
334 340
335 virtual void readyToFinalizeTextureUpdates() OVERRIDE { m_readyToFinalizeCal led = true; } 341 virtual void readyToFinalizeTextureUpdates() OVERRIDE { m_readyToFinalizeCal led = true; }
336 342
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 } 490 }
485 491
486 EXPECT_FALSE(thread.hasPendingTask()); 492 EXPECT_FALSE(thread.hasPendingTask());
487 EXPECT_TRUE(client.readyToFinalizeCalled()); 493 EXPECT_TRUE(client.readyToFinalizeCalled());
488 EXPECT_EQ(2, m_numBeginUploads); 494 EXPECT_EQ(2, m_numBeginUploads);
489 EXPECT_EQ(2, m_numEndUploads); 495 EXPECT_EQ(2, m_numEndUploads);
490 EXPECT_EQ(2, m_numTotalUploads); 496 EXPECT_EQ(2, m_numTotalUploads);
491 } 497 }
492 498
493 } // namespace 499 } // namespace
OLDNEW
« no previous file with comments | « cc/CCTextureUpdateController.cpp ('k') | cc/TextureUploader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698