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

Unified Diff: chrome/test/base/ui_test_utils.cc

Issue 10807047: Create content\public\test\test_utils.h to hold common test classes that are used by unit and brows… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | chrome/test/perf/rendering/throughput_tests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/ui_test_utils.cc
===================================================================
--- chrome/test/base/ui_test_utils.cc (revision 147577)
+++ chrome/test/base/ui_test_utils.cc (working copy)
@@ -65,6 +65,7 @@
#include "content/public/common/geoposition.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
+#include "content/public/test/test_utils.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
#include "net/test/python_utils.h"
@@ -104,7 +105,7 @@
did_respond_(false) {
registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE,
content::Source<RenderViewHost>(render_view_host));
- message_loop_runner_ = new MessageLoopRunner;
+ message_loop_runner_ = new content::MessageLoopRunner;
}
virtual void Observe(int type,
@@ -132,7 +133,7 @@
content::NotificationRegistrar registrar_;
std::string response_;
bool did_respond_;
- scoped_refptr<MessageLoopRunner> message_loop_runner_;
+ scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
DISALLOW_COPY_AND_ASSIGN(DOMOperationObserver);
};
@@ -147,7 +148,7 @@
parent_tab->find_tab_helper()->current_find_request_id();
registrar_.Add(this, chrome::NOTIFICATION_FIND_RESULT_AVAILABLE,
content::Source<WebContents>(parent_tab_->web_contents()));
- message_loop_runner_ = new MessageLoopRunner;
+ message_loop_runner_ = new content::MessageLoopRunner;
message_loop_runner_->Run();
}
@@ -186,7 +187,7 @@
// The id of the current find request, obtained from WebContents. Allows us
// to monitor when the search completes.
int current_find_request_id_;
- scoped_refptr<MessageLoopRunner> message_loop_runner_;
+ scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
DISALLOW_COPY_AND_ASSIGN(FindInPageNotificationObserver);
};
@@ -327,14 +328,14 @@
}
void WaitForNewTab(Browser* browser) {
- WindowedNotificationObserver observer(
+ content::WindowedNotificationObserver observer(
chrome::NOTIFICATION_TAB_ADDED,
content::Source<content::WebContentsDelegate>(browser));
observer.Wait();
}
void WaitForLoadStop(WebContents* tab) {
- WindowedNotificationObserver load_stop_observer(
+ content::WindowedNotificationObserver load_stop_observer(
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(&tab->GetController()));
// In many cases, the load may have finished before we get here. Only wait if
@@ -406,11 +407,11 @@
initial_browsers.insert(*iter);
}
- WindowedNotificationObserver tab_added_observer(
+ content::WindowedNotificationObserver tab_added_observer(
chrome::NOTIFICATION_TAB_ADDED,
content::NotificationService::AllSources());
- WindowedNotificationObserver auth_observer(
+ content::WindowedNotificationObserver auth_observer(
chrome::NOTIFICATION_AUTH_NEEDED,
content::NotificationService::AllSources());
@@ -558,7 +559,7 @@
}
AppModalDialog* WaitForAppModalDialog() {
- WindowedNotificationObserver observer(
+ content::WindowedNotificationObserver observer(
chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN,
content::NotificationService::AllSources());
observer.Wait();
@@ -572,7 +573,7 @@
void CrashTab(WebContents* tab) {
content::RenderProcessHost* rph = tab->GetRenderProcessHost();
- WindowedNotificationObserver observer(
+ content::WindowedNotificationObserver observer(
content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
content::Source<content::RenderProcessHost>(rph));
base::KillProcess(rph->GetHandle(), 0, false);
@@ -712,7 +713,7 @@
}
void WaitForHistoryToLoad(HistoryService* history_service) {
- WindowedNotificationObserver history_loaded_observer(
+ content::WindowedNotificationObserver history_loaded_observer(
chrome::NOTIFICATION_HISTORY_LOADED,
content::NotificationService::AllSources());
if (!history_service->BackendLoaded())
@@ -756,7 +757,8 @@
gfx::NativeWindow window = NULL;
if (!GetNativeWindow(browser, &window))
return false;
- scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner;
+ scoped_refptr<content::MessageLoopRunner> runner =
+ new content::MessageLoopRunner;
bool result;
result = ui_controls::SendKeyPressNotifyWhenDone(
window, key, control, shift, alt, command, runner->QuitClosure());
@@ -786,7 +788,7 @@
bool command,
int type,
const content::NotificationSource& source) {
- WindowedNotificationObserver observer(type, source);
+ content::WindowedNotificationObserver observer(type, source);
if (!SendKeyPressSync(browser, key, control, shift, alt, command))
return false;
@@ -796,7 +798,8 @@
}
bool SendMouseMoveSync(const gfx::Point& location) {
- scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner;
+ scoped_refptr<content::MessageLoopRunner> runner =
+ new content::MessageLoopRunner;
if (!ui_controls::SendMouseMoveNotifyWhenDone(
location.x(), location.y(), runner->QuitClosure())) {
return false;
@@ -806,7 +809,8 @@
}
bool SendMouseEventsSync(ui_controls::MouseButton type, int state) {
- scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner;
+ scoped_refptr<content::MessageLoopRunner> runner =
+ new content::MessageLoopRunner;
if (!ui_controls::SendMouseEventsNotifyWhenDone(
type, state, runner->QuitClosure())) {
return false;
@@ -815,24 +819,6 @@
return !testing::Test::HasFatalFailure();
}
-MessageLoopRunner::MessageLoopRunner() {
-}
-
-MessageLoopRunner::~MessageLoopRunner() {
-}
-
-void MessageLoopRunner::Run() {
- content::RunThisRunLoop(&run_loop_);
-}
-
-base::Closure MessageLoopRunner::QuitClosure() {
- return base::Bind(&MessageLoopRunner::Quit, this);
-}
-
-void MessageLoopRunner::Quit() {
- content::GetQuitTaskForRunLoop(&run_loop_).Run();
-}
-
TestWebSocketServer::TestWebSocketServer()
: started_(false),
port_(kDefaultWsPort),
@@ -979,41 +965,6 @@
#endif
}
-WindowedNotificationObserver::WindowedNotificationObserver(
- int notification_type,
- const content::NotificationSource& source)
- : seen_(false),
- running_(false),
- source_(content::NotificationService::AllSources()) {
- registrar_.Add(this, notification_type, source);
-}
-
-WindowedNotificationObserver::~WindowedNotificationObserver() {}
-
-void WindowedNotificationObserver::Wait() {
- if (seen_)
- return;
-
- running_ = true;
- message_loop_runner_ = new MessageLoopRunner;
- message_loop_runner_->Run();
- EXPECT_TRUE(seen_);
-}
-
-void WindowedNotificationObserver::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- source_ = source;
- details_ = details;
- seen_ = true;
- if (!running_)
- return;
-
- message_loop_runner_->Quit();
- running_ = false;
-}
-
WindowedTabAddedNotificationObserver::WindowedTabAddedNotificationObserver(
const content::NotificationSource& source)
: WindowedNotificationObserver(chrome::NOTIFICATION_TAB_ADDED, source),
@@ -1024,8 +975,8 @@
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- added_tab_ = content::Details<content::WebContents>(details).ptr();
- WindowedNotificationObserver::Observe(type, source, details);
+ added_tab_ = content::Details<WebContents>(details).ptr();
+ content::WindowedNotificationObserver::Observe(type, source, details);
}
TitleWatcher::TitleWatcher(WebContents* web_contents,
@@ -1061,7 +1012,7 @@
if (expected_title_observed_)
return observed_title_;
quit_loop_on_observation_ = true;
- message_loop_runner_ = new MessageLoopRunner;
+ message_loop_runner_ = new content::MessageLoopRunner;
message_loop_runner_->Run();
return observed_title_;
}
@@ -1139,7 +1090,7 @@
if (message_queue_.empty()) {
waiting_for_message_ = true;
// This will be quit when a new message comes in.
- message_loop_runner_ = new MessageLoopRunner;
+ message_loop_runner_ = new content::MessageLoopRunner;
message_loop_runner_->Run();
}
// The queue should not be empty, unless we were quit because of a timeout.
@@ -1168,7 +1119,7 @@
base::Bind(&SnapshotTaker::OnSnapshotTaken, base::Unretained(this)),
page_size,
desired_size);
- message_loop_runner_ = new MessageLoopRunner;
+ message_loop_runner_ = new content::MessageLoopRunner;
message_loop_runner_->Run();
return snapshot_taken_;
}
@@ -1211,7 +1162,7 @@
// Whether the snapshot was actually taken and received by this SnapshotTaker.
// This will be false if the test times out.
bool snapshot_taken_;
- scoped_refptr<MessageLoopRunner> message_loop_runner_;
+ scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
DISALLOW_COPY_AND_ASSIGN(SnapshotTaker);
};
@@ -1237,7 +1188,8 @@
position.altitude = 0.;
position.accuracy = 0.;
position.timestamp = base::Time::Now();
- scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner;
+ scoped_refptr<content::MessageLoopRunner> runner =
+ new content::MessageLoopRunner;
content::OverrideLocationForTesting(position, runner->QuitClosure());
runner->Run();
}
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | chrome/test/perf/rendering/throughput_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698