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

Side by Side Diff: content/public/test/javascript_test_observer.h

Issue 286243003: Move JavascriptTestObserver from chrome to content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « content/content_tests.gypi ('k') | content/public/test/javascript_test_observer.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_TEST_BASE_JAVASCRIPT_TEST_OBSERVER_H_ 5 #ifndef CONTENT_PUBLIC_TEST_JAVASCRIPT_TEST_OBSERVER_H_
6 #define CHROME_TEST_BASE_JAVASCRIPT_TEST_OBSERVER_H_ 6 #define CONTENT_PUBLIC_TEST_JAVASCRIPT_TEST_OBSERVER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "content/public/browser/notification_observer.h" 11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h" 12 #include "content/public/browser/notification_registrar.h"
13 13
14 namespace base { 14 namespace base {
15 class DictionaryValue; 15 class DictionaryValue;
16 } 16 }
17 17
18 namespace content { 18 namespace content {
19 class WebContents; 19 class WebContents;
20 }
21 20
22 // Base class for handling a stream of automation messages produced by a 21 // Base class for handling a stream of automation messages produced by a
23 // JavascriptTestObserver. 22 // JavascriptTestObserver.
24 class TestMessageHandler { 23 class TestMessageHandler {
25 public: 24 public:
26 enum MessageResponse { 25 enum MessageResponse {
27 // Reset the timeout and keep running. 26 // Reset the timeout and keep running.
28 CONTINUE, 27 CONTINUE,
29 // Stop runnning. 28 // Stop runnning.
30 DONE 29 DONE
(...skipping 18 matching lines...) Expand all
49 // Prepare the handler to be used or reused. 48 // Prepare the handler to be used or reused.
50 virtual void Reset(); 49 virtual void Reset();
51 50
52 private: 51 private:
53 bool ok_; 52 bool ok_;
54 std::string error_message_; 53 std::string error_message_;
55 }; 54 };
56 55
57 // This class captures a stream of automation messages coming from a Javascript 56 // This class captures a stream of automation messages coming from a Javascript
58 // test and dispatches them to a message handler. 57 // test and dispatches them to a message handler.
59 class JavascriptTestObserver : public content::NotificationObserver { 58 class JavascriptTestObserver : public content::NotificationObserver {
jam 2014/05/16 17:56:36 nit: here and below, and in the cc file, remove "c
60 public: 59 public:
61 // The observer does not own any arguments passed to it. It is assumed that 60 // The observer does not own any arguments passed to it. It is assumed that
62 // the arguments will outlive all uses of the observer. 61 // the arguments will outlive all uses of the observer.
63 JavascriptTestObserver( 62 JavascriptTestObserver(WebContents* web_contents,
64 content::WebContents* web_contents, 63 TestMessageHandler* handler);
65 TestMessageHandler* handler);
66 64
67 virtual ~JavascriptTestObserver(); 65 virtual ~JavascriptTestObserver();
68 66
69 // Pump the message loop until the message handler indicates the Javascript 67 // Pump the message loop until the message handler indicates the Javascript
70 // test is done running. Return true if the test jig functioned correctly and 68 // test is done running. Return true if the test jig functioned correctly and
71 // nothing timed out. 69 // nothing timed out.
72 bool Run(); 70 bool Run();
73 71
74 // Prepare the observer to be used again. This method should NOT be called 72 // Prepare the observer to be used again. This method should NOT be called
75 // while Run() is pumping the message loop. 73 // while Run() is pumping the message loop.
(...skipping 12 matching lines...) Expand all
88 void EndTest(); 86 void EndTest();
89 87
90 TestMessageHandler* handler_; 88 TestMessageHandler* handler_;
91 bool running_; 89 bool running_;
92 bool finished_; 90 bool finished_;
93 content::NotificationRegistrar registrar_; 91 content::NotificationRegistrar registrar_;
94 92
95 DISALLOW_COPY_AND_ASSIGN(JavascriptTestObserver); 93 DISALLOW_COPY_AND_ASSIGN(JavascriptTestObserver);
96 }; 94 };
97 95
98 #endif // CHROME_TEST_BASE_JAVASCRIPT_TEST_OBSERVER_H_ 96 } // namespace content
97
98 #endif // CONTENT_PUBLIC_TEST_JAVASCRIPT_TEST_OBSERVER_H_
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | content/public/test/javascript_test_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698