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

Side by Side Diff: cc/layers/surface_layer_unittest.cc

Issue 2193293004: cc: Make LayerTreeTests use a DelegatingRenderer and Display. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: display-layertreetest: withperftestsfix Created 4 years, 4 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/cc_tests.gyp ('k') | cc/layers/texture_layer_unittest.cc » ('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 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 scoped_refptr<Layer> blank_layer_; 167 scoped_refptr<Layer> blank_layer_;
168 SurfaceSequence satisfied_sequence_; 168 SurfaceSequence satisfied_sequence_;
169 169
170 SurfaceId required_id_; 170 SurfaceId required_id_;
171 std::set<SurfaceSequence> required_set_; 171 std::set<SurfaceSequence> required_set_;
172 }; 172 };
173 173
174 // Check that SurfaceSequence is sent through swap promise. 174 // Check that SurfaceSequence is sent through swap promise.
175 class SurfaceLayerSwapPromiseWithDraw : public SurfaceLayerSwapPromise { 175 class SurfaceLayerSwapPromiseWithDraw : public SurfaceLayerSwapPromise {
176 public: 176 public:
177 SurfaceLayerSwapPromiseWithDraw() : SurfaceLayerSwapPromise() {}
178
179 std::unique_ptr<OutputSurface> CreateOutputSurface() override {
180 auto ret = FakeOutputSurface::CreateDelegating3d();
181 output_surface_ = ret.get();
182 return std::move(ret);
183 }
184
185 void ChangeTree() override { 177 void ChangeTree() override {
186 ++commit_count_; 178 ++commit_count_;
187 switch (commit_count_) { 179 switch (commit_count_) {
188 case 1: 180 case 1:
189 // Remove SurfaceLayer from tree to cause SwapPromise to be created. 181 // Remove SurfaceLayer from tree to cause SwapPromise to be created.
190 layer_tree_host()->SetRootLayer(blank_layer_); 182 layer_tree_host()->SetRootLayer(blank_layer_);
191 break; 183 break;
192 case 2: 184 case 2:
193 break; 185 break;
194 default: 186 default:
195 NOTREACHED(); 187 NOTREACHED();
196 break; 188 break;
197 } 189 }
198 } 190 }
199 191
200 void SwapBuffersCompleteOnThread() override { 192 void DisplayReceivedCompositorFrameOnThread(
201 std::vector<uint32_t>& satisfied = 193 const CompositorFrame& frame) override {
202 output_surface_->last_sent_frame()->metadata.satisfies_sequences; 194 const std::vector<uint32_t>& satisfied = frame.metadata.satisfies_sequences;
203 EXPECT_LE(satisfied.size(), 1u); 195 EXPECT_LE(satisfied.size(), 1u);
204 if (satisfied.size() == 1) { 196 if (satisfied.size() == 1) {
205 // Eventually the one SurfaceSequence should be satisfied, but only 197 // Eventually the one SurfaceSequence should be satisfied, but only
206 // after the layer was removed from the tree, and only once. 198 // after the layer was removed from the tree, and only once.
207 EXPECT_EQ(1u, satisfied[0]); 199 EXPECT_EQ(1u, satisfied[0]);
208 EXPECT_LE(1, commit_count_); 200 EXPECT_LE(1, commit_count_);
209 EXPECT_FALSE(sequence_was_satisfied_); 201 EXPECT_FALSE(sequence_was_satisfied_);
210 sequence_was_satisfied_ = true; 202 sequence_was_satisfied_ = true;
211 EndTest(); 203 EndTest();
212 } 204 }
213 } 205 }
214 206
215 void AfterTest() override { 207 void AfterTest() override {
216 EXPECT_TRUE(required_id_ == SurfaceId(kArbitraryClientId, 1, 0)); 208 EXPECT_TRUE(required_id_ == SurfaceId(kArbitraryClientId, 1, 0));
217 EXPECT_EQ(1u, required_set_.size()); 209 EXPECT_EQ(1u, required_set_.size());
218 // Sequence should have been satisfied through Swap, not with the 210 // Sequence should have been satisfied through Swap, not with the
219 // callback. 211 // callback.
220 EXPECT_TRUE(satisfied_sequence_.is_null()); 212 EXPECT_TRUE(satisfied_sequence_.is_null());
221 } 213 }
222
223 FakeOutputSurface* output_surface_;
224 }; 214 };
225 215
226 SINGLE_AND_MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithDraw); 216 SINGLE_AND_MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithDraw);
227 217
228 // Check that SurfaceSequence is sent through swap promise and resolved when 218 // Check that SurfaceSequence is sent through swap promise and resolved when
229 // swap fails. 219 // swap fails.
230 class SurfaceLayerSwapPromiseWithoutDraw : public SurfaceLayerSwapPromise { 220 class SurfaceLayerSwapPromiseWithoutDraw : public SurfaceLayerSwapPromise {
231 public: 221 public:
232 SurfaceLayerSwapPromiseWithoutDraw() : SurfaceLayerSwapPromise() {} 222 SurfaceLayerSwapPromiseWithoutDraw() : SurfaceLayerSwapPromise() {}
233 223
(...skipping 24 matching lines...) Expand all
258 EXPECT_EQ(1u, required_set_.size()); 248 EXPECT_EQ(1u, required_set_.size());
259 // Sequence should have been satisfied with the callback. 249 // Sequence should have been satisfied with the callback.
260 EXPECT_TRUE(satisfied_sequence_ == SurfaceSequence(1u, 1u)); 250 EXPECT_TRUE(satisfied_sequence_ == SurfaceSequence(1u, 1u));
261 } 251 }
262 }; 252 };
263 253
264 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithoutDraw); 254 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithoutDraw);
265 255
266 } // namespace 256 } // namespace
267 } // namespace cc 257 } // namespace cc
OLDNEW
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/layers/texture_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698