Commit dab9fba5 authored by Eric Willigers's avatar Eric Willigers Committed by Commit Bot

WebAppUninstallDialogViewBrowserTest does not rely on extensions

The tests BookmarkAppUninstallDialogViewBrowserTest and
BookmarkAppUninstallDialogViewInteractiveBrowserTest previously relies
on extensions methods to install "bookmark apps". We now refer to
these as web apps, and now use web_app:: functions to install them.


Bug: 1052722
Change-Id: Ie4f81682ffa4282a88f06ca89578b3f093507ea1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2067774
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Auto-Submit: Eric Willigers <ericwilligers@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743869}
parent b8b7df1d
......@@ -9,49 +9,42 @@
#include "base/optional.h"
#include "base/run_loop.h"
#include "base/test/bind_test_util.h"
#include "chrome/browser/extensions/browsertest_util.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_uninstall_dialog.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/browser/ui/views/web_apps/web_app_uninstall_dialog_view.h"
#include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h"
#include "chrome/common/web_application_info.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/extension_urls.h"
#include "extensions/common/value_builder.h"
using web_app::AppId;
namespace {
scoped_refptr<const extensions::Extension> BuildTestBookmarkApp() {
extensions::ExtensionBuilder extension_builder("foo");
extension_builder.AddFlags(extensions::Extension::FROM_BOOKMARK);
extension_builder.SetManifestPath({"app", "launch", "web_url"},
"https://example.com/");
return extension_builder.Build();
AppId InstallTestWebApp(Profile* profile) {
const GURL example_url = GURL("http://example.org/");
auto web_app_info = std::make_unique<WebApplicationInfo>();
web_app_info->app_url = example_url;
web_app_info->scope = example_url;
web_app_info->open_as_window = true;
return web_app::InstallWebApp(profile, std::move(web_app_info));
}
} // namespace
using BookmarkAppUninstallDialogViewBrowserTest = InProcessBrowserTest;
using WebAppUninstallDialogViewBrowserTest = InProcessBrowserTest;
// Test that WebAppUninstallDialog cancels the uninstall if the Window
// which is passed to WebAppUninstallDialog::Create() is destroyed before
// WebAppUninstallDialogDelegateView is created.
IN_PROC_BROWSER_TEST_F(BookmarkAppUninstallDialogViewBrowserTest,
IN_PROC_BROWSER_TEST_F(WebAppUninstallDialogViewBrowserTest,
TrackParentWindowDestruction) {
scoped_refptr<const extensions::Extension> extension(BuildTestBookmarkApp());
extensions::ExtensionSystem::Get(browser()->profile())
->extension_service()
->AddExtension(extension.get());
AppId app_id = InstallTestWebApp(browser()->profile());
std::unique_ptr<web_app::WebAppUninstallDialog> dialog(
web_app::WebAppUninstallDialog::Create(
......@@ -62,7 +55,7 @@ IN_PROC_BROWSER_TEST_F(BookmarkAppUninstallDialogViewBrowserTest,
base::RunLoop run_loop;
bool was_uninstalled = false;
dialog->ConfirmUninstall(extension->id(),
dialog->ConfirmUninstall(app_id,
base::BindLambdaForTesting([&](bool uninstalled) {
was_uninstalled = uninstalled;
run_loop.Quit();
......@@ -74,12 +67,9 @@ IN_PROC_BROWSER_TEST_F(BookmarkAppUninstallDialogViewBrowserTest,
// Test that WebAppUninstallDialog cancels the uninstall if the Window
// which is passed to WebAppUninstallDialog::Create() is destroyed after
// WebAppUninstallDialogDelegateView is created.
IN_PROC_BROWSER_TEST_F(BookmarkAppUninstallDialogViewBrowserTest,
IN_PROC_BROWSER_TEST_F(WebAppUninstallDialogViewBrowserTest,
TrackParentWindowDestructionAfterViewCreation) {
scoped_refptr<const extensions::Extension> extension(BuildTestBookmarkApp());
extensions::ExtensionSystem::Get(browser()->profile())
->extension_service()
->AddExtension(extension.get());
AppId app_id = InstallTestWebApp(browser()->profile());
std::unique_ptr<web_app::WebAppUninstallDialog> dialog(
web_app::WebAppUninstallDialog::Create(
......@@ -88,7 +78,7 @@ IN_PROC_BROWSER_TEST_F(BookmarkAppUninstallDialogViewBrowserTest,
base::RunLoop run_loop;
bool was_uninstalled = false;
dialog->ConfirmUninstall(extension->id(),
dialog->ConfirmUninstall(app_id,
base::BindLambdaForTesting([&](bool uninstalled) {
was_uninstalled = uninstalled;
run_loop.Quit();
......@@ -101,22 +91,13 @@ IN_PROC_BROWSER_TEST_F(BookmarkAppUninstallDialogViewBrowserTest,
}
#if defined(OS_CHROMEOS)
// Test that we don't crash when uninstalling an extension from a bookmark app
// window in Ash. Context: crbug.com/825554
IN_PROC_BROWSER_TEST_F(BookmarkAppUninstallDialogViewBrowserTest,
BookmarkAppWindowAshCrash) {
scoped_refptr<const extensions::Extension> extension(BuildTestBookmarkApp());
extensions::ExtensionSystem::Get(browser()->profile())
->extension_service()
->AddExtension(extension.get());
WebApplicationInfo info;
info.app_url = GURL("https://test.com/");
const extensions::Extension* bookmark_app =
extensions::browsertest_util::InstallBookmarkApp(browser()->profile(),
info);
Browser* app_browser = extensions::browsertest_util::LaunchAppBrowser(
browser()->profile(), bookmark_app);
// Test that we don't crash when uninstalling a web app from a web app window in
// Ash. Context: crbug.com/825554
IN_PROC_BROWSER_TEST_F(WebAppUninstallDialogViewBrowserTest,
WebAppWindowAshCrash) {
AppId app_id = InstallTestWebApp(browser()->profile());
Browser* app_browser =
web_app::LaunchWebAppBrowser(browser()->profile(), app_id);
std::unique_ptr<web_app::WebAppUninstallDialog> dialog;
{
......@@ -128,20 +109,17 @@ IN_PROC_BROWSER_TEST_F(BookmarkAppUninstallDialogViewBrowserTest,
{
base::RunLoop run_loop;
dialog->ConfirmUninstall(extension->id(), base::DoNothing());
dialog->ConfirmUninstall(app_id, base::DoNothing());
run_loop.RunUntilIdle();
}
}
#endif // defined(OS_CHROMEOS)
class BookmarkAppUninstallDialogViewInteractiveBrowserTest
class WebAppUninstallDialogViewInteractiveBrowserTest
: public DialogBrowserTest {
public:
void ShowUi(const std::string& name) override {
extension_ = BuildTestBookmarkApp();
extensions::ExtensionSystem::Get(browser()->profile())
->extension_service()
->AddExtension(extension_.get());
AppId app_id = InstallTestWebApp(browser()->profile());
dialog_ = web_app::WebAppUninstallDialog::Create(
browser()->profile(), browser()->window()->GetNativeWindow());
......@@ -149,7 +127,7 @@ class BookmarkAppUninstallDialogViewInteractiveBrowserTest
base::RunLoop run_loop;
dialog_->SetDialogShownCallbackForTesting(run_loop.QuitClosure());
dialog_->ConfirmUninstall(extension_->id(), base::DoNothing());
dialog_->ConfirmUninstall(app_id, base::DoNothing());
run_loop.Run();
}
......@@ -161,11 +139,10 @@ class BookmarkAppUninstallDialogViewInteractiveBrowserTest
dialog_.reset();
}
scoped_refptr<const extensions::Extension> extension_;
std::unique_ptr<web_app::WebAppUninstallDialog> dialog_;
};
IN_PROC_BROWSER_TEST_F(BookmarkAppUninstallDialogViewInteractiveBrowserTest,
IN_PROC_BROWSER_TEST_F(WebAppUninstallDialogViewInteractiveBrowserTest,
InvokeUi_ManualUninstall) {
ShowAndVerifyUi();
}
......@@ -2065,7 +2065,7 @@ if (!is_android) {
"../browser/ui/views/translate/translate_bubble_test_utils_views.cc",
"../browser/ui/views/translate/translate_bubble_view_browsertest.cc",
"../browser/ui/views/translate/translate_language_browsertest.cc",
"../browser/ui/views/web_apps/bookmark_app_uninstall_dialog_browsertest.cc",
"../browser/ui/views/web_apps/web_app_uninstall_dialog_browsertest.cc",
"payments/payment_request_platform_browsertest_base.cc",
]
if (!is_chromeos) {
......
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