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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/debug/trace_event_impl.h" | 6 #include "base/debug/trace_event_impl.h" |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 EXPECT_EQ(value->GetType(), base::Value::TYPE_LIST); | 127 EXPECT_EQ(value->GetType(), base::Value::TYPE_LIST); |
128 | 128 |
129 base::ListValue* values; | 129 base::ListValue* values; |
130 ASSERT_TRUE(value->GetAsList(&values)); | 130 ASSERT_TRUE(value->GetAsList(&values)); |
131 | 131 |
132 int duration_ns = 0; | 132 int duration_ns = 0; |
133 std::string samples_duration; | 133 std::string samples_duration; |
134 double timestamp_ns = 0.0; | 134 double timestamp_ns = 0.0; |
135 double previous_timestamp_ns = 0.0; | 135 double previous_timestamp_ns = 0.0; |
136 std::string samples_interarrival_ns; | 136 std::string samples_interarrival_ns; |
137 for (ListValue::iterator it = values->begin(); it != values->end(); ++it) { | 137 for (base::ListValue::iterator it = values->begin(); |
138 const DictionaryValue* dict; | 138 it != values->end(); ++it) { |
| 139 const base::DictionaryValue* dict; |
139 EXPECT_TRUE((*it)->GetAsDictionary(&dict)); | 140 EXPECT_TRUE((*it)->GetAsDictionary(&dict)); |
140 | 141 |
141 if (dict->GetInteger("dur", &duration_ns)) | 142 if (dict->GetInteger("dur", &duration_ns)) |
142 samples_duration.append(base::StringPrintf("%d,", duration_ns)); | 143 samples_duration.append(base::StringPrintf("%d,", duration_ns)); |
143 if (dict->GetDouble("ts", ×tamp_ns)) { | 144 if (dict->GetDouble("ts", ×tamp_ns)) { |
144 if (previous_timestamp_ns) { | 145 if (previous_timestamp_ns) { |
145 samples_interarrival_ns.append( | 146 samples_interarrival_ns.append( |
146 base::StringPrintf("%f,", timestamp_ns - previous_timestamp_ns)); | 147 base::StringPrintf("%f,", timestamp_ns - previous_timestamp_ns)); |
147 } | 148 } |
148 previous_timestamp_ns = timestamp_ns; | 149 previous_timestamp_ns = timestamp_ns; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 base::JSON_ALLOW_TRAILING_COMMAS, | 181 base::JSON_ALLOW_TRAILING_COMMAS, |
181 &error_code, | 182 &error_code, |
182 &error_message)); | 183 &error_message)); |
183 | 184 |
184 ASSERT_TRUE(value.get() != NULL) << error_message; | 185 ASSERT_TRUE(value.get() != NULL) << error_message; |
185 EXPECT_EQ(value->GetType(), base::Value::TYPE_LIST); | 186 EXPECT_EQ(value->GetType(), base::Value::TYPE_LIST); |
186 | 187 |
187 base::ListValue* values; | 188 base::ListValue* values; |
188 ASSERT_TRUE(value->GetAsList(&values)); | 189 ASSERT_TRUE(value->GetAsList(&values)); |
189 | 190 |
190 for (ListValue::iterator it = values->begin(); it != values->end(); ++it) { | 191 for (base::ListValue::iterator it = values->begin(); |
191 const DictionaryValue* dict; | 192 it != values->end(); ++it) { |
| 193 const base::DictionaryValue* dict; |
192 std::string kind; | 194 std::string kind; |
193 std::string id; | 195 std::string id; |
194 ASSERT_TRUE((*it)->GetAsDictionary(&dict)); | 196 ASSERT_TRUE((*it)->GetAsDictionary(&dict)); |
195 ASSERT_TRUE(dict->GetString("kind", &kind)); | 197 ASSERT_TRUE(dict->GetString("kind", &kind)); |
196 ASSERT_TRUE(dict->GetString("id", &id)); | 198 ASSERT_TRUE(dict->GetString("id", &id)); |
197 ASSERT_FALSE(id.empty()); | 199 ASSERT_FALSE(id.empty()); |
198 EXPECT_TRUE(kind == "audio" || kind == "video"); | 200 EXPECT_TRUE(kind == "audio" || kind == "video"); |
199 if (kind == "audio") { | 201 if (kind == "audio") { |
200 audio_ids->push_back(id); | 202 audio_ids->push_back(id); |
201 } else if (kind == "video") { | 203 } else if (kind == "video") { |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 EXPECT_TRUE(base::PathExists(dump_file)); | 890 EXPECT_TRUE(base::PathExists(dump_file)); |
889 int64 file_size = 0; | 891 int64 file_size = 0; |
890 EXPECT_TRUE(base::GetFileSize(dump_file, &file_size)); | 892 EXPECT_TRUE(base::GetFileSize(dump_file, &file_size)); |
891 EXPECT_EQ(0, file_size); | 893 EXPECT_EQ(0, file_size); |
892 | 894 |
893 base::DeleteFile(dump_file, false); | 895 base::DeleteFile(dump_file, false); |
894 } | 896 } |
895 | 897 |
896 | 898 |
897 } // namespace content | 899 } // namespace content |
OLD | NEW |