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

Side by Side Diff: mojo/public/cpp/utility/tests/run_loop_unittest.cc

Issue 384513003: Remove RequestAnimationFrame from mojo, add delayed tasks to RunLoop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 | Annotate | Revision Log
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 "mojo/public/cpp/utility/run_loop.h" 5 #include "mojo/public/cpp/utility/run_loop.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "mojo/public/cpp/system/core.h" 9 #include "mojo/public/cpp/system/core.h"
10 #include "mojo/public/cpp/test_support/test_utils.h" 10 #include "mojo/public/cpp/test_support/test_utils.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 handler.WriteSignal(); 277 handler.WriteSignal();
278 run_loop.Run(); 278 run_loop.Run();
279 279
280 EXPECT_TRUE(handler.reached_depth_limit()); 280 EXPECT_TRUE(handler.reached_depth_limit());
281 // Got MOJO_RESULT_DEADLINE_EXCEEDED once then removed from the 281 // Got MOJO_RESULT_DEADLINE_EXCEEDED once then removed from the
282 // RunLoop's handler list. 282 // RunLoop's handler list.
283 EXPECT_EQ(handler.error_count(), 1); 283 EXPECT_EQ(handler.error_count(), 1);
284 EXPECT_EQ(handler.last_error_result(), MOJO_RESULT_DEADLINE_EXCEEDED); 284 EXPECT_EQ(handler.last_error_result(), MOJO_RESULT_DEADLINE_EXCEEDED);
285 } 285 }
286 286
287 struct Task {
288 Task(int num, std::vector<int>* sequence) : num(num), sequence(sequence) {}
289
290 void Run() const { sequence->push_back(num); }
291
292 int num;
293 std::vector<int>* sequence;
294 };
295
296 TEST_F(RunLoopTest, DelayedTaskOrder) {
297 std::vector<int> sequence;
298 RunLoop run_loop;
299 run_loop.PostDelayedTask(Closure(Task(1, &sequence)), 0);
300 run_loop.PostDelayedTask(Closure(Task(2, &sequence)), 0);
301 run_loop.PostDelayedTask(Closure(Task(3, &sequence)), 0);
302 run_loop.RunUntilIdle();
303
304 ASSERT_EQ(3u, sequence.size());
305 EXPECT_EQ(1, sequence[0]);
306 EXPECT_EQ(2, sequence[1]);
307 EXPECT_EQ(3, sequence[2]);
308 }
309
287 } // namespace 310 } // namespace
288 } // namespace mojo 311 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698