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

Unified Diff: chrome/test/base/javascript_test_observer.h

Issue 286243003: Move JavascriptTestObserver from chrome to content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unnecessary content prefixes 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | chrome/test/base/javascript_test_observer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/javascript_test_observer.h
diff --git a/chrome/test/base/javascript_test_observer.h b/chrome/test/base/javascript_test_observer.h
deleted file mode 100644
index a35ea92e4f9e083b86e8fb8ddda4ddb019158f2f..0000000000000000000000000000000000000000
--- a/chrome/test/base/javascript_test_observer.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_TEST_BASE_JAVASCRIPT_TEST_OBSERVER_H_
-#define CHROME_TEST_BASE_JAVASCRIPT_TEST_OBSERVER_H_
-
-#include <string>
-
-#include "base/compiler_specific.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
-
-namespace base {
-class DictionaryValue;
-}
-
-namespace content {
-class WebContents;
-}
-
-// Base class for handling a stream of automation messages produced by a
-// JavascriptTestObserver.
-class TestMessageHandler {
- public:
- enum MessageResponse {
- // Reset the timeout and keep running.
- CONTINUE,
- // Stop runnning.
- DONE
- };
-
- TestMessageHandler();
- virtual ~TestMessageHandler();
-
- // Called when a message is received from the DOM automation controller.
- virtual MessageResponse HandleMessage(const std::string& json) = 0;
-
- void SetError(const std::string& message);
-
- bool ok() const {
- return ok_;
- }
-
- const std::string& error_message() const {
- return error_message_;
- }
-
- // Prepare the handler to be used or reused.
- virtual void Reset();
-
- private:
- bool ok_;
- std::string error_message_;
-};
-
-// This class captures a stream of automation messages coming from a Javascript
-// test and dispatches them to a message handler.
-class JavascriptTestObserver : public content::NotificationObserver {
- public:
- // The observer does not own any arguments passed to it. It is assumed that
- // the arguments will outlive all uses of the observer.
- JavascriptTestObserver(
- content::WebContents* web_contents,
- TestMessageHandler* handler);
-
- virtual ~JavascriptTestObserver();
-
- // Pump the message loop until the message handler indicates the Javascript
- // test is done running. Return true if the test jig functioned correctly and
- // nothing timed out.
- bool Run();
-
- // Prepare the observer to be used again. This method should NOT be called
- // while Run() is pumping the message loop.
- void Reset();
-
- virtual void Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
-
- private:
- // This message did not signal the end of a test, keep going.
- void Continue();
-
- // This was the last message we care about, stop listening for more messages.
- void EndTest();
-
- TestMessageHandler* handler_;
- bool running_;
- bool finished_;
- content::NotificationRegistrar registrar_;
-
- DISALLOW_COPY_AND_ASSIGN(JavascriptTestObserver);
-};
-
-#endif // CHROME_TEST_BASE_JAVASCRIPT_TEST_OBSERVER_H_
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | chrome/test/base/javascript_test_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698