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

Side by Side Diff: chrome/test/base/javascript_test_observer.cc

Issue 157713002: Switch DomAutomationController to be a RenderFrameObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nasko@ CR feedback Created 6 years, 10 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) 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/test/base/javascript_test_observer.h" 5 #include "chrome/test/base/javascript_test_observer.h"
6 6
7 #include "content/public/browser/dom_operation_notification_details.h" 7 #include "content/public/browser/dom_operation_notification_details.h"
8 #include "content/public/browser/notification_types.h" 8 #include "content/public/browser/notification_types.h"
9 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/web_contents.h"
10 #include "content/public/test/test_utils.h" 11 #include "content/public/test/test_utils.h"
11 12
12 TestMessageHandler::TestMessageHandler() : ok_(true) { 13 TestMessageHandler::TestMessageHandler() : ok_(true) {
13 } 14 }
14 15
15 TestMessageHandler::~TestMessageHandler() { 16 TestMessageHandler::~TestMessageHandler() {
16 } 17 }
17 18
18 void TestMessageHandler::SetError(const std::string& message) { 19 void TestMessageHandler::SetError(const std::string& message) {
19 ok_ = false; 20 ok_ = false;
20 error_message_ = message; 21 error_message_ = message;
21 } 22 }
22 23
23 void TestMessageHandler::Reset() { 24 void TestMessageHandler::Reset() {
24 ok_ = true; 25 ok_ = true;
25 error_message_.clear(); 26 error_message_.clear();
26 } 27 }
27 28
28 JavascriptTestObserver::JavascriptTestObserver( 29 JavascriptTestObserver::JavascriptTestObserver(
29 content::RenderViewHost* render_view_host, 30 content::WebContents* web_contents,
30 TestMessageHandler* handler) 31 TestMessageHandler* handler)
31 : handler_(handler), 32 : handler_(handler),
32 running_(false), 33 running_(false),
33 finished_(false) { 34 finished_(false) {
34 Reset(); 35 Reset();
35 registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE, 36 registrar_.Add(this,
36 content::Source<content::RenderViewHost>(render_view_host)); 37 content::NOTIFICATION_DOM_OPERATION_RESPONSE,
38 content::Source<content::WebContents>(web_contents));
37 } 39 }
38 40
39 JavascriptTestObserver::~JavascriptTestObserver() { 41 JavascriptTestObserver::~JavascriptTestObserver() {
40 } 42 }
41 43
42 bool JavascriptTestObserver::Run() { 44 bool JavascriptTestObserver::Run() {
43 // Messages may have arrived before Run was called. 45 // Messages may have arrived before Run was called.
44 if (!finished_) { 46 if (!finished_) {
45 CHECK(!running_); 47 CHECK(!running_);
46 running_ = true; 48 running_ = true;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 void JavascriptTestObserver::Continue() { 81 void JavascriptTestObserver::Continue() {
80 } 82 }
81 83
82 void JavascriptTestObserver::EndTest() { 84 void JavascriptTestObserver::EndTest() {
83 finished_ = true; 85 finished_ = true;
84 if (running_) { 86 if (running_) {
85 running_ = false; 87 running_ = false;
86 base::MessageLoopForUI::current()->Quit(); 88 base::MessageLoopForUI::current()->Quit();
87 } 89 }
88 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698