OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/test/chromedriver/chrome/performance_logger.h" | 5 #include "chrome/test/chromedriver/chrome/performance_logger.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 96 } |
97 | 97 |
98 scoped_ptr<DictionaryValue> ParseDictionary(const std::string& json) { | 98 scoped_ptr<DictionaryValue> ParseDictionary(const std::string& json) { |
99 std::string error; | 99 std::string error; |
100 scoped_ptr<Value> value(base::JSONReader::ReadAndReturnError( | 100 scoped_ptr<Value> value(base::JSONReader::ReadAndReturnError( |
101 json, base::JSON_PARSE_RFC, NULL, &error)); | 101 json, base::JSON_PARSE_RFC, NULL, &error)); |
102 if (value == NULL) { | 102 if (value == NULL) { |
103 SCOPED_TRACE(json.c_str()); | 103 SCOPED_TRACE(json.c_str()); |
104 SCOPED_TRACE(error.c_str()); | 104 SCOPED_TRACE(error.c_str()); |
105 ADD_FAILURE(); | 105 ADD_FAILURE(); |
106 return scoped_ptr<DictionaryValue>(NULL); | 106 return scoped_ptr<DictionaryValue>(); |
107 } | 107 } |
108 DictionaryValue* dict = NULL; | 108 DictionaryValue* dict = NULL; |
109 if (!value->GetAsDictionary(&dict)) { | 109 if (!value->GetAsDictionary(&dict)) { |
110 SCOPED_TRACE("JSON object is not a dictionary"); | 110 SCOPED_TRACE("JSON object is not a dictionary"); |
111 ADD_FAILURE(); | 111 ADD_FAILURE(); |
112 return scoped_ptr<DictionaryValue>(NULL); | 112 return scoped_ptr<DictionaryValue>(); |
113 } | 113 } |
114 return scoped_ptr<DictionaryValue>(dict->DeepCopy()); | 114 return scoped_ptr<DictionaryValue>(dict->DeepCopy()); |
115 } | 115 } |
116 | 116 |
117 void ValidateLogEntry(const LogEntry *entry, | 117 void ValidateLogEntry(const LogEntry *entry, |
118 const std::string& expected_webview, | 118 const std::string& expected_webview, |
119 const std::string& expected_method) { | 119 const std::string& expected_method) { |
120 EXPECT_EQ(Log::kLog, entry->level); | 120 EXPECT_EQ(Log::kLog, entry->level); |
121 EXPECT_LT(0, entry->timestamp.ToTimeT()); | 121 EXPECT_LT(0, entry->timestamp.ToTimeT()); |
122 | 122 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 ExpectEnableDomains(client1); | 176 ExpectEnableDomains(client1); |
177 EXPECT_TRUE(client2.PopSentCommand().empty());; | 177 EXPECT_TRUE(client2.PopSentCommand().empty());; |
178 | 178 |
179 ASSERT_EQ(kOk, client1.TriggerEvent("Page.gaga1").code()); | 179 ASSERT_EQ(kOk, client1.TriggerEvent("Page.gaga1").code()); |
180 ASSERT_EQ(kOk, client2.TriggerEvent("Timeline.gaga2").code()); | 180 ASSERT_EQ(kOk, client2.TriggerEvent("Timeline.gaga2").code()); |
181 | 181 |
182 ASSERT_EQ(2u, log.GetEntries().size()); | 182 ASSERT_EQ(2u, log.GetEntries().size()); |
183 ValidateLogEntry(log.GetEntries()[0], "webview-1", "Page.gaga1"); | 183 ValidateLogEntry(log.GetEntries()[0], "webview-1", "Page.gaga1"); |
184 ValidateLogEntry(log.GetEntries()[1], "webview-2", "Timeline.gaga2"); | 184 ValidateLogEntry(log.GetEntries()[1], "webview-2", "Timeline.gaga2"); |
185 } | 185 } |
OLD | NEW |