Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / apps / test / app_shell_test.cc
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.
4
5 #include "apps/test/app_shell_test.h"
6
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"
16
17 namespace apps {
18
19 AppShellTest::AppShellTest() {}
20
21 AppShellTest::~AppShellTest() {}
22
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];
28
29   extension_system_ = static_cast<extensions::ShellExtensionSystem*>(
30       extensions::ExtensionSystem::Get(browser_context_));
31 }
32
33 void AppShellTest::RunTestOnMainThreadLoop() {
34   // Pump startup related events.
35   base::MessageLoopForUI::current()->RunUntilIdle();
36
37   SetUpOnMainThread();
38
39   RunTestOnMainThread();
40
41   TearDownOnMainThread();
42
43   // TODO(yoz): Make windows close. This doesn't seem to close the root window.
44   extension_system_->CloseApp();
45 }
46
47 bool AppShellTest::LoadAndLaunchApp(const base::FilePath& app_dir) {
48   return extension_system_->LoadAndLaunchApp(app_dir);
49 }
50
51 }  // namespace apps