summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authoryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-21 12:47:34 +0000
committeryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-21 12:47:34 +0000
commit18c83cc15087788e314580d2fd20aff907ba1589 (patch)
tree14bbce3c0ccf83bdbb80e86c1b082e15689634bf /apps
parent0d39935ece19c811aa86977b8aa7743138b6a7fd (diff)
downloadchromium_src-18c83cc15087788e314580d2fd20aff907ba1589.zip
chromium_src-18c83cc15087788e314580d2fd20aff907ba1589.tar.gz
chromium_src-18c83cc15087788e314580d2fd20aff907ba1589.tar.bz2
Add apps_browsertests target (currently running 0 tests).
Since trybot configurations only really support building test targets, this change adds a test target (that doesn't run any tests) to ensure that app_shell compiles, so that changes that pass the trybots cannot break the main waterfall due to app_shell compile problems. BUG=349631 Review URL: https://codereview.chromium.org/205653002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258549 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps')
-rw-r--r--apps/DEPS1
-rw-r--r--apps/apps.gypi52
-rw-r--r--apps/shell/browser/shell_browser_main_parts.cc12
-rw-r--r--apps/shell/browser/shell_browser_main_parts.h4
-rw-r--r--apps/test/app_shell_test.cc51
-rw-r--r--apps/test/app_shell_test.h48
-rw-r--r--apps/test/apps_test_launcher_delegate.cc27
-rw-r--r--apps/test/apps_test_launcher_delegate.h23
-rw-r--r--apps/test/apps_tests_main.cc15
9 files changed, 227 insertions, 6 deletions
diff --git a/apps/DEPS b/apps/DEPS
index e9d3eeb..703a749 100644
--- a/apps/DEPS
+++ b/apps/DEPS
@@ -1,5 +1,6 @@
include_rules = [
"+base",
+ "+content/public/app",
"+content/public/browser",
"+content/public/common",
"+content/public/test",
diff --git a/apps/apps.gypi b/apps/apps.gypi
index 65d1e0d..ddbec1b 100644
--- a/apps/apps.gypi
+++ b/apps/apps.gypi
@@ -153,8 +153,8 @@
],
},
{
- 'target_name': 'app_shell',
- 'type': 'executable',
+ 'target_name': 'app_shell_lib',
+ 'type': 'static_library',
'defines!': ['CONTENT_IMPLEMENTATION'],
'variables': {
'chromium_code': 1,
@@ -177,7 +177,6 @@
'sources': [
'shell/app/shell_main_delegate.cc',
'shell/app/shell_main_delegate.h',
- 'shell/app/shell_main.cc',
'shell/browser/shell_app_sorting.cc',
'shell/browser/shell_app_sorting.h',
'shell/browser/shell_app_window_delegate.cc',
@@ -207,6 +206,24 @@
'shell/renderer/shell_content_renderer_client.cc',
'shell/renderer/shell_content_renderer_client.h',
],
+ },
+ {
+ 'target_name': 'app_shell',
+ 'type': 'executable',
+ 'defines!': ['CONTENT_IMPLEMENTATION'],
+ 'variables': {
+ 'chromium_code': 1,
+ },
+ 'dependencies': [
+ 'app_shell_lib',
+ 'app_shell_pak',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'sources': [
+ 'shell/app/shell_main.cc',
+ ],
'conditions': [
['OS=="win"', {
'msvs_settings': {
@@ -221,7 +238,34 @@
}],
],
},
+ {
+ 'target_name': 'apps_browsertests',
+ 'type': '<(gtest_target_type)',
+ 'variables': {
+ 'chromium_code': 1,
+ },
+ 'dependencies': [
+ 'app_shell_lib',
+ # TODO(yoz): find the right deps
+ '../base/base.gyp:test_support_base',
+ '../content/content.gyp:content_app_both',
+ '../content/content_shell_and_tests.gyp:content_browser_test_support',
+ '../content/content_shell_and_tests.gyp:test_support_content',
+ '../testing/gtest.gyp:gtest',
+ ],
+ 'defines': [
+ 'HAS_OUT_OF_PROC_TEST_RUNNER',
+ ],
+ 'sources': [
+ # TODO(yoz): Refactor once we have a second test target.
+ 'test/app_shell_test.h',
+ 'test/app_shell_test.cc',
+ 'test/apps_test_launcher_delegate.cc',
+ 'test/apps_test_launcher_delegate.h',
+ 'test/apps_tests_main.cc',
+ ],
+ },
], # targets
- }], # chromeos==1
+ }], # chromeos==1 or linux aura or win aura
], # conditions
}
diff --git a/apps/shell/browser/shell_browser_main_parts.cc b/apps/shell/browser/shell_browser_main_parts.cc
index ab9aac2..fefaf0c 100644
--- a/apps/shell/browser/shell_browser_main_parts.cc
+++ b/apps/shell/browser/shell_browser_main_parts.cc
@@ -76,8 +76,7 @@ namespace apps {
ShellBrowserMainParts::ShellBrowserMainParts(
const content::MainFunctionParams& parameters)
- : extension_system_(NULL) {
-}
+ : extension_system_(NULL), parameters_(parameters) {}
ShellBrowserMainParts::~ShellBrowserMainParts() {
}
@@ -131,6 +130,15 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
devtools_delegate_.reset(
new content::ShellDevToolsDelegate(browser_context_.get()));
+ // For running browser tests.
+ // TODO(yoz): This is set up to exit prematurely because we don't have
+ // any tests yet.
+ if (parameters_.ui_task) {
+ parameters_.ui_task->Run();
+ delete parameters_.ui_task;
+ return;
+ }
+
CreateRootWindow();
CreateViewsDelegate();
diff --git a/apps/shell/browser/shell_browser_main_parts.h b/apps/shell/browser/shell_browser_main_parts.h
index 653e90d..8d559bc 100644
--- a/apps/shell/browser/shell_browser_main_parts.h
+++ b/apps/shell/browser/shell_browser_main_parts.h
@@ -9,6 +9,7 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "content/public/browser/browser_main_parts.h"
+#include "content/public/common/main_function_params.h"
#include "ui/aura/window_tree_host_observer.h"
namespace aura {
@@ -105,6 +106,9 @@ class ShellBrowserMainParts : public content::BrowserMainParts,
// Owned by the KeyedService system.
extensions::ShellExtensionSystem* extension_system_;
+ // For running app browsertests.
+ const content::MainFunctionParams parameters_;
+
DISALLOW_COPY_AND_ASSIGN(ShellBrowserMainParts);
};
diff --git a/apps/test/app_shell_test.cc b/apps/test/app_shell_test.cc
new file mode 100644
index 0000000..9baf997
--- /dev/null
+++ b/apps/test/app_shell_test.cc
@@ -0,0 +1,51 @@
+// 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 "apps/test/app_shell_test.h"
+
+#include "apps/apps_client.h"
+#include "apps/shell/browser/shell_browser_context.h"
+#include "apps/shell/browser/shell_extension_system.h"
+#include "apps/shell/browser/shell_extension_system_factory.h"
+#include "base/files/file_path.h"
+#include "base/logging.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#include "extensions/browser/extension_system.h"
+#include "extensions/common/extension_paths.h"
+
+namespace apps {
+
+AppShellTest::AppShellTest() {}
+
+AppShellTest::~AppShellTest() {}
+
+void AppShellTest::SetUpOnMainThread() {
+ std::vector<content::BrowserContext*> contexts =
+ AppsClient::Get()->GetLoadedBrowserContexts();
+ CHECK_EQ(1U, contexts.size());
+ browser_context_ = contexts[0];
+
+ extension_system_ = static_cast<extensions::ShellExtensionSystem*>(
+ extensions::ExtensionSystem::Get(browser_context_));
+}
+
+void AppShellTest::RunTestOnMainThreadLoop() {
+ // Pump startup related events.
+ base::MessageLoopForUI::current()->RunUntilIdle();
+
+ SetUpOnMainThread();
+
+ RunTestOnMainThread();
+
+ TearDownOnMainThread();
+
+ // TODO(yoz): Make windows close. This doesn't seem to close the root window.
+ extension_system_->CloseApp();
+}
+
+bool AppShellTest::LoadAndLaunchApp(const base::FilePath& app_dir) {
+ return extension_system_->LoadAndLaunchApp(app_dir);
+}
+
+} // namespace apps
diff --git a/apps/test/app_shell_test.h b/apps/test/app_shell_test.h
new file mode 100644
index 0000000..e6be460
--- /dev/null
+++ b/apps/test/app_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 APPS_TEST_APP_SHELL_TEST_H_
+#define APPS_TEST_APP_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;
+}
+
+namespace apps {
+
+// Base class for app shell browser tests.
+class AppShellTest : public content::BrowserTestBase {
+ public:
+ AppShellTest();
+ virtual ~AppShellTest();
+
+ 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_;
+ extensions::ShellExtensionSystem* extension_system_;
+};
+
+} // namespace apps
+
+#endif // APPS_TEST_APP_SHELL_TEST_H_
diff --git a/apps/test/apps_test_launcher_delegate.cc b/apps/test/apps_test_launcher_delegate.cc
new file mode 100644
index 0000000..dec4a18
--- /dev/null
+++ b/apps/test/apps_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 "apps/test/apps_test_launcher_delegate.h"
+
+#include "apps/shell/app/shell_main_delegate.h"
+#include "base/test/test_suite.h"
+
+namespace apps {
+
+int AppsTestLauncherDelegate::RunTestSuite(int argc, char** argv) {
+ return base::TestSuite(argc, argv).Run();
+}
+
+bool AppsTestLauncherDelegate::AdjustChildProcessCommandLine(
+ base::CommandLine* command_line,
+ const base::FilePath& temp_data_dir) {
+ return true;
+}
+
+content::ContentMainDelegate*
+AppsTestLauncherDelegate::CreateContentMainDelegate() {
+ return new ShellMainDelegate();
+}
+
+} // namespace apps
diff --git a/apps/test/apps_test_launcher_delegate.h b/apps/test/apps_test_launcher_delegate.h
new file mode 100644
index 0000000..60dc175
--- /dev/null
+++ b/apps/test/apps_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 APPS_TEST_APPS_TEST_LAUNCHER_DELEGATE_H_
+#define APPS_TEST_APPS_TEST_LAUNCHER_DELEGATE_H_
+
+#include "content/public/test/test_launcher.h"
+
+namespace apps {
+
+class AppsTestLauncherDelegate : 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 apps
+
+#endif // APPS_TEST_APPS_TEST_LAUNCHER_DELEGATE_H_
diff --git a/apps/test/apps_tests_main.cc b/apps/test/apps_tests_main.cc
new file mode 100644
index 0000000..080841e
--- /dev/null
+++ b/apps/test/apps_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 "apps/test/apps_test_launcher_delegate.h"
+#include "base/sys_info.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+int main(int argc, char** argv) {
+ int default_jobs = std::max(1, base::SysInfo::NumberOfProcessors() / 2);
+ apps::AppsTestLauncherDelegate launcher_delegate;
+ return content::LaunchTests(&launcher_delegate, default_jobs, argc, argv);
+}