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 "chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h" | 5 #include "chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 base::Value* value) { | 193 base::Value* value) { |
194 web_ui()->CallJavascriptFunctionUnsafe("NetInternalsTest.callback", *value); | 194 web_ui()->CallJavascriptFunctionUnsafe("NetInternalsTest.callback", *value); |
195 } | 195 } |
196 | 196 |
197 void NetInternalsTest::MessageHandler::GetTestServerURL( | 197 void NetInternalsTest::MessageHandler::GetTestServerURL( |
198 const base::ListValue* list_value) { | 198 const base::ListValue* list_value) { |
199 ASSERT_TRUE(net_internals_test_->StartTestServer()); | 199 ASSERT_TRUE(net_internals_test_->StartTestServer()); |
200 std::string path; | 200 std::string path; |
201 ASSERT_TRUE(list_value->GetString(0, &path)); | 201 ASSERT_TRUE(list_value->GetString(0, &path)); |
202 GURL url = net_internals_test_->embedded_test_server()->GetURL(path); | 202 GURL url = net_internals_test_->embedded_test_server()->GetURL(path); |
203 std::unique_ptr<base::Value> url_value(new base::StringValue(url.spec())); | 203 std::unique_ptr<base::Value> url_value(new base::Value(url.spec())); |
204 RunJavascriptCallback(url_value.get()); | 204 RunJavascriptCallback(url_value.get()); |
205 } | 205 } |
206 | 206 |
207 void NetInternalsTest::MessageHandler::AddCacheEntry( | 207 void NetInternalsTest::MessageHandler::AddCacheEntry( |
208 const base::ListValue* list_value) { | 208 const base::ListValue* list_value) { |
209 std::string hostname; | 209 std::string hostname; |
210 std::string ip_literal; | 210 std::string ip_literal; |
211 double net_error; | 211 double net_error; |
212 double expire_days_from_now; | 212 double expire_days_from_now; |
213 ASSERT_TRUE(list_value->GetString(0, &hostname)); | 213 ASSERT_TRUE(list_value->GetString(0, &hostname)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 frame->ExecuteJavaScriptForTests( | 254 frame->ExecuteJavaScriptForTests( |
255 base::ASCIIToUTF16(base::StringPrintf("Click('%s')", url.c_str()))); | 255 base::ASCIIToUTF16(base::StringPrintf("Click('%s')", url.c_str()))); |
256 } | 256 } |
257 | 257 |
258 void NetInternalsTest::MessageHandler::CreateIncognitoBrowser( | 258 void NetInternalsTest::MessageHandler::CreateIncognitoBrowser( |
259 const base::ListValue* list_value) { | 259 const base::ListValue* list_value) { |
260 ASSERT_FALSE(incognito_browser_); | 260 ASSERT_FALSE(incognito_browser_); |
261 incognito_browser_ = net_internals_test_->CreateIncognitoBrowser(); | 261 incognito_browser_ = net_internals_test_->CreateIncognitoBrowser(); |
262 | 262 |
263 // Tell the test harness that creation is complete. | 263 // Tell the test harness that creation is complete. |
264 base::StringValue command_value("onIncognitoBrowserCreatedForTest"); | 264 base::Value command_value("onIncognitoBrowserCreatedForTest"); |
265 web_ui()->CallJavascriptFunctionUnsafe("g_browser.receive", command_value); | 265 web_ui()->CallJavascriptFunctionUnsafe("g_browser.receive", command_value); |
266 } | 266 } |
267 | 267 |
268 void NetInternalsTest::MessageHandler::CloseIncognitoBrowser( | 268 void NetInternalsTest::MessageHandler::CloseIncognitoBrowser( |
269 const base::ListValue* list_value) { | 269 const base::ListValue* list_value) { |
270 ASSERT_TRUE(incognito_browser_); | 270 ASSERT_TRUE(incognito_browser_); |
271 incognito_browser_->tab_strip_model()->CloseAllTabs(); | 271 incognito_browser_->tab_strip_model()->CloseAllTabs(); |
272 // Closing all a Browser's tabs will ultimately result in its destruction, | 272 // Closing all a Browser's tabs will ultimately result in its destruction, |
273 // thought it may not have been destroyed yet. | 273 // thought it may not have been destroyed yet. |
274 incognito_browser_ = NULL; | 274 incognito_browser_ = NULL; |
(...skipping 23 matching lines...) Expand all Loading... |
298 g_browser_process->net_log(), net::NetLogSourceType::URL_REQUEST); | 298 g_browser_process->net_log(), net::NetLogSourceType::URL_REQUEST); |
299 net_log_with_source.BeginEvent(net::NetLogEventType::REQUEST_ALIVE); | 299 net_log_with_source.BeginEvent(net::NetLogEventType::REQUEST_ALIVE); |
300 net_log_logger->StopObserving(nullptr); | 300 net_log_logger->StopObserving(nullptr); |
301 net_log_logger.reset(); | 301 net_log_logger.reset(); |
302 | 302 |
303 std::string log_contents; | 303 std::string log_contents; |
304 ASSERT_TRUE(base::ReadFileToString(temp_file, &log_contents)); | 304 ASSERT_TRUE(base::ReadFileToString(temp_file, &log_contents)); |
305 ASSERT_GT(log_contents.length(), 0u); | 305 ASSERT_GT(log_contents.length(), 0u); |
306 | 306 |
307 std::unique_ptr<base::Value> log_contents_value( | 307 std::unique_ptr<base::Value> log_contents_value( |
308 new base::StringValue(log_contents)); | 308 new base::Value(log_contents)); |
309 RunJavascriptCallback(log_contents_value.get()); | 309 RunJavascriptCallback(log_contents_value.get()); |
310 } | 310 } |
311 | 311 |
312 void NetInternalsTest::MessageHandler::EnableDataReductionProxy( | 312 void NetInternalsTest::MessageHandler::EnableDataReductionProxy( |
313 const base::ListValue* list_value) { | 313 const base::ListValue* list_value) { |
314 bool enable; | 314 bool enable; |
315 ASSERT_TRUE(list_value->GetBoolean(0, &enable)); | 315 ASSERT_TRUE(list_value->GetBoolean(0, &enable)); |
316 browser()->profile()->GetPrefs()->SetBoolean( | 316 browser()->profile()->GetPrefs()->SetBoolean( |
317 prefs::kDataSaverEnabled, enable); | 317 prefs::kDataSaverEnabled, enable); |
318 } | 318 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 if (test_server_started_) | 363 if (test_server_started_) |
364 return true; | 364 return true; |
365 test_server_started_ = embedded_test_server()->Start(); | 365 test_server_started_ = embedded_test_server()->Start(); |
366 | 366 |
367 // Sample domain for SDCH-view test. Dictionaries for localhost/127.0.0.1 | 367 // Sample domain for SDCH-view test. Dictionaries for localhost/127.0.0.1 |
368 // are forbidden. | 368 // are forbidden. |
369 host_resolver()->AddRule("testdomain.com", "127.0.0.1"); | 369 host_resolver()->AddRule("testdomain.com", "127.0.0.1"); |
370 host_resolver()->AddRule("sub.testdomain.com", "127.0.0.1"); | 370 host_resolver()->AddRule("sub.testdomain.com", "127.0.0.1"); |
371 return test_server_started_; | 371 return test_server_started_; |
372 } | 372 } |
OLD | NEW |