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

Side by Side Diff: cc/scheduler/scheduler_unittest.cc

Issue 735723005: cc: Adding creation location to debug BeginFrameArgs objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Testing on try bots. Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 164 }
165 165
166 void AdvanceFrame() { 166 void AdvanceFrame() {
167 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), 167 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"),
168 "FakeSchedulerClient::AdvanceFrame"); 168 "FakeSchedulerClient::AdvanceFrame");
169 if (ExternalBeginFrame()) { 169 if (ExternalBeginFrame()) {
170 // Creep the time forward so that any BeginFrameArgs is not equal to the 170 // Creep the time forward so that any BeginFrameArgs is not equal to the
171 // last one otherwise we violate the BeginFrameSource contract. 171 // last one otherwise we violate the BeginFrameSource contract.
172 now_src_->AdvanceNowMicroseconds(1); 172 now_src_->AdvanceNowMicroseconds(1);
173 fake_external_begin_frame_source_->TestOnBeginFrame( 173 fake_external_begin_frame_source_->TestOnBeginFrame(
174 CreateBeginFrameArgsForTesting(now_src_)); 174 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src_));
175 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 175 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
176 } 176 }
177 177
178 EXPECT_TRUE(task_runner().RunTasksWhile(ImplFrameDeadlinePending(false))); 178 EXPECT_TRUE(task_runner().RunTasksWhile(ImplFrameDeadlinePending(false)));
179 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 179 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
180 } 180 }
181 181
182 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } 182 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; }
183 TestNowSource* now_src() { return now_src_.get(); } 183 TestNowSource* now_src() { return now_src_.get(); }
184 184
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 scheduler->SetCanStart(); 1119 scheduler->SetCanStart();
1120 scheduler->SetVisible(true); 1120 scheduler->SetVisible(true);
1121 scheduler->DidCreateAndInitializeOutputSurface(); 1121 scheduler->DidCreateAndInitializeOutputSurface();
1122 1122
1123 scheduler->SetNeedsCommit(); 1123 scheduler->SetNeedsCommit();
1124 EXPECT_TRUE(scheduler->CommitPending()); 1124 EXPECT_TRUE(scheduler->CommitPending());
1125 scheduler->NotifyBeginMainFrameStarted(); 1125 scheduler->NotifyBeginMainFrameStarted();
1126 scheduler->NotifyReadyToCommit(); 1126 scheduler->NotifyReadyToCommit();
1127 scheduler->SetNeedsRedraw(); 1127 scheduler->SetNeedsRedraw();
1128 1128
1129 BeginFrameArgs frame_args = CreateBeginFrameArgsForTesting(client.now_src()); 1129 BeginFrameArgs frame_args =
1130 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, client.now_src());
1130 frame_args.interval = base::TimeDelta::FromMilliseconds(1000); 1131 frame_args.interval = base::TimeDelta::FromMilliseconds(1000);
1131 client.fake_external_begin_frame_source()->TestOnBeginFrame(frame_args); 1132 client.fake_external_begin_frame_source()->TestOnBeginFrame(frame_args);
1132 1133
1133 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1134 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1134 client.task_runner().RunPendingTasks(); // Run posted deadline. 1135 client.task_runner().RunPendingTasks(); // Run posted deadline.
1135 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1136 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1136 1137
1137 scheduler->DidSwapBuffers(); 1138 scheduler->DidSwapBuffers();
1138 scheduler->DidSwapBuffersComplete(); 1139 scheduler->DidSwapBuffersComplete();
1139 1140
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1193 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1193 1194
1194 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1195 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1195 client.Reset(); 1196 client.Reset();
1196 scheduler->SetNeedsCommit(); 1197 scheduler->SetNeedsCommit();
1197 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); 1198 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client);
1198 client.Reset(); 1199 client.Reset();
1199 1200
1200 // Create a BeginFrame with a long deadline to avoid race conditions. 1201 // Create a BeginFrame with a long deadline to avoid race conditions.
1201 // This is the first BeginFrame, which will be handled immediately. 1202 // This is the first BeginFrame, which will be handled immediately.
1202 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); 1203 BeginFrameArgs args =
1204 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, client.now_src());
1203 args.deadline += base::TimeDelta::FromHours(1); 1205 args.deadline += base::TimeDelta::FromHours(1);
1204 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); 1206 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1205 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1207 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1206 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1208 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1207 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1209 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1208 EXPECT_TRUE(client.needs_begin_frames()); 1210 EXPECT_TRUE(client.needs_begin_frames());
1209 client.Reset(); 1211 client.Reset();
1210 1212
1211 // Queue BeginFrames while we are still handling the previous BeginFrame. 1213 // Queue BeginFrames while we are still handling the previous BeginFrame.
1212 args.frame_time += base::TimeDelta::FromSeconds(1); 1214 args.frame_time += base::TimeDelta::FromSeconds(1);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 client.SetAutomaticSwapAck(false); 1272 client.SetAutomaticSwapAck(false);
1271 1273
1272 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1274 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1273 client.Reset(); 1275 client.Reset();
1274 scheduler->SetNeedsCommit(); 1276 scheduler->SetNeedsCommit();
1275 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); 1277 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client);
1276 client.Reset(); 1278 client.Reset();
1277 1279
1278 // Create a BeginFrame with a long deadline to avoid race conditions. 1280 // Create a BeginFrame with a long deadline to avoid race conditions.
1279 // This is the first BeginFrame, which will be handled immediately. 1281 // This is the first BeginFrame, which will be handled immediately.
1280 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); 1282 BeginFrameArgs args =
1283 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, client.now_src());
1281 args.deadline += base::TimeDelta::FromHours(1); 1284 args.deadline += base::TimeDelta::FromHours(1);
1282 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); 1285 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1283 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1286 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1284 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1287 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1285 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1288 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1286 EXPECT_TRUE(client.needs_begin_frames()); 1289 EXPECT_TRUE(client.needs_begin_frames());
1287 client.Reset(); 1290 client.Reset();
1288 1291
1289 // Queue BeginFrame while we are still handling the previous BeginFrame. 1292 // Queue BeginFrame while we are still handling the previous BeginFrame.
1290 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1293 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1748 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1746 1749
1747 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1750 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1748 client.Reset(); 1751 client.Reset();
1749 scheduler->SetNeedsCommit(); 1752 scheduler->SetNeedsCommit();
1750 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); 1753 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client);
1751 1754
1752 // Create a BeginFrame with a long deadline to avoid race conditions. 1755 // Create a BeginFrame with a long deadline to avoid race conditions.
1753 // This is the first BeginFrame, which will be handled immediately. 1756 // This is the first BeginFrame, which will be handled immediately.
1754 client.Reset(); 1757 client.Reset();
1755 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); 1758 BeginFrameArgs args =
1759 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, client.now_src());
1756 args.deadline += base::TimeDelta::FromHours(1); 1760 args.deadline += base::TimeDelta::FromHours(1);
1757 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); 1761 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1758 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1762 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1759 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1763 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1760 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1764 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1761 EXPECT_TRUE(client.needs_begin_frames()); 1765 EXPECT_TRUE(client.needs_begin_frames());
1762 1766
1763 // Queue BeginFrames while we are still handling the previous BeginFrame. 1767 // Queue BeginFrames while we are still handling the previous BeginFrame.
1764 args.frame_time += base::TimeDelta::FromSeconds(1); 1768 args.frame_time += base::TimeDelta::FromSeconds(1);
1765 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); 1769 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1808 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1805 1809
1806 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1810 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1807 client.Reset(); 1811 client.Reset();
1808 scheduler->SetNeedsCommit(); 1812 scheduler->SetNeedsCommit();
1809 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); 1813 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client);
1810 1814
1811 // Create a BeginFrame with a long deadline to avoid race conditions. 1815 // Create a BeginFrame with a long deadline to avoid race conditions.
1812 // This is the first BeginFrame, which will be handled immediately. 1816 // This is the first BeginFrame, which will be handled immediately.
1813 client.Reset(); 1817 client.Reset();
1814 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); 1818 BeginFrameArgs args =
1819 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, client.now_src());
1815 args.deadline += base::TimeDelta::FromHours(1); 1820 args.deadline += base::TimeDelta::FromHours(1);
1816 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); 1821 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1817 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1822 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1818 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1823 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1819 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1824 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1820 EXPECT_TRUE(client.needs_begin_frames()); 1825 EXPECT_TRUE(client.needs_begin_frames());
1821 1826
1822 // Queue BeginFrames while we are still handling the previous BeginFrame. 1827 // Queue BeginFrames while we are still handling the previous BeginFrame.
1823 args.frame_time += base::TimeDelta::FromSeconds(1); 1828 args.frame_time += base::TimeDelta::FromSeconds(1);
1824 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); 1829 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 2092
2088 // Deadline task is pending 2093 // Deadline task is pending
2089 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 2094 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
2090 client.task_runner().RunPendingTasks(); 2095 client.task_runner().RunPendingTasks();
2091 // Deadline task runs immediately 2096 // Deadline task runs immediately
2092 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 2097 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
2093 } 2098 }
2094 2099
2095 } // namespace 2100 } // namespace
2096 } // namespace cc 2101 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698