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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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
« no previous file with comments | « chrome/browser/ui/webui/web_ui_test_handler.h ('k') | chrome/browser/upgrade_detector.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/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/test/ui_test_utils.h" 9 #include "chrome/test/ui_test_utils.h"
10 #include "content/browser/renderer_host/render_view_host.h" 10 #include "content/browser/renderer_host/render_view_host.h"
11 #include "content/common/notification_details.h" 11 #include "content/common/notification_details.h"
12 #include "content/common/notification_registrar.h" 12 #include "content/common/notification_registrar.h"
13 13
14 bool WebUITestHandler::RunJavascript(const std::string& js_test, bool is_test) { 14 bool WebUITestHandler::RunJavascript(const std::string& js_test, bool is_test) {
15 if (is_test) { 15 if (is_test) {
16 NotificationRegistrar notification_registrar; 16 NotificationRegistrar notification_registrar;
17 notification_registrar.Add( 17 notification_registrar.Add(
18 this, NotificationType::EXECUTE_JAVASCRIPT_RESULT, 18 this, content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
19 Source<RenderViewHost>(web_ui_->GetRenderViewHost())); 19 Source<RenderViewHost>(web_ui_->GetRenderViewHost()));
20 web_ui_->GetRenderViewHost()->ExecuteJavascriptInWebFrameNotifyResult( 20 web_ui_->GetRenderViewHost()->ExecuteJavascriptInWebFrameNotifyResult(
21 string16(), UTF8ToUTF16(js_test)); 21 string16(), UTF8ToUTF16(js_test));
22 return WaitForResult(); 22 return WaitForResult();
23 } else { 23 } else {
24 web_ui_->GetRenderViewHost()->ExecuteJavascriptInWebFrame( 24 web_ui_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(
25 string16(), UTF8ToUTF16(js_test)); 25 string16(), UTF8ToUTF16(js_test));
26 return true; 26 return true;
27 } 27 }
28 } 28 }
29 29
30 void WebUITestHandler::Observe(NotificationType type, 30 void WebUITestHandler::Observe(int type,
31 const NotificationSource& source, 31 const NotificationSource& source,
32 const NotificationDetails& details) { 32 const NotificationDetails& details) {
33 // Quit the message loop if we were waiting so Waiting process can get result 33 // Quit the message loop if we were waiting so Waiting process can get result
34 // or error. To ensure this gets done, do this before ASSERT* calls. 34 // or error. To ensure this gets done, do this before ASSERT* calls.
35 if (is_waiting_) 35 if (is_waiting_)
36 MessageLoopForUI::current()->Quit(); 36 MessageLoopForUI::current()->Quit();
37 37
38 SCOPED_TRACE("WebUITestHandler::Observe"); 38 SCOPED_TRACE("WebUITestHandler::Observe");
39 Value* value = Details<std::pair<int, Value*> >(details)->second; 39 Value* value = Details<std::pair<int, Value*> >(details)->second;
40 ListValue* list_value; 40 ListValue* list_value;
41 ASSERT_TRUE(value->GetAsList(&list_value)); 41 ASSERT_TRUE(value->GetAsList(&list_value));
42 ASSERT_TRUE(list_value->GetBoolean(0, &test_succeeded_)); 42 ASSERT_TRUE(list_value->GetBoolean(0, &test_succeeded_));
43 if (!test_succeeded_) { 43 if (!test_succeeded_) {
44 std::string message; 44 std::string message;
45 ASSERT_TRUE(list_value->GetString(1, &message)); 45 ASSERT_TRUE(list_value->GetString(1, &message));
46 LOG(ERROR) << message; 46 LOG(ERROR) << message;
47 } 47 }
48 } 48 }
49 49
50 bool WebUITestHandler::WaitForResult() { 50 bool WebUITestHandler::WaitForResult() {
51 is_waiting_ = true; 51 is_waiting_ = true;
52 ui_test_utils::RunMessageLoop(); 52 ui_test_utils::RunMessageLoop();
53 is_waiting_ = false; 53 is_waiting_ = false;
54 return test_succeeded_; 54 return test_succeeded_;
55 } 55 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/web_ui_test_handler.h ('k') | chrome/browser/upgrade_detector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698