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

Side by Side Diff: components/scheduler/base/long_task_tracker_unittest.cc

Issue 2118903002: scheduler: Move the Blink scheduler into Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/scheduler/base/long_task_tracker.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace scheduler {
9
10 class LongTaskTrackerTest : public ::testing::Test {
11 protected:
12 LongTaskTracker long_task_tracker_;
13
14 size_t NumLongTasks() {
15 return long_task_tracker_.long_task_times_.size();
16 }
17 };
18
19 TEST_F(LongTaskTrackerTest, RecordAndReport) {
20 EXPECT_EQ(0U, NumLongTasks());
21
22 // Add long tasks above 50ms threshold
23 long_task_tracker_.RecordLongTask(
24 base::TimeTicks() + base::TimeDelta::FromMilliseconds(4500),
25 base::TimeDelta::FromMilliseconds(51));
26 EXPECT_EQ(1U, NumLongTasks());
27
28 long_task_tracker_.RecordLongTask(
29 base::TimeTicks() + base::TimeDelta::FromMilliseconds(5500),
30 base::TimeDelta::FromMilliseconds(75));
31 EXPECT_EQ(2U, NumLongTasks());
32
33 // Add task below 50ms threshold
34 long_task_tracker_.RecordLongTask(
35 base::TimeTicks() + base::TimeDelta::FromMilliseconds(6500),
36 base::TimeDelta::FromMilliseconds(49));
37 EXPECT_EQ(2U, NumLongTasks());
38
39 LongTaskTracker::LongTaskTiming long_task_times =
40 long_task_tracker_.GetLongTaskTiming();
41 // GetLongTaskTiming clears the internal vector
42 EXPECT_EQ(0U, NumLongTasks());
43 // Validate recorded contents
44 EXPECT_EQ(2U, long_task_times.size());
45 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMilliseconds(4500),
46 long_task_times[0].first);
47 EXPECT_EQ(51, long_task_times[0].second.InMilliseconds());
48 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMilliseconds(5500),
49 long_task_times[1].first);
50 EXPECT_EQ(75, long_task_times[1].second.InMilliseconds());
51 }
52
53 }
OLDNEW
« no previous file with comments | « components/scheduler/base/long_task_tracker.cc ('k') | components/scheduler/base/pollable_thread_safe_flag.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698