This source file includes following definitions.
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- SetUpCommandLine
- LoadAndLaunchApp
- IN_PROC_BROWSER_TEST_F
#include "apps/switches.h"
#include "base/process/launch.h"
#include "base/test/test_timeouts.h"
#include "chrome/browser/apps/app_browsertest_util.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/test/test_launcher.h"
using extensions::PlatformAppBrowserTest;
namespace apps {
#if defined(OS_MACOSX)
#define MAYBE_LoadAndLaunchAppChromeRunning \
DISABLED_LoadAndLaunchAppChromeRunning
#else
#define MAYBE_LoadAndLaunchAppChromeRunning LoadAndLaunchAppChromeRunning
#endif
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
MAYBE_LoadAndLaunchAppChromeRunning) {
ExtensionTestMessageListener launched_listener("Launched", false);
const CommandLine& cmdline = *CommandLine::ForCurrentProcess();
CommandLine new_cmdline(cmdline.GetProgram());
const char* kSwitchNames[] = {
switches::kUserDataDir,
};
new_cmdline.CopySwitchesFrom(cmdline, kSwitchNames, arraysize(kSwitchNames));
base::FilePath app_path = test_data_dir_
.AppendASCII("platform_apps")
.AppendASCII("minimal");
new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp,
app_path.value());
new_cmdline.AppendSwitch(content::kLaunchAsBrowser);
base::ProcessHandle process;
base::LaunchProcess(new_cmdline, base::LaunchOptions(), &process);
ASSERT_NE(base::kNullProcessHandle, process);
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
ASSERT_TRUE(base::WaitForSingleProcess(
process, TestTimeouts::action_timeout()));
}
#if defined(OS_MACOSX)
#define MAYBE_LoadAndLaunchAppWithFile DISABLED_LoadAndLaunchAppWithFile
#else
#define MAYBE_LoadAndLaunchAppWithFile LoadAndLaunchAppWithFile
#endif
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
MAYBE_LoadAndLaunchAppWithFile) {
ExtensionTestMessageListener launched_listener("Launched", false);
const CommandLine& cmdline = *CommandLine::ForCurrentProcess();
CommandLine new_cmdline(cmdline.GetProgram());
const char* kSwitchNames[] = {
switches::kUserDataDir,
};
new_cmdline.CopySwitchesFrom(cmdline, kSwitchNames, arraysize(kSwitchNames));
base::FilePath app_path = test_data_dir_
.AppendASCII("platform_apps")
.AppendASCII("load_and_launch_file");
base::FilePath test_file_path = test_data_dir_
.AppendASCII("platform_apps")
.AppendASCII("launch_files")
.AppendASCII("test.txt");
new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp,
app_path.value());
new_cmdline.AppendSwitch(content::kLaunchAsBrowser);
new_cmdline.AppendArgPath(test_file_path);
base::ProcessHandle process;
base::LaunchProcess(new_cmdline, base::LaunchOptions(), &process);
ASSERT_NE(base::kNullProcessHandle, process);
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
ASSERT_TRUE(base::WaitForSingleProcess(
process, TestTimeouts::action_timeout()));
}
namespace {
class PlatformAppLoadAndLaunchBrowserTest : public PlatformAppBrowserTest {
protected:
PlatformAppLoadAndLaunchBrowserTest() {}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
PlatformAppBrowserTest::SetUpCommandLine(command_line);
app_path_ = test_data_dir_
.AppendASCII("platform_apps")
.AppendASCII("minimal");
command_line->AppendSwitchNative(apps::kLoadAndLaunchApp,
app_path_.value());
}
void LoadAndLaunchApp() {
ExtensionTestMessageListener launched_listener("Launched", false);
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
CreateBrowser(ProfileManager::GetActiveUserProfile());
}
private:
base::FilePath app_path_;
DISALLOW_COPY_AND_ASSIGN(PlatformAppLoadAndLaunchBrowserTest);
};
}
#if defined(OS_WIN) || (defined(OS_LINUX) && defined(USE_AURA))
#define MAYBE_LoadAndLaunchAppChromeNotRunning \
DISABLED_LoadAndLaunchAppChromeNotRunning
#else
#define MAYBE_LoadAndLaunchAppChromeNotRunning \
LoadAndLaunchAppChromeNotRunning
#endif
IN_PROC_BROWSER_TEST_F(PlatformAppLoadAndLaunchBrowserTest,
MAYBE_LoadAndLaunchAppChromeNotRunning) {
LoadAndLaunchApp();
}
}