Commit 264544cf authored by Xi Cheng's avatar Xi Cheng Committed by Commit Bot

Add test coverage for launching Chrome using notification launch id

This adds test coverage for correctly passing launch id from browser startup
to the notification system when Chrome is launched by the notification_helper
process.

Bug: 734095
Change-Id: If902781ab49368616857ab72a1fa02f4a9949e2f
Reviewed-on: https://chromium-review.googlesource.com/981198Reviewed-by: default avatarTommy Martino <tmartino@chromium.org>
Commit-Queue: Xi Cheng <chengx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546126}
parent 8a798e91
...@@ -466,6 +466,50 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, OpenAppShortcutTabPref) { ...@@ -466,6 +466,50 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, OpenAppShortcutTabPref) {
#endif // !defined(OS_CHROMEOS) #endif // !defined(OS_CHROMEOS)
#if defined(OS_WIN)
IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ValidNotificationLaunchId) {
// This test execises NotificationPlatformBridgeWin, which is not enabled in
// older versions of Windows.
if (base::win::GetVersion() < base::win::VERSION_WIN8)
return;
// Simulate a launch from the notification_helper process which appends the
// kNotificationLaunchId switch to the command line.
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
command_line.AppendSwitchNative(
switches::kNotificationLaunchId,
L"1|1|0|Default|0|https://example.com/|notification_id");
chrome::startup::IsFirstRun first_run =
first_run::IsChromeFirstRun() ? chrome::startup::IS_FIRST_RUN
: chrome::startup::IS_NOT_FIRST_RUN;
StartupBrowserCreatorImpl launch(base::FilePath(), command_line, first_run);
ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false));
// The launch delegates to the notification system and doesn't open any new
// browser window.
ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile()));
}
IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, InvalidNotificationLaunchId) {
// This test execises NotificationPlatformBridgeWin, which is not enabled in
// older versions of Windows.
if (base::win::GetVersion() < base::win::VERSION_WIN8)
return;
// Simulate a launch with invalid launch id, which will fail.
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
command_line.AppendSwitchNative(switches::kNotificationLaunchId, L"");
chrome::startup::IsFirstRun first_run =
first_run::IsChromeFirstRun() ? chrome::startup::IS_FIRST_RUN
: chrome::startup::IS_NOT_FIRST_RUN;
StartupBrowserCreatorImpl launch(base::FilePath(), command_line, first_run);
ASSERT_FALSE(launch.Launch(browser()->profile(), std::vector<GURL>(), false));
// No new browser window is open.
ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile()));
}
#endif // defined(OS_WIN)
IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest,
ReadingWasRestartedAfterRestart) { ReadingWasRestartedAfterRestart) {
// Tests that StartupBrowserCreator::WasRestarted reads and resets the // Tests that StartupBrowserCreator::WasRestarted reads and resets the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment