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

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

Issue 2393343002: Split ExtensionTestObserver and move to //extensions. (Closed)
Patch Set: fix bug in ActivityLogApiTest.TriggerEvent Created 4 years, 2 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/chrome_extension_test_notification_observer.h
diff --git a/chrome/browser/extensions/extension_test_notification_observer.h b/chrome/browser/extensions/chrome_extension_test_notification_observer.h
similarity index 19%
copy from chrome/browser/extensions/extension_test_notification_observer.h
copy to chrome/browser/extensions/chrome_extension_test_notification_observer.h
index d4b8d866ac05eead9c300f367e7a65b290623747..2e207bceb71d12368e3b922941b5aaffab005f3e 100644
--- a/chrome/browser/extensions/extension_test_notification_observer.h
+++ b/chrome/browser/extensions/chrome_extension_test_notification_observer.h
@@ -1,126 +1,56 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2016 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_NOTIFICATION_OBSERVER_H_
-#define CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_
+#ifndef CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_
+#define CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_
#include <string>
-#include "base/callback.h"
-#include "base/compiler_specific.h"
-#include "chrome/browser/chrome_notification_types.h"
+#include "base/macros.h"
#include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/location_bar/location_bar.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_types.h"
+#include "extensions/test/extension_test_notification_observer.h"
+
+class Browser;
namespace content {
+class BrowserContext;
class WindowedNotificationObserver;
}
// Test helper class for observing extension-related events.
-class ExtensionTestNotificationObserver
- : public content::NotificationObserver,
+// TODO(devlin): This should be in the extensions namespace.
+class ChromeExtensionTestNotificationObserver
+ : public ExtensionTestNotificationObserver,
public extensions::ExtensionActionAPI::Observer {
public:
- explicit ExtensionTestNotificationObserver(Browser* browser);
- ~ExtensionTestNotificationObserver() override;
+ explicit ChromeExtensionTestNotificationObserver(Browser* browser);
+ ~ChromeExtensionTestNotificationObserver() override;
- // Wait for the number of visible page actions to change to |count|.
+ // Waits for the number of visible page actions to change to |count|.
bool WaitForPageActionVisibilityChangeTo(int count);
- // Wait for an extension install error to be raised. Returns true if an
- // error was raised.
- bool WaitForExtensionInstallError();
-
// Waits until an extension is loaded and all view have loaded.
void WaitForExtensionAndViewLoad();
- // Waits until an extension is loaded.
- void WaitForExtensionLoad();
-
- // Waits for an extension load error. Returns true if the error really
- // happened.
- bool WaitForExtensionLoadError();
-
- // Wait for the specified extension to crash. Returns true if it really
- // crashed.
- bool WaitForExtensionCrash(const std::string& extension_id);
-
- // Wait for the crx installer to be done. Returns true if it really is done.
- bool WaitForCrxInstallerDone();
-
- // Wait for all extension views to load.
+ // Waits for all extension views to load.
bool WaitForExtensionViewsToLoad();
- // Wait for extension to be idle.
+ // Waits for extension to be idle.
bool WaitForExtensionIdle(const std::string& extension_id);
- // Wait for extension to be not idle.
+ // Waits for extension to be not idle.
bool WaitForExtensionNotIdle(const std::string& extension_id);
- // Watch for the given event type from the given source.
- // After calling this method, call Wait() to ensure that RunMessageLoop() is
- // called appropriately and cleanup is performed.
- void Watch(int type, const content::NotificationSource& source);
-
- // After registering one or more event types with Watch(), call
- // this method to run the message loop and perform cleanup.
- void Wait();
-
- const std::string& last_loaded_extension_id() {
- return last_loaded_extension_id_;
- }
- void set_last_loaded_extension_id(
- const std::string& last_loaded_extension_id) {
- last_loaded_extension_id_ = last_loaded_extension_id;
- }
-
- // content::NotificationObserver
- void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override;
-
private:
- class NotificationSet;
-
- Profile* GetProfile();
-
- void WaitForNotification(int notification_type);
-
- // Wait for |condition_| to be met. |notification_set| is the set of
- // notifications to wait for and to check |condition| when observing. This
- // can be NULL if we are instead waiting for a different observer method, like
- // OnPageActionsUpdated().
- void WaitForCondition(const base::Callback<bool(void)>& condition,
- NotificationSet* notification_set);
-
- // Quits the message loop if |condition_| is met.
- void MaybeQuit();
+ content::BrowserContext* GetBrowserContext();
// extensions::ExtensionActionAPI::Observer:
void OnPageActionsUpdated(content::WebContents* contents) override;
Browser* browser_;
- Profile* profile_;
-
- content::NotificationRegistrar registrar_;
- std::unique_ptr<content::WindowedNotificationObserver> observer_;
-
- std::string last_loaded_extension_id_;
- int extension_installs_observed_;
- int extension_load_errors_observed_;
- int crx_installers_done_observed_;
-
- // The condition for which we are waiting. This should be checked in any
- // observing methods that could trigger it.
- base::Callback<bool(void)> condition_;
- // The closure to quit the currently-running message loop.
- base::Closure quit_closure_;
+ DISALLOW_COPY_AND_ASSIGN(ChromeExtensionTestNotificationObserver);
};
-#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_
+#endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698