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

Side by Side Diff: chrome/browser/ui/webui/web_ui_test_handler.cc

Issue 8113018: [web-ui] Migrate RegisterMessageCallback usage to base::bind(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
« no previous file with comments | « chrome/browser/ui/webui/web_ui_browsertest.cc ('k') | chrome/browser/ui/webui/workers_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/web_ui_test_handler.h" 5 #include "chrome/browser/ui/webui/web_ui_test_handler.h"
6 6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
7 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
8 #include "base/values.h" 10 #include "base/values.h"
9 #include "chrome/common/render_messages.h" 11 #include "chrome/common/render_messages.h"
10 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/browser/renderer_host/render_view_host.h" 13 #include "content/browser/renderer_host/render_view_host.h"
12 #include "content/browser/tab_contents/tab_contents.h" 14 #include "content/browser/tab_contents/tab_contents.h"
13 #include "content/common/notification_details.h" 15 #include "content/common/notification_details.h"
14 #include "content/common/notification_registrar.h" 16 #include "content/common/notification_registrar.h"
15 17
16 WebUITestHandler::WebUITestHandler() 18 WebUITestHandler::WebUITestHandler()
(...skipping 23 matching lines...) Expand all
40 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); 42 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host();
41 NotificationRegistrar notification_registrar; 43 NotificationRegistrar notification_registrar;
42 notification_registrar.Add( 44 notification_registrar.Add(
43 this, content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, 45 this, content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
44 Source<RenderViewHost>(rvh)); 46 Source<RenderViewHost>(rvh));
45 rvh->ExecuteJavascriptInWebFrameNotifyResult(string16(), js_text); 47 rvh->ExecuteJavascriptInWebFrameNotifyResult(string16(), js_text);
46 return WaitForResult(); 48 return WaitForResult();
47 } 49 }
48 50
49 void WebUITestHandler::RegisterMessages() { 51 void WebUITestHandler::RegisterMessages() {
50 web_ui_->RegisterMessageCallback("testResult", NewCallback( 52 web_ui_->RegisterMessageCallback("testResult",
51 this, &WebUITestHandler::HandleTestResult)); 53 base::Bind(&WebUITestHandler::HandleTestResult, base::Unretained(this)));
52 } 54 }
53 55
54 void WebUITestHandler::HandleTestResult(const ListValue* test_result) { 56 void WebUITestHandler::HandleTestResult(const ListValue* test_result) {
55 // Quit the message loop if |is_waiting_| so waiting process can get result or 57 // Quit the message loop if |is_waiting_| so waiting process can get result or
56 // error. To ensure this gets done, do this before ASSERT* calls. 58 // error. To ensure this gets done, do this before ASSERT* calls.
57 if (is_waiting_) 59 if (is_waiting_)
58 MessageLoopForUI::current()->Quit(); 60 MessageLoopForUI::current()->Quit();
59 61
60 SCOPED_TRACE("WebUITestHandler::HandleTestResult"); 62 SCOPED_TRACE("WebUITestHandler::HandleTestResult");
61 63
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // complete. 108 // complete.
107 if (!run_test_done_ || (run_test_succeeded_ && !test_done_)) { 109 if (!run_test_done_ || (run_test_succeeded_ && !test_done_)) {
108 ui_test_utils::RunMessageLoop(); 110 ui_test_utils::RunMessageLoop();
109 } 111 }
110 112
111 is_waiting_ = false; 113 is_waiting_ = false;
112 114
113 // To succeed the test must execute as well as pass the test. 115 // To succeed the test must execute as well as pass the test.
114 return run_test_succeeded_ && test_succeeded_; 116 return run_test_succeeded_ && test_succeeded_;
115 } 117 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/web_ui_browsertest.cc ('k') | chrome/browser/ui/webui/workers_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698