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

Side by Side Diff: cc/CCTextureUpdateControllerTest.cpp

Issue 10917153: Update cc snapshot to r127918 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « cc/CCSingleThreadProxy.cpp ('k') | cc/CCThreadProxy.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
11 #include "CCTiledLayerTestCommon.h" 11 #include "CCTiledLayerTestCommon.h"
12 #include "FakeWebCompositorOutputSurface.h" 12 #include "FakeWebCompositorOutputSurface.h"
13 #include "FakeWebGraphicsContext3D.h" 13 #include "FakeWebGraphicsContext3D.h"
14 #include "WebCompositorInitializer.h"
14 #include <gtest/gtest.h> 15 #include <gtest/gtest.h>
15 #include <public/WebCompositor.h>
16 #include <public/WebThread.h> 16 #include <public/WebThread.h>
17 #include <wtf/RefPtr.h> 17 #include <wtf/RefPtr.h>
18 18
19 using namespace WebCore; 19 using namespace WebCore;
20 using namespace WebKit; 20 using namespace WebKit;
21 using namespace WebKitTests; 21 using namespace WebKitTests;
22 using testing::Test; 22 using testing::Test;
23 23
24 24
25 namespace { 25 namespace {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 class TextureForUploadTest : public LayerTextureUpdater::Texture { 68 class TextureForUploadTest : public LayerTextureUpdater::Texture {
69 public: 69 public:
70 TextureForUploadTest() : LayerTextureUpdater::Texture(adoptPtr<CCPrioritized Texture>(0)) { } 70 TextureForUploadTest() : LayerTextureUpdater::Texture(adoptPtr<CCPrioritized Texture>(0)) { }
71 virtual void updateRect(CCResourceProvider*, const IntRect& sourceRect, cons t IntSize& destOffset) { } 71 virtual void updateRect(CCResourceProvider*, const IntRect& sourceRect, cons t IntSize& destOffset) { }
72 }; 72 };
73 73
74 74
75 class CCTextureUpdateControllerTest : public Test { 75 class CCTextureUpdateControllerTest : public Test {
76 public: 76 public:
77 CCTextureUpdateControllerTest() 77 CCTextureUpdateControllerTest()
78 : m_queue(adoptPtr(new CCTextureUpdateQueue)) 78 : m_queue(adoptPtr(new CCTextureUpdateQueue))
79 , m_uploader(this) 79 , m_uploader(this)
80 , m_fullUploadCountExpected(0) 80 , m_compositorInitializer(m_thread.get())
81 , m_partialCountExpected(0) 81 , m_fullUploadCountExpected(0)
82 , m_totalUploadCountExpected(0) 82 , m_partialCountExpected(0)
83 , m_maxUploadCountPerUpdate(0) 83 , m_totalUploadCountExpected(0)
84 , m_numBeginUploads(0) 84 , m_maxUploadCountPerUpdate(0)
85 , m_numEndUploads(0) 85 , m_numBeginUploads(0)
86 , m_numConsecutiveFlushes(0) 86 , m_numEndUploads(0)
87 , m_numDanglingUploads(0) 87 , m_numConsecutiveFlushes(0)
88 , m_numTotalUploads(0) 88 , m_numDanglingUploads(0)
89 , m_numTotalFlushes(0) 89 , m_numTotalUploads(0)
90 , m_numPreviousUploads(0) 90 , m_numTotalFlushes(0)
91 , m_numPreviousFlushes(0) 91 , m_numPreviousUploads(0)
92 { } 92 , m_numPreviousFlushes(0)
93 {
94 }
93 95
94 public: 96 public:
95 void onFlush() 97 void onFlush()
96 { 98 {
97 // Check for back-to-back flushes. 99 // Check for back-to-back flushes.
98 EXPECT_EQ(0, m_numConsecutiveFlushes) << "Back-to-back flushes detected. "; 100 EXPECT_EQ(0, m_numConsecutiveFlushes) << "Back-to-back flushes detected. ";
99 101
100 // Check for premature flushes 102 // Check for premature flushes
101 if (m_numPreviousUploads != m_maxUploadCountPerUpdate) { 103 if (m_numPreviousUploads != m_maxUploadCountPerUpdate) {
102 if (m_numTotalUploads < m_fullUploadCountExpected) 104 if (m_numTotalUploads < m_fullUploadCountExpected)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 EXPECT_EQ(m_maxUploadCountPerUpdate, m_numPreviousUploads) 145 EXPECT_EQ(m_maxUploadCountPerUpdate, m_numPreviousUploads)
144 << "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.";
145 } 147 }
146 148
147 m_numEndUploads++; 149 m_numEndUploads++;
148 } 150 }
149 151
150 protected: 152 protected:
151 virtual void SetUp() 153 virtual void SetUp()
152 { 154 {
153 OwnPtr<WebThread> thread;
154 WebCompositor::initialize(thread.get());
155
156 m_context = FakeWebCompositorOutputSurface::create(adoptPtr(new WebGraph icsContext3DForUploadTest(this))); 155 m_context = FakeWebCompositorOutputSurface::create(adoptPtr(new WebGraph icsContext3DForUploadTest(this)));
157 DebugScopedSetImplThread implThread; 156 DebugScopedSetImplThread implThread;
158 m_resourceProvider = CCResourceProvider::create(m_context.get()); 157 m_resourceProvider = CCResourceProvider::create(m_context.get());
159 } 158 }
160 159
161 virtual void TearDown()
162 {
163 WebCompositor::shutdown();
164 }
165
166 void appendFullUploadsToUpdateQueue(int count) 160 void appendFullUploadsToUpdateQueue(int count)
167 { 161 {
168 m_fullUploadCountExpected += count; 162 m_fullUploadCountExpected += count;
169 m_totalUploadCountExpected += count; 163 m_totalUploadCountExpected += count;
170 164
171 const IntRect rect(0, 0, 300, 150); 165 const IntRect rect(0, 0, 300, 150);
172 const TextureUploader::Parameters upload = { &m_texture, rect, IntSize() }; 166 const TextureUploader::Parameters upload = { &m_texture, rect, IntSize() };
173 for (int i = 0; i < count; i++) 167 for (int i = 0; i < count; i++)
174 m_queue->appendFullUpload(upload); 168 m_queue->appendFullUpload(upload);
175 } 169 }
(...skipping 15 matching lines...) Expand all
191 } 185 }
192 186
193 protected: 187 protected:
194 // Classes required to interact and test the CCTextureUpdateController 188 // Classes required to interact and test the CCTextureUpdateController
195 OwnPtr<CCGraphicsContext> m_context; 189 OwnPtr<CCGraphicsContext> m_context;
196 OwnPtr<CCResourceProvider> m_resourceProvider; 190 OwnPtr<CCResourceProvider> m_resourceProvider;
197 OwnPtr<CCTextureUpdateQueue> m_queue; 191 OwnPtr<CCTextureUpdateQueue> m_queue;
198 TextureForUploadTest m_texture; 192 TextureForUploadTest m_texture;
199 FakeTextureCopier m_copier; 193 FakeTextureCopier m_copier;
200 TextureUploaderForUploadTest m_uploader; 194 TextureUploaderForUploadTest m_uploader;
195 OwnPtr<WebThread> m_thread;
196 WebCompositorInitializer m_compositorInitializer;
197
201 198
202 // Properties / expectations of this test 199 // Properties / expectations of this test
203 int m_fullUploadCountExpected; 200 int m_fullUploadCountExpected;
204 int m_partialCountExpected; 201 int m_partialCountExpected;
205 int m_totalUploadCountExpected; 202 int m_totalUploadCountExpected;
206 int m_maxUploadCountPerUpdate; 203 int m_maxUploadCountPerUpdate;
207 204
208 // Dynamic properties of this test 205 // Dynamic properties of this test
209 int m_numBeginUploads; 206 int m_numBeginUploads;
210 int m_numEndUploads; 207 int m_numEndUploads;
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 thread.runPendingTask(); 656 thread.runPendingTask();
660 } 657 }
661 } 658 }
662 659
663 EXPECT_EQ(2, m_numBeginUploads); 660 EXPECT_EQ(2, m_numBeginUploads);
664 EXPECT_EQ(2, m_numEndUploads); 661 EXPECT_EQ(2, m_numEndUploads);
665 EXPECT_EQ(2, m_numTotalUploads); 662 EXPECT_EQ(2, m_numTotalUploads);
666 } 663 }
667 664
668 } // namespace 665 } // namespace
OLDNEW
« no previous file with comments | « cc/CCSingleThreadProxy.cpp ('k') | cc/CCThreadProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698