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 "apps/test/app_shell_test.h"
7 #include "apps/apps_client.h"
8 #include "apps/shell/browser/shell_browser_context.h"
9 #include "apps/shell/browser/shell_extension_system.h"
10 #include "apps/shell/browser/shell_extension_system_factory.h"
11 #include "base/files/file_path.h"
12 #include "base/logging.h"
13 #include "components/keyed_service/content/browser_context_dependency_manager.h"
14 #include "extensions/browser/extension_system.h"
15 #include "extensions/common/extension_paths.h"
19 AppShellTest::AppShellTest() {}
21 AppShellTest::~AppShellTest() {}
23 void AppShellTest::SetUpOnMainThread() {
24 std::vector<content::BrowserContext*> contexts =
25 AppsClient::Get()->GetLoadedBrowserContexts();
26 CHECK_EQ(1U, contexts.size());
27 browser_context_ = contexts[0];
29 extension_system_ = static_cast<extensions::ShellExtensionSystem*>(
30 extensions::ExtensionSystem::Get(browser_context_));
33 void AppShellTest::RunTestOnMainThreadLoop() {
34 // Pump startup related events.
35 base::MessageLoopForUI::current()->RunUntilIdle();
39 RunTestOnMainThread();
41 TearDownOnMainThread();
43 // TODO(yoz): Make windows close. This doesn't seem to close the root window.
44 extension_system_->CloseApp();
47 bool AppShellTest::LoadAndLaunchApp(const base::FilePath& app_dir) {
48 return extension_system_->LoadAndLaunchApp(app_dir);