Commit 2311fc53 authored by Glen Robertson's avatar Glen Robertson Committed by Commit Bot

Move launcher-related tests to launcher_controller test file and delete install_manager test file.

install_manager_bookmark_app_browsertest.cc was actually testing PWA install bubble behaviour,
which is already tested in hosted_app_browsertest.cc and pwa_install_view_browsertest.cc.

Tests for launcher behaviour were moved to a better home in chrome_launcher_controller_browsertest.cc

This was resolved in prep for https://chromium-review.googlesource.com/c/chromium/src/+/1746116

Change-Id: I03a7dfcead67c0174241b8cbd4192035b71be15b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1760843Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Commit-Queue: Glen Robertson <glenrob@chromium.org>
Auto-Submit: Glen Robertson <glenrob@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689249}
parent 1a372585
......@@ -26,6 +26,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind_test_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/apps/launch_service/launch_service.h"
#include "chrome/browser/apps/platform_apps/app_browsertest_util.h"
#include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
......@@ -53,6 +54,7 @@
#include "chrome/browser/ui/test/test_app_window_icon_observer.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h"
#include "chrome/browser/web_applications/system_web_app_manager.h"
#include "chrome/browser/web_applications/test/web_app_install_observer.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
......@@ -1873,6 +1875,54 @@ IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, WindowedHostedAndBookmarkApps) {
shelf_model()->ItemByID(bookmark_app_shelf_id)->status);
}
// Windowed progressive web apps should have shelf activity indicator showing
// after install.
IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest,
WindowedPwasHaveActivityIndicatorSet) {
// Start server and open test page.
ASSERT_TRUE(embedded_test_server()->Start());
AddTabAtIndex(
1,
GURL(embedded_test_server()->GetURL("/banners/manifest_test_page.html")),
ui::PAGE_TRANSITION_LINK);
// Install PWA.
chrome::SetAutoAcceptPWAInstallConfirmationForTesting(true);
web_app::WebAppInstallObserver observer(profile());
chrome::ExecuteCommand(browser(), IDC_INSTALL_PWA);
web_app::AppId app_id = observer.AwaitNextInstall();
chrome::SetAutoAcceptPWAInstallConfirmationForTesting(false);
ash::ShelfID shelf_id(app_id);
EXPECT_TRUE(ChromeLauncherController::instance()->IsPinned(shelf_id));
EXPECT_EQ(
shelf_id,
ChromeLauncherController::instance()->shelf_model()->active_shelf_id());
}
// Windowed shortcut apps should have shelf activity indicator showing after
// install.
IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest,
WindowedShortcutAppsHaveActivityIndicatorSet) {
// Start server and open test page.
ASSERT_TRUE(embedded_test_server()->Start());
AddTabAtIndex(
1,
GURL(embedded_test_server()->GetURL("/banners/manifest_test_page.html")),
ui::PAGE_TRANSITION_LINK);
// Install shortcut app.
chrome::SetAutoAcceptBookmarkAppDialogForTesting(true);
web_app::WebAppInstallObserver observer(profile());
chrome::ExecuteCommand(browser(), IDC_CREATE_SHORTCUT);
web_app::AppId app_id = observer.AwaitNextInstall();
chrome::SetAutoAcceptBookmarkAppDialogForTesting(false);
ash::ShelfID shelf_id(app_id);
EXPECT_TRUE(ChromeLauncherController::instance()->IsPinned(shelf_id));
EXPECT_EQ(
shelf_id,
ChromeLauncherController::instance()->shelf_model()->active_shelf_id());
}
// Test that "Close" is shown in the context menu when there are opened browsers
// windows.
IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest,
......
......@@ -74,7 +74,6 @@ source_set("browser_tests") {
sources = [
"bookmark_app_registrar_browsertest.cc",
"install_manager_bookmark_app_browsertest.cc",
"system_web_app_manager_browsertest.cc",
"system_web_app_manager_browsertest.h",
"web_app_audio_focus_browsertest.cc",
......
// Copyright 2019 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 "base/run_loop.h"
#include "base/test/bind_test_util.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/browser/ui/web_applications/web_app_dialog_utils.h"
#include "chrome/browser/web_applications/components/install_manager.h"
#include "chrome/browser/web_applications/components/web_app_constants.h"
#include "chrome/common/chrome_features.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_registry.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_CHROMEOS)
#include "ash/public/cpp/shelf_model.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#endif // defined(OS_CHROMEOS)
namespace extensions {
class InstallManagerBookmarkAppDialogTest : public DialogBrowserTest {
public:
InstallManagerBookmarkAppDialogTest() {
scoped_feature_list_.InitWithFeatures(
{}, {features::kDesktopPWAsWithoutExtensions});
}
// DialogBrowserTest:
void ShowUi(const std::string& test_suffix) override {
ASSERT_TRUE(embedded_test_server()->Start());
std::string page_path;
if (test_suffix == "FromInstallableSite")
page_path = "/banners/manifest_test_page.html";
else if (test_suffix == "FromNonInstallableSite")
page_path = "/favicon/page_with_favicon.html";
else
NOTREACHED();
AddTabAtIndex(1, GURL(embedded_test_server()->GetURL(page_path)),
ui::PAGE_TRANSITION_LINK);
EXPECT_TRUE(web_app::CanCreateWebApp(browser()));
web_contents_ = browser()->tab_strip_model()->GetActiveWebContents();
base::RunLoop run_loop;
web_app::CreateWebAppFromCurrentWebContents(
browser(), /*force_shortcut_app=*/false,
base::BindLambdaForTesting(
[&](const web_app::AppId& app_id, web_app::InstallResultCode code) {
DCHECK_EQ(web_app::InstallResultCode::kSuccess, code);
installed_app_id_ = app_id;
run_loop.Quit();
}));
run_loop.Run();
}
protected:
content::WebContents* web_contents() const { return web_contents_; }
web_app::AppId installed_app_id() const { return installed_app_id_; }
private:
base::test::ScopedFeatureList scoped_feature_list_;
content::WebContents* web_contents_ = nullptr;
web_app::AppId installed_app_id_;
DISALLOW_COPY_AND_ASSIGN(InstallManagerBookmarkAppDialogTest);
};
IN_PROC_BROWSER_TEST_F(InstallManagerBookmarkAppDialogTest,
CreateWindowedPWA_FromNonInstallableSite) {
// The chrome::ShowBookmarkAppDialog will be launched because
// page_with_favicon.html doesn't pass the PWA check.
chrome::SetAutoAcceptBookmarkAppDialogForTesting(true);
ShowAndVerifyUi();
chrome::SetAutoAcceptBookmarkAppDialogForTesting(false);
#if defined(OS_CHROMEOS)
const ash::ShelfID shelf_id(installed_app_id());
EXPECT_TRUE(ChromeLauncherController::instance()->IsPinned(shelf_id));
EXPECT_EQ(
shelf_id,
ChromeLauncherController::instance()->shelf_model()->active_shelf_id());
#endif // defined(OS_CHROMEOS)
}
IN_PROC_BROWSER_TEST_F(InstallManagerBookmarkAppDialogTest,
CreateWindowedPWA_FromInstallableSite) {
// The chrome::ShowPWAInstallDialog will be launched because
// manifest_test_page.html passes the PWA check.
chrome::SetAutoAcceptPWAInstallConfirmationForTesting(true);
ShowAndVerifyUi();
chrome::SetAutoAcceptPWAInstallConfirmationForTesting(false);
auto* registry = ExtensionRegistry::Get(browser()->profile());
const Extension* extension =
registry->enabled_extensions().GetByID(installed_app_id());
DCHECK(extension);
EXPECT_EQ("Manifest test app", extension->name());
// Ensure the tab is reparented into dedicated app window.
Browser* app_browser = chrome::FindBrowserWithWebContents(web_contents());
EXPECT_TRUE(app_browser->is_type_app());
EXPECT_NE(app_browser, browser());
}
} // namespace extensions
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