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

Unified Diff: chrome/browser/extensions/extension_test_message_listener.h

Issue 3058044: Revert 54955 - Merge 54514 ... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/479/src/
Patch Set: Created 10 years, 4 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
Index: chrome/browser/extensions/extension_test_message_listener.h
===================================================================
--- chrome/browser/extensions/extension_test_message_listener.h (revision 54967)
+++ chrome/browser/extensions/extension_test_message_listener.h (working copy)
@@ -1,70 +0,0 @@
-// Copyright (c) 2010 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_BROWSER_EXTENSIONS_EXTENSION_TEST_MESSAGE_LISTENER_H_
-#define CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_MESSAGE_LISTENER_H_
-#pragma once
-
-#include <string>
-
-#include "chrome/common/notification_observer.h"
-#include "chrome/common/notification_registrar.h"
-
-// A message from javascript sent via chrome.test.sendMessage().
-struct ExtensionTestMessage {
- // The sender's extension id.
- std::string extension_id;
-
- // The message content.
- std::string content;
-};
-
-// This class helps us wait for incoming messages sent from javascript via
-// chrome.test.sendMessage(). A sample usage would be:
-//
-// ExtensionTestMessageListener listener("foo");
-// ... do some work
-// ASSERT_TRUE(listener.WaitUntilSatisfied());
-//
-// TODO(asargent) - In the future we may want to add the ability to listen for
-// multiple messages, and/or to wait for "any" message and then retrieve the
-// contents of that message. We may also want to specify an extension id as
-// satisfaction criteria in addition to message content.
-//
-// Note that when using it in browser tests, you need to make sure it gets
-// destructed *before* the browser gets torn down. Two common patterns are to
-// either make it a local variable inside your test body, or if it's a member
-// variable of a ExtensionBrowserTest subclass, override the
-// InProcessBrowserTest::CleanUpOnMainThread() method and clean it up there.
-class ExtensionTestMessageListener : public NotificationObserver {
- public:
- // We immediately start listening for |expected_message|.
- explicit ExtensionTestMessageListener(const std::string& expected_message);
- ~ExtensionTestMessageListener();
-
- // This returns true immediately if we've already gotten the expected
- // message, or waits until it arrives. Returns false if the wait is
- // interrupted and we still haven't gotten the message.
- bool WaitUntilSatisfied();
-
- // Implements the NotificationObserver interface.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
- private:
- NotificationRegistrar registrar_;
-
- // The message we're expecting.
- std::string expected_message_;
-
- // Whether we've seen expected_message_ yet.
- bool satisfied_;
-
- // If we're waiting, then we want to post a quit task when the expected
- // message arrives.
- bool waiting_;
-};
-
-#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_MESSAGE_LISTENER_H_
« no previous file with comments | « chrome/browser/extensions/extension_test_api.cc ('k') | chrome/browser/extensions/extension_test_message_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698