diff options
author | yoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-24 03:39:36 +0000 |
---|---|---|
committer | yoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-24 03:39:36 +0000 |
commit | 7685f64a35b6d029f7d11ce752dc126163d9474e (patch) | |
tree | 0cb10d4ed10d781bc6de27672bbcc8528134baab /extensions/shell/test | |
parent | af97fe7d55c6310aacf1585bdbd8d38e3bc4c080 (diff) | |
download | chromium_src-7685f64a35b6d029f7d11ce752dc126163d9474e.zip chromium_src-7685f64a35b6d029f7d11ce752dc126163d9474e.tar.gz chromium_src-7685f64a35b6d029f7d11ce752dc126163d9474e.tar.bz2 |
Move apps/shell to extensions/shell.
This does:
- Move files
- Fix up all namespaces in these files to be extensions, not apps
- Clean up DEPS files
This does not:
- Change the name of the build targets (app_shell, app_shell_browsertests)
BUG=394987
TBR=ben@chromium.org
Review URL: https://codereview.chromium.org/412713002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285144 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/shell/test')
-rw-r--r-- | extensions/shell/test/DEPS | 4 | ||||
-rw-r--r-- | extensions/shell/test/shell_test.cc | 57 | ||||
-rw-r--r-- | extensions/shell/test/shell_test.h | 48 | ||||
-rw-r--r-- | extensions/shell/test/shell_test_launcher_delegate.cc | 27 | ||||
-rw-r--r-- | extensions/shell/test/shell_test_launcher_delegate.h | 23 | ||||
-rw-r--r-- | extensions/shell/test/shell_tests_main.cc | 15 |
6 files changed, 174 insertions, 0 deletions
diff --git a/extensions/shell/test/DEPS b/extensions/shell/test/DEPS new file mode 100644 index 0000000..c243ad4 --- /dev/null +++ b/extensions/shell/test/DEPS @@ -0,0 +1,4 @@ +include_rules = [ + # Testing utilities can access anything in extensions/shell. + "+extensions/shell", +] diff --git a/extensions/shell/test/shell_test.cc b/extensions/shell/test/shell_test.cc new file mode 100644 index 0000000..e67400d --- /dev/null +++ b/extensions/shell/test/shell_test.cc @@ -0,0 +1,57 @@ +// Copyright 2014 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. + +#include "extensions/shell/test/shell_test.h" + +#include "base/command_line.h" +#include "base/files/file_path.h" +#include "base/logging.h" +#include "content/public/common/content_switches.h" +#include "extensions/browser/extension_system.h" +#include "extensions/shell/browser/shell_content_browser_client.h" +#include "extensions/shell/browser/shell_desktop_controller.h" +#include "extensions/shell/browser/shell_extension_system.h" + +namespace extensions { + +AppShellTest::AppShellTest() : browser_context_(NULL), extension_system_(NULL) { +} + +AppShellTest::~AppShellTest() { +} + +void AppShellTest::SetUp() { + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + command_line->AppendSwitchASCII(switches::kTestType, "appshell"); + content::BrowserTestBase::SetUp(); +} + +void AppShellTest::SetUpOnMainThread() { + browser_context_ = ShellContentBrowserClient::Get()->GetBrowserContext(); + + extension_system_ = static_cast<ShellExtensionSystem*>( + ExtensionSystem::Get(browser_context_)); +} + +void AppShellTest::RunTestOnMainThreadLoop() { + base::MessageLoopForUI::current()->RunUntilIdle(); + + SetUpOnMainThread(); + + RunTestOnMainThread(); + + TearDownOnMainThread(); + + // Clean up the app window. + ShellDesktopController::instance()->CloseAppWindows(); +} + +bool AppShellTest::LoadAndLaunchApp(const base::FilePath& app_dir) { + bool loaded = extension_system_->LoadApp(app_dir); + if (loaded) + extension_system_->LaunchApp(); + return loaded; +} + +} // namespace extensions diff --git a/extensions/shell/test/shell_test.h b/extensions/shell/test/shell_test.h new file mode 100644 index 0000000..c9d36ed --- /dev/null +++ b/extensions/shell/test/shell_test.h @@ -0,0 +1,48 @@ +// Copyright 2014 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 EXTENSIONS_SHELL_TEST_SHELL_TEST_H_ +#define EXTENSIONS_SHELL_TEST_SHELL_TEST_H_ + +#include "base/memory/scoped_ptr.h" +#include "content/public/test/browser_test.h" +#include "content/public/test/browser_test_base.h" + +namespace base { +class FilePath; +} + +namespace content { +class BrowserContext; +} + +namespace extensions { + +class ShellExtensionSystem; + +// Base class for app shell browser tests. +class AppShellTest : public content::BrowserTestBase { + public: + AppShellTest(); + virtual ~AppShellTest(); + + // content::BrowserTestBase implementation. + virtual void SetUp() OVERRIDE; + virtual void SetUpOnMainThread() OVERRIDE; + virtual void RunTestOnMainThreadLoop() OVERRIDE; + + // Loads an unpacked application from a directory using |extension_system_| + // and attempts to launch it. Returns true on success. + bool LoadAndLaunchApp(const base::FilePath& app_dir); + + content::BrowserContext* browser_context() { return browser_context_; } + + private: + content::BrowserContext* browser_context_; + ShellExtensionSystem* extension_system_; +}; + +} // namespace extensions + +#endif // EXTENSIONS_SHELL_TEST_SHELL_TEST_H_ diff --git a/extensions/shell/test/shell_test_launcher_delegate.cc b/extensions/shell/test/shell_test_launcher_delegate.cc new file mode 100644 index 0000000..ce7bc59 --- /dev/null +++ b/extensions/shell/test/shell_test_launcher_delegate.cc @@ -0,0 +1,27 @@ +// Copyright 2014 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. + +#include "extensions/shell/test/shell_test_launcher_delegate.h" + +#include "base/test/test_suite.h" +#include "extensions/shell/app/shell_main_delegate.h" + +namespace extensions { + +int AppShellTestLauncherDelegate::RunTestSuite(int argc, char** argv) { + return base::TestSuite(argc, argv).Run(); +} + +bool AppShellTestLauncherDelegate::AdjustChildProcessCommandLine( + base::CommandLine* command_line, + const base::FilePath& temp_data_dir) { + return true; +} + +content::ContentMainDelegate* +AppShellTestLauncherDelegate::CreateContentMainDelegate() { + return new ShellMainDelegate(); +} + +} // namespace extensions diff --git a/extensions/shell/test/shell_test_launcher_delegate.h b/extensions/shell/test/shell_test_launcher_delegate.h new file mode 100644 index 0000000..8e62f5d --- /dev/null +++ b/extensions/shell/test/shell_test_launcher_delegate.h @@ -0,0 +1,23 @@ +// Copyright 2014 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 EXTENSIONS_SHELL_TEST_SHELL_TEST_LAUNCHER_DELEGATE_H_ +#define EXTENSIONS_SHELL_TEST_SHELL_TEST_LAUNCHER_DELEGATE_H_ + +#include "content/public/test/test_launcher.h" + +namespace extensions { + +class AppShellTestLauncherDelegate : public content::TestLauncherDelegate { + public: + virtual int RunTestSuite(int argc, char** argv) OVERRIDE; + virtual bool AdjustChildProcessCommandLine( + base::CommandLine* command_line, + const base::FilePath& temp_data_dir) OVERRIDE; + virtual content::ContentMainDelegate* CreateContentMainDelegate() OVERRIDE; +}; + +} // namespace extensions + +#endif // EXTENSIONS_SHELL_TEST_SHELL_TEST_LAUNCHER_DELEGATE_H_ diff --git a/extensions/shell/test/shell_tests_main.cc b/extensions/shell/test/shell_tests_main.cc new file mode 100644 index 0000000..eb16469 --- /dev/null +++ b/extensions/shell/test/shell_tests_main.cc @@ -0,0 +1,15 @@ +// Copyright 2014 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. + +#include <algorithm> + +#include "base/sys_info.h" +#include "extensions/shell/test/shell_test_launcher_delegate.h" +#include "testing/gtest/include/gtest/gtest.h" + +int main(int argc, char** argv) { + int default_jobs = std::max(1, base::SysInfo::NumberOfProcessors() / 2); + extensions::AppShellTestLauncherDelegate launcher_delegate; + return content::LaunchTests(&launcher_delegate, default_jobs, argc, argv); +} |