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 "content/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
6 | 6 |
| 7 #include "base/bind.h" |
7 #include "base/command_line.h" | 8 #include "base/command_line.h" |
8 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
10 #include "base/process/kill.h" | 11 #include "base/process/kill.h" |
11 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
15 #include "base/test/test_timeouts.h" | 16 #include "base/test/test_timeouts.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "content/browser/renderer_host/render_widget_host_impl.h" | 18 #include "content/browser/renderer_host/render_widget_host_impl.h" |
18 #include "content/browser/web_contents/web_contents_view.h" | 19 #include "content/browser/web_contents/web_contents_view.h" |
19 #include "content/common/input/synthetic_web_input_event_builders.h" | 20 #include "content/common/input/synthetic_web_input_event_builders.h" |
20 #include "content/public/browser/browser_context.h" | 21 #include "content/public/browser/browser_context.h" |
21 #include "content/public/browser/dom_operation_notification_details.h" | 22 #include "content/public/browser/dom_operation_notification_details.h" |
| 23 #include "content/public/browser/histogram_fetcher.h" |
22 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
24 #include "content/public/browser/render_frame_host.h" | 26 #include "content/public/browser/render_frame_host.h" |
25 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
26 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
27 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
28 #include "content/public/browser/web_contents_observer.h" | 30 #include "content/public/browser/web_contents_observer.h" |
29 #include "content/public/test/test_utils.h" | 31 #include "content/public/test/test_utils.h" |
30 #include "grit/webui_resources.h" | 32 #include "grit/webui_resources.h" |
31 #include "net/base/filename_util.h" | 33 #include "net/base/filename_util.h" |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 browser_context->GetRequestContext(); | 581 browser_context->GetRequestContext(); |
580 | 582 |
581 BrowserThread::PostTask( | 583 BrowserThread::PostTask( |
582 BrowserThread::IO, FROM_HERE, | 584 BrowserThread::IO, FROM_HERE, |
583 base::Bind(&SetCookieOnIOThread, url, value, | 585 base::Bind(&SetCookieOnIOThread, url, value, |
584 make_scoped_refptr(context_getter), &event, &result)); | 586 make_scoped_refptr(context_getter), &event, &result)); |
585 event.Wait(); | 587 event.Wait(); |
586 return result; | 588 return result; |
587 } | 589 } |
588 | 590 |
| 591 void FetchHistogramsFromChildProcesses() { |
| 592 scoped_refptr<content::MessageLoopRunner> runner = new MessageLoopRunner; |
| 593 |
| 594 FetchHistogramsAsynchronously( |
| 595 base::MessageLoop::current(), |
| 596 runner->QuitClosure(), |
| 597 // If this call times out, it means that a child process is not |
| 598 // responding, which is something we should not ignore. The timeout is |
| 599 // set to be longer than the normal browser test timeout so that it will |
| 600 // be prempted by the normal timeout. |
| 601 TestTimeouts::action_max_timeout()); |
| 602 runner->Run(); |
| 603 } |
| 604 |
589 TitleWatcher::TitleWatcher(WebContents* web_contents, | 605 TitleWatcher::TitleWatcher(WebContents* web_contents, |
590 const base::string16& expected_title) | 606 const base::string16& expected_title) |
591 : WebContentsObserver(web_contents), | 607 : WebContentsObserver(web_contents), |
592 message_loop_runner_(new MessageLoopRunner) { | 608 message_loop_runner_(new MessageLoopRunner) { |
593 EXPECT_TRUE(web_contents != NULL); | 609 EXPECT_TRUE(web_contents != NULL); |
594 expected_titles_.push_back(expected_title); | 610 expected_titles_.push_back(expected_title); |
595 } | 611 } |
596 | 612 |
597 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) { | 613 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) { |
598 expected_titles_.push_back(expected_title); | 614 expected_titles_.push_back(expected_title); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 } | 735 } |
720 // The queue should not be empty, unless we were quit because of a timeout. | 736 // The queue should not be empty, unless we were quit because of a timeout. |
721 if (message_queue_.empty()) | 737 if (message_queue_.empty()) |
722 return false; | 738 return false; |
723 *message = message_queue_.front(); | 739 *message = message_queue_.front(); |
724 message_queue_.pop(); | 740 message_queue_.pop(); |
725 return true; | 741 return true; |
726 } | 742 } |
727 | 743 |
728 } // namespace content | 744 } // namespace content |
OLD | NEW |