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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 browser_context->GetRequestContext(); | 589 browser_context->GetRequestContext(); |
588 | 590 |
589 BrowserThread::PostTask( | 591 BrowserThread::PostTask( |
590 BrowserThread::IO, FROM_HERE, | 592 BrowserThread::IO, FROM_HERE, |
591 base::Bind(&SetCookieOnIOThread, url, value, | 593 base::Bind(&SetCookieOnIOThread, url, value, |
592 make_scoped_refptr(context_getter), &event, &result)); | 594 make_scoped_refptr(context_getter), &event, &result)); |
593 event.Wait(); | 595 event.Wait(); |
594 return result; | 596 return result; |
595 } | 597 } |
596 | 598 |
599 void FetchHistogramsFromChildProcesses() { | |
600 scoped_refptr<content::MessageLoopRunner> runner = new MessageLoopRunner; | |
601 | |
602 FetchHistogramsAsynchronously( | |
603 base::MessageLoop::current(), | |
604 runner->QuitClosure(), | |
605 // If this call times out, it means that a child process is not | |
606 // responding, which is something we should not ignore. The timeout is | |
607 // set to be longer than the normal browser test timeout so that it will | |
608 // be prempted by the normal timeout. | |
609 TestTimeouts::action_max_timeout() * 2); | |
Paweł Hajdan Jr.
2014/07/23 10:50:58
The timeouts returned by TestTimeout should not be
Ilya Sherman
2014/07/23 17:25:11
What is your objection to multiplying the timeout?
brettw
2014/08/04 05:45:49
I agree with Pawel. We shouldn't have arbitrary ti
| |
610 runner->Run(); | |
611 } | |
612 | |
597 TitleWatcher::TitleWatcher(WebContents* web_contents, | 613 TitleWatcher::TitleWatcher(WebContents* web_contents, |
598 const base::string16& expected_title) | 614 const base::string16& expected_title) |
599 : WebContentsObserver(web_contents), | 615 : WebContentsObserver(web_contents), |
600 message_loop_runner_(new MessageLoopRunner) { | 616 message_loop_runner_(new MessageLoopRunner) { |
601 EXPECT_TRUE(web_contents != NULL); | 617 EXPECT_TRUE(web_contents != NULL); |
602 expected_titles_.push_back(expected_title); | 618 expected_titles_.push_back(expected_title); |
603 } | 619 } |
604 | 620 |
605 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) { | 621 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) { |
606 expected_titles_.push_back(expected_title); | 622 expected_titles_.push_back(expected_title); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
727 } | 743 } |
728 // The queue should not be empty, unless we were quit because of a timeout. | 744 // The queue should not be empty, unless we were quit because of a timeout. |
729 if (message_queue_.empty()) | 745 if (message_queue_.empty()) |
730 return false; | 746 return false; |
731 *message = message_queue_.front(); | 747 *message = message_queue_.front(); |
732 message_queue_.pop(); | 748 message_queue_.pop(); |
733 return true; | 749 return true; |
734 } | 750 } |
735 | 751 |
736 } // namespace content | 752 } // namespace content |
OLD | NEW |