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

Side by Side Diff: webrtc/base/task_unittest.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 years, 2 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 | « webrtc/base/task.cc ('k') | webrtc/base/taskrunner.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 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 13 matching lines...) Expand all
24 #include "webrtc/base/gunit.h" 24 #include "webrtc/base/gunit.h"
25 #include "webrtc/base/logging.h" 25 #include "webrtc/base/logging.h"
26 #include "webrtc/base/task.h" 26 #include "webrtc/base/task.h"
27 #include "webrtc/base/taskrunner.h" 27 #include "webrtc/base/taskrunner.h"
28 #include "webrtc/base/thread.h" 28 #include "webrtc/base/thread.h"
29 #include "webrtc/base/timeutils.h" 29 #include "webrtc/base/timeutils.h"
30 #include "webrtc/test/testsupport/gtest_disable.h" 30 #include "webrtc/test/testsupport/gtest_disable.h"
31 31
32 namespace rtc { 32 namespace rtc {
33 33
34 static int64 GetCurrentTime() { 34 static int64_t GetCurrentTime() {
35 return static_cast<int64>(Time()) * 10000; 35 return static_cast<int64_t>(Time()) * 10000;
36 } 36 }
37 37
38 // feel free to change these numbers. Note that '0' won't work, though 38 // feel free to change these numbers. Note that '0' won't work, though
39 #define STUCK_TASK_COUNT 5 39 #define STUCK_TASK_COUNT 5
40 #define HAPPY_TASK_COUNT 20 40 #define HAPPY_TASK_COUNT 20
41 41
42 // this is a generic timeout task which, when it signals timeout, will 42 // this is a generic timeout task which, when it signals timeout, will
43 // include the unique ID of the task in the signal (we don't use this 43 // include the unique ID of the task in the signal (we don't use this
44 // in production code because we haven't yet had occasion to generate 44 // in production code because we haven't yet had occasion to generate
45 // an array of the same types of task) 45 // an array of the same types of task)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 private: 91 private:
92 int time_to_perform_; 92 int time_to_perform_;
93 }; 93 };
94 94
95 // simple implementation of a task runner which uses Windows' 95 // simple implementation of a task runner which uses Windows'
96 // GetSystemTimeAsFileTime() to get the current clock ticks 96 // GetSystemTimeAsFileTime() to get the current clock ticks
97 97
98 class MyTaskRunner : public TaskRunner { 98 class MyTaskRunner : public TaskRunner {
99 public: 99 public:
100 virtual void WakeTasks() { RunTasks(); } 100 virtual void WakeTasks() { RunTasks(); }
101 virtual int64 CurrentTime() { 101 virtual int64_t CurrentTime() { return GetCurrentTime(); }
102 return GetCurrentTime();
103 }
104 102
105 bool timeout_change() const { 103 bool timeout_change() const {
106 return timeout_change_; 104 return timeout_change_;
107 } 105 }
108 106
109 void clear_timeout_change() { 107 void clear_timeout_change() {
110 timeout_change_ = false; 108 timeout_change_ = false;
111 } 109 }
112 protected: 110 protected:
113 virtual void OnTimeoutChange() { 111 virtual void OnTimeoutChange() {
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 TEST(start_task_test, TimeoutChange) { 481 TEST(start_task_test, TimeoutChange) {
484 TimeoutChangeTest timeout_change_test; 482 TimeoutChangeTest timeout_change_test;
485 timeout_change_test.Start(); 483 timeout_change_test.Start();
486 } 484 }
487 485
488 class DeleteTestTaskRunner : public TaskRunner { 486 class DeleteTestTaskRunner : public TaskRunner {
489 public: 487 public:
490 DeleteTestTaskRunner() { 488 DeleteTestTaskRunner() {
491 } 489 }
492 virtual void WakeTasks() { } 490 virtual void WakeTasks() { }
493 virtual int64 CurrentTime() { 491 virtual int64_t CurrentTime() { return GetCurrentTime(); }
494 return GetCurrentTime();
495 }
496 private: 492 private:
497 RTC_DISALLOW_COPY_AND_ASSIGN(DeleteTestTaskRunner); 493 RTC_DISALLOW_COPY_AND_ASSIGN(DeleteTestTaskRunner);
498 }; 494 };
499 495
500 TEST(unstarted_task_test, DeleteTask) { 496 TEST(unstarted_task_test, DeleteTask) {
501 // This test ensures that we don't 497 // This test ensures that we don't
502 // crash if a task is deleted without running it. 498 // crash if a task is deleted without running it.
503 DeleteTestTaskRunner task_runner; 499 DeleteTestTaskRunner task_runner;
504 HappyTask* happy_task = new HappyTask(&task_runner); 500 HappyTask* happy_task = new HappyTask(&task_runner);
505 happy_task->Start(); 501 happy_task->Start();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 // Do not start the task. 533 // Do not start the task.
538 // Note: this leaks memory, so don't do this. 534 // Note: this leaks memory, so don't do this.
539 // Instead, always run your tasks or delete them. 535 // Instead, always run your tasks or delete them.
540 new HappyTask(happy_task); 536 new HappyTask(happy_task);
541 537
542 // run the unblocked tasks 538 // run the unblocked tasks
543 task_runner.RunTasks(); 539 task_runner.RunTasks();
544 } 540 }
545 541
546 } // namespace rtc 542 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/task.cc ('k') | webrtc/base/taskrunner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698