Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 379283002: Rework UMAHistogramHelper and StatisticsDeltaReader into [Chrome]HistogramTester. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove the ChromeHistogramHelper Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 FetchHistogramsData() {
600 scoped_refptr<content::MessageLoopRunner> runner =
601 new content::MessageLoopRunner;
602
603 content::FetchHistogramsAsynchronously(
Ilya Sherman 2014/07/17 18:35:09 nit: No need for the "content::" namespace prefix
Mike Lerman 2014/07/18 13:58:23 Done.
604 base::MessageLoop::current(),
605 runner->QuitClosure(),
606 // If this call times out, it means that a child process is not
607 // responding, which is something we should not ignore. The timeout is
608 // set to be longer than the normal browser test timeout so that it will
609 // be prempted by the normal timeout.
610 TestTimeouts::action_max_timeout() * 2);
611 runner->Run();
612 }
613
597 TitleWatcher::TitleWatcher(WebContents* web_contents, 614 TitleWatcher::TitleWatcher(WebContents* web_contents,
598 const base::string16& expected_title) 615 const base::string16& expected_title)
599 : WebContentsObserver(web_contents), 616 : WebContentsObserver(web_contents),
600 message_loop_runner_(new MessageLoopRunner) { 617 message_loop_runner_(new MessageLoopRunner) {
601 EXPECT_TRUE(web_contents != NULL); 618 EXPECT_TRUE(web_contents != NULL);
602 expected_titles_.push_back(expected_title); 619 expected_titles_.push_back(expected_title);
603 } 620 }
604 621
605 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) { 622 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) {
606 expected_titles_.push_back(expected_title); 623 expected_titles_.push_back(expected_title);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 } 744 }
728 // The queue should not be empty, unless we were quit because of a timeout. 745 // The queue should not be empty, unless we were quit because of a timeout.
729 if (message_queue_.empty()) 746 if (message_queue_.empty())
730 return false; 747 return false;
731 *message = message_queue_.front(); 748 *message = message_queue_.front();
732 message_queue_.pop(); 749 message_queue_.pop();
733 return true; 750 return true;
734 } 751 }
735 752
736 } // namespace content 753 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698