OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "net/log/write_to_file_net_log_observer.h" | 5 #include "net/log/write_to_file_net_log_observer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 base::DictionaryValue* dict; | 146 base::DictionaryValue* dict; |
147 ASSERT_TRUE(root->GetAsDictionary(&dict)); | 147 ASSERT_TRUE(root->GetAsDictionary(&dict)); |
148 base::ListValue* events; | 148 base::ListValue* events; |
149 ASSERT_TRUE(dict->GetList("events", &events)); | 149 ASSERT_TRUE(dict->GetList("events", &events)); |
150 ASSERT_EQ(2u, events->GetSize()); | 150 ASSERT_EQ(2u, events->GetSize()); |
151 } | 151 } |
152 | 152 |
153 TEST_F(WriteToFileNetLogObserverTest, CustomConstants) { | 153 TEST_F(WriteToFileNetLogObserverTest, CustomConstants) { |
154 const char kConstantString[] = "awesome constant"; | 154 const char kConstantString[] = "awesome constant"; |
155 std::unique_ptr<base::Value> constants( | 155 std::unique_ptr<base::Value> constants(new base::Value(kConstantString)); |
156 new base::StringValue(kConstantString)); | |
157 base::ScopedFILE file(base::OpenFile(log_path_, "w")); | 156 base::ScopedFILE file(base::OpenFile(log_path_, "w")); |
158 ASSERT_TRUE(file); | 157 ASSERT_TRUE(file); |
159 std::unique_ptr<WriteToFileNetLogObserver> logger( | 158 std::unique_ptr<WriteToFileNetLogObserver> logger( |
160 new WriteToFileNetLogObserver()); | 159 new WriteToFileNetLogObserver()); |
161 logger->StartObserving(&net_log_, std::move(file), constants.get(), nullptr); | 160 logger->StartObserving(&net_log_, std::move(file), constants.get(), nullptr); |
162 logger->StopObserving(nullptr); | 161 logger->StopObserving(nullptr); |
163 logger.reset(); | 162 logger.reset(); |
164 | 163 |
165 std::string input; | 164 std::string input; |
166 ASSERT_TRUE(base::ReadFileToString(log_path_, &input)); | 165 ASSERT_TRUE(base::ReadFileToString(log_path_, &input)); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 ASSERT_EQ(1u, events->GetSize()); | 244 ASSERT_EQ(1u, events->GetSize()); |
246 | 245 |
247 // Make sure additional information is present, but don't validate it. | 246 // Make sure additional information is present, but don't validate it. |
248 base::DictionaryValue* tab_info; | 247 base::DictionaryValue* tab_info; |
249 ASSERT_TRUE(dict->GetDictionary("tabInfo", &tab_info)); | 248 ASSERT_TRUE(dict->GetDictionary("tabInfo", &tab_info)); |
250 } | 249 } |
251 | 250 |
252 } // namespace | 251 } // namespace |
253 | 252 |
254 } // namespace net | 253 } // namespace net |
OLD | NEW |