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

Side by Side Diff: components/metrics/profiler/tracking_synchronizer_unittest.cc

Issue 1178423008: Provision to start base::SimpleTestTickClock at initial ticks Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/test/simple_test_tick_clock.h" 6 #include "base/test/simple_test_tick_clock.h"
7 #include "base/tracked_objects.h" 7 #include "base/tracked_objects.h"
8 #include "components/metrics/profiler/tracking_synchronizer.h" 8 #include "components/metrics/profiler/tracking_synchronizer.h"
9 #include "components/metrics/profiler/tracking_synchronizer_observer.h" 9 #include "components/metrics/profiler/tracking_synchronizer_observer.h"
10 #include "content/public/test/test_browser_thread_bundle.h" 10 #include "content/public/test/test_browser_thread_bundle.h"
(...skipping 22 matching lines...) Expand all
33 EXPECT_EQ(static_cast<base::ProcessId>(239), attributes.process_id); 33 EXPECT_EQ(static_cast<base::ProcessId>(239), attributes.process_id);
34 EXPECT_EQ(content::ProcessType::PROCESS_TYPE_PLUGIN, 34 EXPECT_EQ(content::ProcessType::PROCESS_TYPE_PLUGIN,
35 attributes.process_type); 35 attributes.process_type);
36 ASSERT_EQ(1u, process_data_phase.tasks.size()); 36 ASSERT_EQ(1u, process_data_phase.tasks.size());
37 37
38 switch (attributes.profiling_phase) { 38 switch (attributes.profiling_phase) {
39 case 0: 39 case 0:
40 EXPECT_FALSE(got_phase_0_); 40 EXPECT_FALSE(got_phase_0_);
41 got_phase_0_ = true; 41 got_phase_0_ = true;
42 42
43 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMilliseconds(111), 43 // SimpleTestTickClock starts at 1 microsecond, add to expected ticks
44 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMicroseconds(1) +
45 base::TimeDelta::FromMilliseconds(111),
44 attributes.phase_start); 46 attributes.phase_start);
45 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMilliseconds(333), 47 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMicroseconds(1) +
48 base::TimeDelta::FromMilliseconds(333),
46 attributes.phase_finish); 49 attributes.phase_finish);
47 50
48 EXPECT_EQ("death_thread0", 51 EXPECT_EQ("death_thread0",
49 process_data_phase.tasks[0].death_thread_name); 52 process_data_phase.tasks[0].death_thread_name);
50 EXPECT_EQ(0u, past_events.size()); 53 EXPECT_EQ(0u, past_events.size());
51 break; 54 break;
52 55
53 case 1: 56 case 1:
54 EXPECT_FALSE(got_phase_1_); 57 EXPECT_FALSE(got_phase_1_);
55 got_phase_1_ = true; 58 got_phase_1_ = true;
56 59
57 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMilliseconds(333), 60 // SimpleTestTickClock starts at 1 microsecond, add to expected ticks
61 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMicroseconds(1) +
62 base::TimeDelta::FromMilliseconds(333),
58 attributes.phase_start); 63 attributes.phase_start);
59 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMilliseconds(777), 64 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMicroseconds(1) +
65 base::TimeDelta::FromMilliseconds(777),
60 attributes.phase_finish); 66 attributes.phase_finish);
61 67
62 EXPECT_EQ("death_thread1", 68 EXPECT_EQ("death_thread1",
63 process_data_phase.tasks[0].death_thread_name); 69 process_data_phase.tasks[0].death_thread_name);
64 ASSERT_EQ(1u, past_events.size()); 70 ASSERT_EQ(1u, past_events.size());
65 EXPECT_EQ(ProfilerEventProto::EVENT_FIRST_NONEMPTY_PAINT, 71 EXPECT_EQ(ProfilerEventProto::EVENT_FIRST_NONEMPTY_PAINT,
66 past_events[0]); 72 past_events[0]);
67 break; 73 break;
68 74
69 default: 75 default:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 profiler_data.phased_snapshots[1] = snapshot1; 130 profiler_data.phased_snapshots[1] = snapshot1;
125 profiler_data.process_id = 239; 131 profiler_data.process_id = 239;
126 132
127 clock->Advance(base::TimeDelta::FromMilliseconds(444)); 133 clock->Advance(base::TimeDelta::FromMilliseconds(444));
128 TestObserver test_observer; 134 TestObserver test_observer;
129 tracking_synchronizer->SendData( 135 tracking_synchronizer->SendData(
130 profiler_data, content::ProcessType::PROCESS_TYPE_PLUGIN, &test_observer); 136 profiler_data, content::ProcessType::PROCESS_TYPE_PLUGIN, &test_observer);
131 } 137 }
132 138
133 } // namespace metrics 139 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698