Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / extensions / shell / test / shell_apitest.cc
blobd442228e38ef65ecbe99ceafa179681b4c9b4140
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "extensions/shell/test/shell_apitest.h"
7 #include "base/files/file_path.h"
8 #include "base/path_service.h"
9 #include "content/public/browser/notification_service.h"
10 #include "extensions/browser/extension_registry.h"
11 #include "extensions/browser/notification_types.h"
12 #include "extensions/common/extension_paths.h"
13 #include "extensions/shell/browser/shell_extension_system.h"
14 #include "extensions/test/result_catcher.h"
16 namespace extensions {
18 ShellApiTest::ShellApiTest() {
21 ShellApiTest::~ShellApiTest() {
24 const Extension* ShellApiTest::LoadApp(const std::string& app_dir) {
25 base::FilePath test_data_dir;
26 PathService::Get(extensions::DIR_TEST_DATA, &test_data_dir);
27 test_data_dir = test_data_dir.AppendASCII(app_dir);
29 const Extension* extension = extension_system_->LoadApp(test_data_dir);
30 if (!extension)
31 return NULL;
33 extension_system_->LaunchApp(extension->id());
35 return extension;
38 bool ShellApiTest::RunAppTest(const std::string& app_dir) {
39 ResultCatcher catcher;
41 const Extension* extension = LoadApp(app_dir);
42 if (!extension)
43 return false;
45 if (!catcher.GetNextResult()) {
46 message_ = catcher.message();
47 return false;
50 return true;
53 void ShellApiTest::UnloadApp(const Extension* app) {
54 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context());
55 ASSERT_TRUE(registry->RemoveEnabled(app->id()));
57 UnloadedExtensionInfo::Reason reason(UnloadedExtensionInfo::REASON_DISABLE);
58 registry->TriggerOnUnloaded(app, reason);
60 // The following notifications are deprecated and in the future, classes
61 // should only be observing the ExtensionRegistry.
62 UnloadedExtensionInfo details(app, reason);
63 content::NotificationService::current()->Notify(
64 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
65 content::Source<content::BrowserContext>(browser_context()),
66 content::Details<UnloadedExtensionInfo>(&details));
68 content::NotificationService::current()->Notify(
69 extensions::NOTIFICATION_EXTENSION_REMOVED,
70 content::Source<content::BrowserContext>(browser_context()),
71 content::Details<const Extension>(app));
74 } // namespace extensions