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

Side by Side Diff: cc/trees/remote_channel_unittest.cc

Issue 2042433002: cc: Fix flaky RemoteChannelTest.ReleaseOutputSurfaceDuringCommit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/test/begin_frame_args_test.h" 5 #include "cc/test/begin_frame_args_test.h"
6 #include "cc/test/layer_tree_test.h" 6 #include "cc/test/layer_tree_test.h"
7 7
8 namespace cc { 8 namespace cc {
9 9
10 class RemoteChannelTest : public LayerTreeTest { 10 class RemoteChannelTest : public LayerTreeTest {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 class RemoteChannelTestReleaseOutputSurfaceDuringCommit 199 class RemoteChannelTestReleaseOutputSurfaceDuringCommit
200 : public RemoteChannelTest { 200 : public RemoteChannelTest {
201 public: 201 public:
202 RemoteChannelTestReleaseOutputSurfaceDuringCommit() 202 RemoteChannelTestReleaseOutputSurfaceDuringCommit()
203 : output_surface_initialized_count_(0), commit_count_(0) {} 203 : output_surface_initialized_count_(0), commit_count_(0) {}
204 void BeginChannelTest() override { PostSetNeedsCommitToMainThread(); } 204 void BeginChannelTest() override { PostSetNeedsCommitToMainThread(); }
205 205
206 void DidInitializeOutputSurface() override { 206 void DidInitializeOutputSurface() override {
207 ++output_surface_initialized_count_; 207 ++output_surface_initialized_count_;
208 208
209 // We should not have any commits at this point. This call runs either after 209 switch (output_surface_initialized_count_) {
210 // the first output surface is initialized so no commits should have been 210 case 1:
211 // started, or after the output surface was released by the main thread. In 211 // No commits can be performed before the first output surface is
212 // which case, we should have queued the commit and it should only go 212 // initialized. The Scheduler should not send BeginMainFrames.
213 // through after the new output surface is initialized. 213 EXPECT_EQ(0, commit_count_);
214 EXPECT_EQ(0, commit_count_); 214 break;
215 case 2:
216 // When the first BeginMainFrame is received on the server, we release
217 // the output surface on the client. The RemoteChannelImpl on the client
218 // will queue the commit received till a new output surface is
219 // initialized, so we shouldn't see any commits till a second output
220 // surface is provided to the LTH.
221 EXPECT_EQ(0, commit_count_);
222 break;
223 }
215 } 224 }
216 225
217 void ReceivedBeginMainFrame() override { 226 void ReceivedBeginMainFrame() override {
218 // Release the output surface before we respond to the BeginMainFrame. 227 if (commit_count_ == 0) {
219 SetVisibleOnLayerTreeHost(false); 228 // Release the output surface before we respond to the BeginMainFrame.
220 ReleaseOutputSurfaceOnLayerTreeHost(); 229 // We perform the test only for the first BeginMainFrame request.
221 SetVisibleOnLayerTreeHost(true); 230 SetVisibleOnLayerTreeHost(false);
231 ReleaseOutputSurfaceOnLayerTreeHost();
232 SetVisibleOnLayerTreeHost(true);
233 }
222 } 234 }
223 235
224 void StartCommitOnImpl() override { 236 void StartCommitOnImpl() override {
225 // The commit should go through only when the second output surface is
226 // initialized.
227 EXPECT_EQ(2, output_surface_initialized_count_);
228 EXPECT_EQ(0, commit_count_);
229 ++commit_count_; 237 ++commit_count_;
230 EndTest(); 238 if (commit_count_ == 1) {
239 // If this is the first commit, then the output surface must have been
240 // initialized twice.
241 EXPECT_EQ(2, output_surface_initialized_count_);
242 EndTest();
243 }
231 } 244 }
232 245
233 void AfterTest() override { 246 void AfterTest() override {}
234 EXPECT_EQ(2, output_surface_initialized_count_);
235 EXPECT_EQ(1, commit_count_);
236 }
237 247
248 // Accessed on the main thread and the impl thread, when the main thread is
249 // blocked.
238 int output_surface_initialized_count_; 250 int output_surface_initialized_count_;
239 int commit_count_; 251 int commit_count_;
240 }; 252 };
241 253
242 REMOTE_DIRECT_RENDERER_TEST_F( 254 REMOTE_DIRECT_RENDERER_TEST_F(
243 RemoteChannelTestReleaseOutputSurfaceDuringCommit); 255 RemoteChannelTestReleaseOutputSurfaceDuringCommit);
244 256
245 } // namespace cc 257 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698