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

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

Issue 1539203002: Switch to standard integer types in cc/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more includes Created 5 years 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 | « cc/scheduler/delay_based_time_source.h ('k') | cc/scheduler/scheduler.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 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/delay_based_time_source.h" 5 #include "cc/scheduler/delay_based_time_source.h"
6 6
7 #include "base/basictypes.h" 7 #include <stdint.h>
8
8 #include "base/test/test_simple_task_runner.h" 9 #include "base/test/test_simple_task_runner.h"
9 #include "cc/test/scheduler_test_common.h" 10 #include "cc/test/scheduler_test_common.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace cc { 13 namespace cc {
13 namespace { 14 namespace {
14 15
15 base::TimeDelta Interval() { 16 base::TimeDelta Interval() {
16 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond / 17 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond /
17 60); 18 60);
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 scoped_refptr<base::TestSimpleTaskRunner> task_runner = 423 scoped_refptr<base::TestSimpleTaskRunner> task_runner =
423 new base::TestSimpleTaskRunner; 424 new base::TestSimpleTaskRunner;
424 FakeDelayBasedTimeSourceClient client; 425 FakeDelayBasedTimeSourceClient client;
425 scoped_ptr<FakeDelayBasedTimeSource> timer = 426 scoped_ptr<FakeDelayBasedTimeSource> timer =
426 FakeDelayBasedTimeSource::Create(Interval(), task_runner.get()); 427 FakeDelayBasedTimeSource::Create(Interval(), task_runner.get());
427 timer->SetClient(&client); 428 timer->SetClient(&client);
428 timer->SetActive(true); 429 timer->SetActive(true);
429 430
430 double total_frame_time = 0.0; 431 double total_frame_time = 0.0;
431 for (int i = 0; i < num_iterations; ++i) { 432 for (int i = 0; i < num_iterations; ++i) {
432 int64 delay_ms = task_runner->NextPendingTaskDelay().InMilliseconds(); 433 int64_t delay_ms = task_runner->NextPendingTaskDelay().InMilliseconds();
433 434
434 // accumulate the "delay" 435 // accumulate the "delay"
435 total_frame_time += delay_ms / 1000.0; 436 total_frame_time += delay_ms / 1000.0;
436 437
437 // Run the callback exactly when asked 438 // Run the callback exactly when asked
438 timer->SetNow(timer->Now() + base::TimeDelta::FromMilliseconds(delay_ms)); 439 timer->SetNow(timer->Now() + base::TimeDelta::FromMilliseconds(delay_ms));
439 task_runner->RunPendingTasks(); 440 task_runner->RunPendingTasks();
440 } 441 }
441 double average_interval = 442 double average_interval =
442 total_frame_time / static_cast<double>(num_iterations); 443 total_frame_time / static_cast<double>(num_iterations);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 timer->SetActive(true); 520 timer->SetActive(true);
520 task_runner->RunPendingTasks(); 521 task_runner->RunPendingTasks();
521 522
522 // SetActive should return empty TimeTicks when the timer is deactivated. 523 // SetActive should return empty TimeTicks when the timer is deactivated.
523 base::TimeTicks missed_tick_time = timer->SetActive(false); 524 base::TimeTicks missed_tick_time = timer->SetActive(false);
524 EXPECT_TRUE(missed_tick_time.is_null()); 525 EXPECT_TRUE(missed_tick_time.is_null());
525 } 526 }
526 527
527 } // namespace 528 } // namespace
528 } // namespace cc 529 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/delay_based_time_source.h ('k') | cc/scheduler/scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698