| OLD | NEW |
| 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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
| 11 #include "content/browser/renderer_host/render_view_host.h" | 11 #include "content/browser/renderer_host/render_view_host.h" |
| 12 #include "content/browser/tab_contents/tab_contents.h" | 12 #include "content/browser/tab_contents/tab_contents.h" |
| 13 #include "content/common/notification_details.h" | 13 #include "content/common/notification_details.h" |
| 14 #include "content/common/notification_registrar.h" | 14 #include "content/common/notification_registrar.h" |
| 15 | 15 |
| 16 WebUITestHandler::WebUITestHandler() | 16 WebUITestHandler::WebUITestHandler() |
| 17 : test_done_(false), | 17 : test_done_(false), |
| 18 test_succeeded_(false), | 18 test_succeeded_(false), |
| 19 run_test_done_(false), | 19 run_test_done_(false), |
| 20 run_test_succeeded_(false), | 20 run_test_succeeded_(false), |
| 21 is_waiting_(false) { | 21 is_waiting_(false) { |
| 22 } | 22 } |
| 23 | 23 |
| 24 void WebUITestHandler::PreloadJavaScript(const string16& js_text, | 24 void WebUITestHandler::PreloadJavaScript(const string16& js_text, |
| 25 RenderViewHost* preload_host) { | 25 RenderViewHost* preload_host) { |
| 26 DCHECK(preload_host); | 26 DCHECK(preload_host); |
| 27 preload_host->Send(new ViewMsg_WebUIJavaScript( | 27 preload_host->Send(new ChromeViewMsg_WebUIJavaScript( |
| 28 preload_host->routing_id(), string16(), js_text, 0, | 28 preload_host->routing_id(), string16(), js_text, 0, |
| 29 false)); | 29 false)); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void WebUITestHandler::RunJavaScript(const string16& js_text) { | 32 void WebUITestHandler::RunJavaScript(const string16& js_text) { |
| 33 web_ui_->tab_contents()->render_view_host()->ExecuteJavascriptInWebFrame( | 33 web_ui_->tab_contents()->render_view_host()->ExecuteJavascriptInWebFrame( |
| 34 string16(), js_text); | 34 string16(), js_text); |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool WebUITestHandler::RunJavaScriptTestWithResult(const string16& js_text) { | 37 bool WebUITestHandler::RunJavaScriptTestWithResult(const string16& js_text) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // complete. | 106 // complete. |
| 107 if (!run_test_done_ || (run_test_succeeded_ && !test_done_)) { | 107 if (!run_test_done_ || (run_test_succeeded_ && !test_done_)) { |
| 108 ui_test_utils::RunMessageLoop(); | 108 ui_test_utils::RunMessageLoop(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 is_waiting_ = false; | 111 is_waiting_ = false; |
| 112 | 112 |
| 113 // To succeed the test must execute as well as pass the test. | 113 // To succeed the test must execute as well as pass the test. |
| 114 return run_test_succeeded_ && test_succeeded_; | 114 return run_test_succeeded_ && test_succeeded_; |
| 115 } | 115 } |
| OLD | NEW |