summaryrefslogtreecommitdiffstats
path: root/extensions/shell/test
diff options
context:
space:
mode:
authorthiago.santos <thiago.santos@intel.com>2015-01-21 12:16:27 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-21 20:17:58 +0000
commitd4ef11808ce81d02bb772a87ac8e698226c6e37f (patch)
treeaaa7b5abb32f3dec9329cc8e178a705c2d0391dd /extensions/shell/test
parentf714289259132eb6bf22e01e6125c3e81d929740 (diff)
downloadchromium_src-d4ef11808ce81d02bb772a87ac8e698226c6e37f.zip
chromium_src-d4ef11808ce81d02bb772a87ac8e698226c6e37f.tar.gz
chromium_src-d4ef11808ce81d02bb772a87ac8e698226c6e37f.tar.bz2
Move sockets_* tests to extensions/
Also add a new function for unloading extensions to ShellApiTest. It is needed by SocketTCPServerUnbindOnUnload and others tests as we migrate them. Review URL: https://codereview.chromium.org/854703003 Cr-Commit-Position: refs/heads/master@{#312410}
Diffstat (limited to 'extensions/shell/test')
-rw-r--r--extensions/shell/test/DEPS2
-rw-r--r--extensions/shell/test/shell_apitest.cc24
-rw-r--r--extensions/shell/test/shell_apitest.h4
3 files changed, 30 insertions, 0 deletions
diff --git a/extensions/shell/test/DEPS b/extensions/shell/test/DEPS
index c243ad4..4759ee0 100644
--- a/extensions/shell/test/DEPS
+++ b/extensions/shell/test/DEPS
@@ -1,4 +1,6 @@
include_rules = [
+ "+content/public/browser",
+
# Testing utilities can access anything in extensions/shell.
"+extensions/shell",
]
diff --git a/extensions/shell/test/shell_apitest.cc b/extensions/shell/test/shell_apitest.cc
index 8db5aaf..d442228 100644
--- a/extensions/shell/test/shell_apitest.cc
+++ b/extensions/shell/test/shell_apitest.cc
@@ -6,6 +6,9 @@
#include "base/files/file_path.h"
#include "base/path_service.h"
+#include "content/public/browser/notification_service.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/notification_types.h"
#include "extensions/common/extension_paths.h"
#include "extensions/shell/browser/shell_extension_system.h"
#include "extensions/test/result_catcher.h"
@@ -47,4 +50,25 @@ bool ShellApiTest::RunAppTest(const std::string& app_dir) {
return true;
}
+void ShellApiTest::UnloadApp(const Extension* app) {
+ ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context());
+ ASSERT_TRUE(registry->RemoveEnabled(app->id()));
+
+ UnloadedExtensionInfo::Reason reason(UnloadedExtensionInfo::REASON_DISABLE);
+ registry->TriggerOnUnloaded(app, reason);
+
+ // The following notifications are deprecated and in the future, classes
+ // should only be observing the ExtensionRegistry.
+ UnloadedExtensionInfo details(app, reason);
+ content::NotificationService::current()->Notify(
+ extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
+ content::Source<content::BrowserContext>(browser_context()),
+ content::Details<UnloadedExtensionInfo>(&details));
+
+ content::NotificationService::current()->Notify(
+ extensions::NOTIFICATION_EXTENSION_REMOVED,
+ content::Source<content::BrowserContext>(browser_context()),
+ content::Details<const Extension>(app));
+}
+
} // namespace extensions
diff --git a/extensions/shell/test/shell_apitest.h b/extensions/shell/test/shell_apitest.h
index 09475e5..2246b49 100644
--- a/extensions/shell/test/shell_apitest.h
+++ b/extensions/shell/test/shell_apitest.h
@@ -31,6 +31,10 @@ class ShellApiTest : public AppShellTest {
// subpath under extensions/test/data.
bool RunAppTest(const std::string& app_dir);
+ // Removes the |app| from the ExtensionRegistry and dispatches
+ // notifications of the removal stating reason as REASON_DISABLE.
+ void UnloadApp(const Extension* app);
+
protected:
// If it failed, what was the error message?
std::string message_;