diff options
author | yoz <yoz@chromium.org> | 2014-09-05 07:16:42 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-05 14:19:32 +0000 |
commit | d6f2fa209bab91490944004b5189cd4191e09024 (patch) | |
tree | 022566a96cfee377196fc40209d6b52013e19656 /extensions/shell/test | |
parent | 98d6f1e45c66a03b7b583eec3694c84ff7411fec (diff) | |
download | chromium_src-d6f2fa209bab91490944004b5189cd4191e09024.zip chromium_src-d6f2fa209bab91490944004b5189cd4191e09024.tar.gz chromium_src-d6f2fa209bab91490944004b5189cd4191e09024.tar.bz2 |
Extract ResultCatcher from ExtensionApiTest. Use it in ShellApiTest, which is separated out from AppShellTest.
Move the remaining DnsApiTest to app_shell_browsertests.
BUG=388893
Review URL: https://codereview.chromium.org/529293003
Cr-Commit-Position: refs/heads/master@{#293517}
Diffstat (limited to 'extensions/shell/test')
-rw-r--r-- | extensions/shell/test/shell_apitest.cc | 41 | ||||
-rw-r--r-- | extensions/shell/test/shell_apitest.h | 37 | ||||
-rw-r--r-- | extensions/shell/test/shell_test.cc | 8 | ||||
-rw-r--r-- | extensions/shell/test/shell_test.h | 6 |
4 files changed, 79 insertions, 13 deletions
diff --git a/extensions/shell/test/shell_apitest.cc b/extensions/shell/test/shell_apitest.cc new file mode 100644 index 0000000..b60bf5b --- /dev/null +++ b/extensions/shell/test/shell_apitest.cc @@ -0,0 +1,41 @@ +// 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_apitest.h" + +#include "base/files/file_path.h" +#include "base/path_service.h" +#include "extensions/common/extension_paths.h" +#include "extensions/shell/browser/shell_extension_system.h" +#include "extensions/test/result_catcher.h" + +namespace extensions { + +ShellApiTest::ShellApiTest() { +} + +ShellApiTest::~ShellApiTest() { +} + +bool ShellApiTest::RunAppTest(const std::string& app_dir) { + base::FilePath test_data_dir; + PathService::Get(extensions::DIR_TEST_DATA, &test_data_dir); + test_data_dir = test_data_dir.AppendASCII(app_dir); + ResultCatcher catcher; + + bool loaded = extension_system_->LoadApp(test_data_dir); + if (!loaded) + return false; + + extension_system_->LaunchApp(); + + if (!catcher.GetNextResult()) { + message_ = catcher.message(); + return false; + } + + return true; +} + +} // namespace extensions diff --git a/extensions/shell/test/shell_apitest.h b/extensions/shell/test/shell_apitest.h new file mode 100644 index 0000000..6eb0cb0 --- /dev/null +++ b/extensions/shell/test/shell_apitest.h @@ -0,0 +1,37 @@ +// 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_API_TEST_H_ +#define EXTENSIONS_SHELL_TEST_SHELL_API_TEST_H_ + +#include <string> + +#include "extensions/shell/test/shell_test.h" + +namespace extensions { + +// Base class for app shell browser API tests that load an app/extension +// and wait for a success message from the chrome.test API. +class ShellApiTest : public AppShellTest { + public: + ShellApiTest(); + virtual ~ShellApiTest(); + + // Loads an unpacked platform app from a directory using the current + // ExtensionSystem, launches it, and waits for a chrome.test success + // notification. Returns true if the test succeeds. |app_dir| is a + // subpath under extensions/test/data. + bool RunAppTest(const std::string& app_dir); + + protected: + // If it failed, what was the error message? + std::string message_; + + private: + DISALLOW_COPY_AND_ASSIGN(ShellApiTest); +}; + +} // namespace extensions + +#endif // EXTENSIONS_SHELL_TEST_SHELL_API_TEST_H_ diff --git a/extensions/shell/test/shell_test.cc b/extensions/shell/test/shell_test.cc index e67400d..294fbaa 100644 --- a/extensions/shell/test/shell_test.cc +++ b/extensions/shell/test/shell_test.cc @@ -5,7 +5,6 @@ #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" @@ -47,11 +46,4 @@ void AppShellTest::RunTestOnMainThreadLoop() { 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 index c9d36ed..ac7ad78 100644 --- a/extensions/shell/test/shell_test.h +++ b/extensions/shell/test/shell_test.h @@ -32,13 +32,9 @@ class AppShellTest : public content::BrowserTestBase { 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: + protected: content::BrowserContext* browser_context_; ShellExtensionSystem* extension_system_; }; |