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

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

Issue 2140383005: cc: Decouple LayerTreeTests from FakeOutputSurface expectations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@novirtualswapbuffers
Patch Set: layertreetest-outputsurface: more-more-more-android 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 | « no previous file | cc/test/layer_tree_test.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 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 SurfaceId required_id_; 175 SurfaceId required_id_;
176 std::set<SurfaceSequence> required_set_; 176 std::set<SurfaceSequence> required_set_;
177 }; 177 };
178 178
179 // Check that SurfaceSequence is sent through swap promise. 179 // Check that SurfaceSequence is sent through swap promise.
180 class SurfaceLayerSwapPromiseWithDraw : public SurfaceLayerSwapPromise { 180 class SurfaceLayerSwapPromiseWithDraw : public SurfaceLayerSwapPromise {
181 public: 181 public:
182 SurfaceLayerSwapPromiseWithDraw() : SurfaceLayerSwapPromise() {} 182 SurfaceLayerSwapPromiseWithDraw() : SurfaceLayerSwapPromise() {}
183 183
184 std::unique_ptr<OutputSurface> CreateOutputSurface() override {
185 auto ret = delegating_renderer() ? FakeOutputSurface::CreateDelegating3d()
186 : FakeOutputSurface::Create3d();
187 output_surface_ = ret.get();
188 return std::move(ret);
189 }
190
184 void ChangeTree() override { 191 void ChangeTree() override {
185 ++commit_count_; 192 ++commit_count_;
186 switch (commit_count_) { 193 switch (commit_count_) {
187 case 1: 194 case 1:
188 // Remove SurfaceLayer from tree to cause SwapPromise to be created. 195 // Remove SurfaceLayer from tree to cause SwapPromise to be created.
189 layer_tree_host()->SetRootLayer(blank_layer_); 196 layer_tree_host()->SetRootLayer(blank_layer_);
190 break; 197 break;
191 case 2: 198 case 2:
192 break; 199 break;
193 default: 200 default:
194 NOTREACHED(); 201 NOTREACHED();
195 break; 202 break;
196 } 203 }
197 } 204 }
198 205
199 void SwapBuffersCompleteOnThread() override { 206 void SwapBuffersCompleteOnThread() override {
200 std::vector<uint32_t>& satisfied = 207 std::vector<uint32_t>& satisfied =
201 output_surface()->last_sent_frame()->metadata.satisfies_sequences; 208 output_surface_->last_sent_frame()->metadata.satisfies_sequences;
202 EXPECT_LE(satisfied.size(), 1u); 209 EXPECT_LE(satisfied.size(), 1u);
203 if (satisfied.size() == 1) { 210 if (satisfied.size() == 1) {
204 // Eventually the one SurfaceSequence should be satisfied, but only 211 // Eventually the one SurfaceSequence should be satisfied, but only
205 // after the layer was removed from the tree, and only once. 212 // after the layer was removed from the tree, and only once.
206 EXPECT_EQ(1u, satisfied[0]); 213 EXPECT_EQ(1u, satisfied[0]);
207 EXPECT_LE(1, commit_count_); 214 EXPECT_LE(1, commit_count_);
208 EXPECT_FALSE(sequence_was_satisfied_); 215 EXPECT_FALSE(sequence_was_satisfied_);
209 sequence_was_satisfied_ = true; 216 sequence_was_satisfied_ = true;
210 EndTest(); 217 EndTest();
211 } 218 }
212 } 219 }
213 220
214 void AfterTest() override { 221 void AfterTest() override {
215 EXPECT_TRUE(required_id_ == SurfaceId(kArbitraryClientId, 1, 0)); 222 EXPECT_TRUE(required_id_ == SurfaceId(kArbitraryClientId, 1, 0));
216 EXPECT_EQ(1u, required_set_.size()); 223 EXPECT_EQ(1u, required_set_.size());
217 // Sequence should have been satisfied through Swap, not with the 224 // Sequence should have been satisfied through Swap, not with the
218 // callback. 225 // callback.
219 EXPECT_TRUE(satisfied_sequence_.is_null()); 226 EXPECT_TRUE(satisfied_sequence_.is_null());
220 } 227 }
228
229 FakeOutputSurface* output_surface_;
221 }; 230 };
222 231
223 // TODO(jbauman): Reenable on single thread once http://crbug.com/421923 is 232 // TODO(jbauman): Reenable on single thread once http://crbug.com/421923 is
224 // fixed. 233 // fixed.
225 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithDraw); 234 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithDraw);
226 235
227 // Check that SurfaceSequence is sent through swap promise and resolved when 236 // Check that SurfaceSequence is sent through swap promise and resolved when
228 // swap fails. 237 // swap fails.
229 class SurfaceLayerSwapPromiseWithoutDraw : public SurfaceLayerSwapPromise { 238 class SurfaceLayerSwapPromiseWithoutDraw : public SurfaceLayerSwapPromise {
230 public: 239 public:
(...skipping 26 matching lines...) Expand all
257 EXPECT_EQ(1u, required_set_.size()); 266 EXPECT_EQ(1u, required_set_.size());
258 // Sequence should have been satisfied with the callback. 267 // Sequence should have been satisfied with the callback.
259 EXPECT_TRUE(satisfied_sequence_ == SurfaceSequence(1u, 1u)); 268 EXPECT_TRUE(satisfied_sequence_ == SurfaceSequence(1u, 1u));
260 } 269 }
261 }; 270 };
262 271
263 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithoutDraw); 272 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithoutDraw);
264 273
265 } // namespace 274 } // namespace
266 } // namespace cc 275 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/test/layer_tree_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698