OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/tracked_objects.h" | 11 #include "base/tracked_objects.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/task_profiler/task_profiler_data_serializer.h" | 13 #include "chrome/browser/task_profiler/task_profiler_data_serializer.h" |
14 #include "content/public/common/process_type.h" | 14 #include "content/public/common/process_type.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 void ExpectSerialization( | 19 void ExpectSerialization( |
20 const tracked_objects::ProcessDataPhaseSnapshot& process_data_phase, | 20 const tracked_objects::ProcessDataPhaseSnapshot& process_data_phase, |
21 base::ProcessId process_id, | 21 base::ProcessId process_id, |
22 int process_type, | 22 int process_type, |
23 const std::string& expected_json) { | 23 const std::string& expected_json) { |
24 base::DictionaryValue serialized_value; | 24 base::DictionaryValue serialized_value; |
25 task_profiler::TaskProfilerDataSerializer::ToValue( | 25 task_profiler::TaskProfilerDataSerializer::ToValue( |
26 process_data_phase, process_id, process_type, &serialized_value); | 26 process_data_phase, process_id, process_type, &serialized_value); |
27 | 27 |
28 std::string serialized_json; | 28 std::string serialized_json; |
29 base::JSONWriter::Write(&serialized_value, &serialized_json); | 29 base::JSONWriter::Write(serialized_value, &serialized_json); |
30 | 30 |
31 EXPECT_EQ(expected_json, serialized_json); | 31 EXPECT_EQ(expected_json, serialized_json); |
32 } | 32 } |
33 | 33 |
34 } // anonymous namespace | 34 } // anonymous namespace |
35 | 35 |
36 // Tests the JSON serialization format for profiled process data. | 36 // Tests the JSON serialization format for profiled process data. |
37 TEST(TaskProfilerDataSerializerTest, SerializeProcessDataToJson) { | 37 TEST(TaskProfilerDataSerializerTest, SerializeProcessDataToJson) { |
38 { | 38 { |
39 // Empty data. | 39 // Empty data. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 "\"run_ms_max\":205," | 126 "\"run_ms_max\":205," |
127 "\"run_ms_sample\":203" | 127 "\"run_ms_sample\":203" |
128 "}," | 128 "}," |
129 "\"death_thread\":\"PAC thread #3\"" | 129 "\"death_thread\":\"PAC thread #3\"" |
130 "}]," | 130 "}]," |
131 "\"process_id\":239," | 131 "\"process_id\":239," |
132 "\"process_type\":\"Tab\"" | 132 "\"process_type\":\"Tab\"" |
133 "}"); | 133 "}"); |
134 } | 134 } |
135 } | 135 } |
OLD | NEW |