| OLD | NEW |
| 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 "components/metrics/profiler/profiler_metrics_provider.h" | 5 #include "components/metrics/profiler/profiler_metrics_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/tracked_objects.h" | 8 #include "base/tracked_objects.h" |
| 9 #include "components/metrics/metrics_hashes.h" | 9 #include "components/metrics/metrics_hashes.h" |
| 10 #include "content/public/common/process_type.h" | 10 #include "content/public/common/process_type.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 using tracked_objects::ProcessDataSnapshot; | 13 using tracked_objects::ProcessDataSnapshot; |
| 14 using tracked_objects::TaskSnapshot; | 14 using tracked_objects::TaskSnapshot; |
| 15 | 15 |
| 16 namespace metrics { | 16 namespace metrics { |
| 17 | 17 |
| 18 void MockIsCellular(bool* is_cellular_out) { | |
| 19 *is_cellular_out = false; | |
| 20 } | |
| 21 | |
| 22 TEST(ProfilerMetricsProviderTest, RecordData) { | 18 TEST(ProfilerMetricsProviderTest, RecordData) { |
| 23 // WARNING: If you broke the below check, you've modified how | 19 // WARNING: If you broke the below check, you've modified how |
| 24 // HashMetricName works. Please also modify all server-side code that | 20 // HashMetricName works. Please also modify all server-side code that |
| 25 // relies on the existing way of hashing. | 21 // relies on the existing way of hashing. |
| 26 EXPECT_EQ(GG_UINT64_C(1518842999910132863), HashMetricName("birth_thread*")); | 22 EXPECT_EQ(GG_UINT64_C(1518842999910132863), HashMetricName("birth_thread*")); |
| 27 | 23 |
| 28 ProfilerMetricsProvider profiler_metrics_provider(base::Bind(MockIsCellular)); | 24 ProfilerMetricsProvider profiler_metrics_provider; |
| 29 | 25 |
| 30 { | 26 { |
| 31 // Add data from the browser process. | 27 // Add data from the browser process. |
| 32 ProcessDataSnapshot process_data; | 28 ProcessDataSnapshot process_data; |
| 33 process_data.process_id = 177; | 29 process_data.process_id = 177; |
| 34 process_data.tasks.push_back(TaskSnapshot()); | 30 process_data.tasks.push_back(TaskSnapshot()); |
| 35 process_data.tasks.back().birth.location.file_name = "a/b/file.h"; | 31 process_data.tasks.back().birth.location.file_name = "a/b/file.h"; |
| 36 process_data.tasks.back().birth.location.function_name = "function"; | 32 process_data.tasks.back().birth.location.function_name = "function"; |
| 37 process_data.tasks.back().birth.location.line_number = 1337; | 33 process_data.tasks.back().birth.location.line_number = 1337; |
| 38 process_data.tasks.back().birth.thread_name = "birth_thread"; | 34 process_data.tasks.back().birth.thread_name = "birth_thread"; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 EXPECT_EQ(109, tracked_object->queue_time_total()); | 175 EXPECT_EQ(109, tracked_object->queue_time_total()); |
| 180 EXPECT_EQ(104, tracked_object->queue_time_sampled()); | 176 EXPECT_EQ(104, tracked_object->queue_time_sampled()); |
| 181 EXPECT_EQ(HashMetricName(""), | 177 EXPECT_EQ(HashMetricName(""), |
| 182 tracked_object->exec_thread_name_hash()); | 178 tracked_object->exec_thread_name_hash()); |
| 183 EXPECT_EQ(ProfilerEventProto::TrackedObject::RENDERER, | 179 EXPECT_EQ(ProfilerEventProto::TrackedObject::RENDERER, |
| 184 tracked_object->process_type()); | 180 tracked_object->process_type()); |
| 185 } | 181 } |
| 186 } | 182 } |
| 187 | 183 |
| 188 } // namespace metrics | 184 } // namespace metrics |
| OLD | NEW |