Commit 4cab334b authored by Eric Willigers's avatar Eric Willigers Committed by Commit Bot

WebAppNavigationBrowserTest

WebAppNavigationBrowserTest replaces BookmarkAppNavigationBrowserTest.
InstallTestWebApp() replaces InstallTestBookmarkApp()

Tests using the class no longer have any references to extensions,
and continue to pass if the DesktopPWAsWithoutExtensions flag is enabled.

To avoid a name class, the existing class WebAppNavigationBrowserTest is
renamed to WebAppNavigateBrowserTest. It tests the Navigate() function.

Bug: 1052722
TBR=jamescook@chromium.org
TBR=pbos@chromium.org

Change-Id: I8a09bb8f5c4bf563645ae5bca940015a05fbbe56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2060213Reviewed-by: default avatarMaggie Cai <mxcai@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Auto-Submit: Eric Willigers <ericwilligers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742038}
parent f28eb1e6
......@@ -15,7 +15,7 @@
#include "chrome/browser/ui/settings_window_manager_chromeos.h"
#include "chrome/browser/ui/settings_window_manager_observer_chromeos.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/web_applications/test/bookmark_app_navigation_browsertest.h"
#include "chrome/browser/ui/web_applications/test/web_app_navigation_browsertest.h"
#include "chrome/browser/web_applications/system_web_app_manager.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/common/chrome_features.h"
......@@ -72,7 +72,7 @@ Browser* GetLastActiveBrowser() {
using ChromeNewWindowClientBrowserTest = InProcessBrowserTest;
using ChromeNewWindowClientWebAppBrowserTest =
extensions::test::BookmarkAppNavigationBrowserTest;
web_app::WebAppNavigationBrowserTest;
// Tests that when we open a new window by pressing 'Ctrl-N', we should use the
// current active window's profile to determine on which profile's desktop we
......@@ -142,7 +142,7 @@ IN_PROC_BROWSER_TEST_F(ChromeNewWindowClientBrowserTest, IncognitoDisabled) {
}
IN_PROC_BROWSER_TEST_F(ChromeNewWindowClientWebAppBrowserTest, OpenWebApp) {
InstallTestBookmarkApp();
InstallTestWebApp();
const GURL app_url = https_server().GetURL(GetAppUrlHost(), GetAppUrlPath());
const char* key =
arc::ArcWebContentsData::ArcWebContentsData::kArcTransitionFlag;
......
......@@ -12,7 +12,7 @@
#include "chrome/browser/ui/views/location_bar/intent_picker_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "chrome/browser/ui/views/page_action/page_action_icon_view.h"
#include "chrome/browser/ui/web_applications/test/bookmark_app_navigation_browsertest.h"
#include "chrome/browser/ui/web_applications/test/web_app_navigation_browsertest.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/web_application_info.h"
#include "content/public/test/browser_test_utils.h"
......@@ -20,14 +20,14 @@
#include "url/gurl.h"
class IntentPickerBubbleViewBrowserTest
: public extensions::test::BookmarkAppNavigationBrowserTest,
: public web_app::WebAppNavigationBrowserTest,
public ::testing::WithParamInterface<std::string> {
public:
void SetUp() override {
// TODO(schenney): Stop disabling Paint Holding. crbug.com/1001189
scoped_feature_list_.InitWithFeatures({features::kIntentPicker},
{blink::features::kPaintHolding});
extensions::test::BookmarkAppNavigationBrowserTest::SetUp();
web_app::WebAppNavigationBrowserTest::SetUp();
}
void OpenNewTab(const GURL& url) {
......@@ -64,7 +64,7 @@ class IntentPickerBubbleViewBrowserTest
// bubble will only show up for android apps which is too hard to test.
IN_PROC_BROWSER_TEST_P(IntentPickerBubbleViewBrowserTest,
NavigationToInScopeLinkShowsIntentPicker) {
InstallTestBookmarkApp();
InstallTestWebApp();
const GURL in_scope_url =
https_server().GetURL(GetAppUrlHost(), GetInScopeUrlPath());
......@@ -87,7 +87,7 @@ IN_PROC_BROWSER_TEST_P(IntentPickerBubbleViewBrowserTest,
// installed app does not show the intent picker.
IN_PROC_BROWSER_TEST_P(IntentPickerBubbleViewBrowserTest,
NavigationToOutofScopeLinkDoesNotShowIntentPicker) {
InstallTestBookmarkApp();
InstallTestWebApp();
const GURL out_of_scope_url =
https_server().GetURL(GetAppUrlHost(), GetOutOfScopeUrlPath());
......@@ -107,10 +107,10 @@ IN_PROC_BROWSER_TEST_P(IntentPickerBubbleViewBrowserTest,
IN_PROC_BROWSER_TEST_P(
IntentPickerBubbleViewBrowserTest,
NavigationInAppWindowToInScopeLinkDoesNotShowIntentPicker) {
InstallTestBookmarkApp();
InstallTestWebApp();
// No intent picker should be seen when first opening the bookmark app.
Browser* app_browser = OpenTestBookmarkApp();
// No intent picker should be seen when first opening the web app.
Browser* app_browser = OpenTestWebApp();
EXPECT_EQ(nullptr, IntentPickerBubbleView::intent_picker_bubble());
{
......@@ -142,7 +142,7 @@ IN_PROC_BROWSER_TEST_P(
// tabs.
IN_PROC_BROWSER_TEST_P(IntentPickerBubbleViewBrowserTest,
IconVisibilityAfterTabSwitching) {
InstallTestBookmarkApp();
InstallTestWebApp();
const GURL in_scope_url =
https_server().GetURL(GetAppUrlHost(), GetInScopeUrlPath());
......@@ -167,7 +167,7 @@ IN_PROC_BROWSER_TEST_P(IntentPickerBubbleViewBrowserTest,
// Tests that the navigation in iframe doesn't affect intent picker icon
IN_PROC_BROWSER_TEST_P(IntentPickerBubbleViewBrowserTest,
IframeNavigationDoesNotAffectIntentPicker) {
InstallTestBookmarkApp();
InstallTestWebApp();
const GURL in_scope_url =
https_server().GetURL(GetAppUrlHost(), GetInScopeUrlPath());
......@@ -199,7 +199,7 @@ IN_PROC_BROWSER_TEST_P(IntentPickerBubbleViewBrowserTest,
// redirects to a URL that doesn't have an installed PWA.
IN_PROC_BROWSER_TEST_P(IntentPickerBubbleViewBrowserTest,
DoesNotShowIntentPickerWhenRedirectedOutOfScope) {
InstallTestBookmarkApp(GetOtherAppUrlHost(), /*app_scope=*/"/");
InstallTestWebApp(GetOtherAppUrlHost(), /*app_scope=*/"/");
const GURL out_of_scope_url =
https_server().GetURL(GetAppUrlHost(), GetOutOfScopeUrlPath());
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEB_APPLICATIONS_TEST_BOOKMARK_APP_NAVIGATION_BROWSERTEST_H_
#define CHROME_BROWSER_UI_WEB_APPLICATIONS_TEST_BOOKMARK_APP_NAVIGATION_BROWSERTEST_H_
#ifndef CHROME_BROWSER_UI_WEB_APPLICATIONS_TEST_WEB_APP_NAVIGATION_BROWSERTEST_H_
#define CHROME_BROWSER_UI_WEB_APPLICATIONS_TEST_WEB_APP_NAVIGATION_BROWSERTEST_H_
#include <memory>
#include <string>
......@@ -11,23 +11,23 @@
#include "base/callback_forward.h"
#include "base/files/file_path.h"
#include "base/test/metrics/histogram_tester.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/web_applications/components/web_app_id.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/content_mock_cert_verifier.h"
#include "extensions/common/extension.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/gurl.h"
class Browser;
class Profile;
namespace content {
class TestNavigationObserver;
class WebContents;
} // namespace content
namespace extensions {
namespace test {
namespace web_app {
class BookmarkAppNavigationBrowserTest : public ExtensionBrowserTest {
class WebAppNavigationBrowserTest : public InProcessBrowserTest {
public:
enum class LinkTarget {
SELF,
......@@ -80,8 +80,8 @@ class BookmarkAppNavigationBrowserTest : public ExtensionBrowserTest {
LinkTarget target,
const std::string& rel);
BookmarkAppNavigationBrowserTest();
~BookmarkAppNavigationBrowserTest() override;
WebAppNavigationBrowserTest();
~WebAppNavigationBrowserTest() override;
void SetUp() override;
void SetUpInProcessBrowserTestFixture() override;
......@@ -89,12 +89,13 @@ class BookmarkAppNavigationBrowserTest : public ExtensionBrowserTest {
void SetUpCommandLine(base::CommandLine* command_line) override;
void SetUpOnMainThread() override;
void InstallTestBookmarkApp();
void InstallOtherTestBookmarkApp();
const Extension* InstallTestBookmarkApp(const std::string& app_host,
const std::string& app_scope);
Profile* profile();
Browser* OpenTestBookmarkApp();
void InstallTestWebApp();
AppId InstallTestWebApp(const std::string& app_host,
const std::string& app_scope);
Browser* OpenTestWebApp();
// Navigates the active tab in |browser| to the launching page.
void NavigateToLaunchingPage(Browser* browser);
......@@ -106,13 +107,6 @@ class BookmarkAppNavigationBrowserTest : public ExtensionBrowserTest {
const GURL& target_url,
base::OnceClosure action);
// Checks that a new foreground tab is opened in an existing browser, that the
// new tab's browser is in the foreground, and that |app_browser| didn't
// navigate.
void TestAppActionOpensForegroundTab(Browser* app_browser,
const GURL& target_url,
base::OnceClosure action);
// Checks that no new windows are opened after running |action| and that the
// main browser window is still the active one and navigated to |target_url|.
// Returns true if there were no errors.
......@@ -126,11 +120,10 @@ class BookmarkAppNavigationBrowserTest : public ExtensionBrowserTest {
// Similar to net::MockCertVerifier, but also updates the CertVerifier
// used by the NetworkService.
content::ContentMockCertVerifier cert_verifier_;
const Extension* test_bookmark_app_;
AppId test_web_app_;
base::HistogramTester histogram_tester_;
};
} // namespace test
} // namespace extensions
} // namespace web_app
#endif // CHROME_BROWSER_UI_WEB_APPLICATIONS_TEST_BOOKMARK_APP_NAVIGATION_BROWSERTEST_H_
#endif // CHROME_BROWSER_UI_WEB_APPLICATIONS_TEST_WEB_APP_NAVIGATION_BROWSERTEST_H_
......@@ -16,7 +16,7 @@
namespace web_app {
class WebAppNavigationBrowserTest : public WebAppControllerBrowserTestBase {
class WebAppNavigateBrowserTest : public WebAppControllerBrowserTestBase {
public:
static GURL GetGoogleURL() { return GURL("http://www.google.com/"); }
......@@ -28,8 +28,8 @@ class WebAppNavigationBrowserTest : public WebAppControllerBrowserTestBase {
};
// This test verifies that navigating with "open_pwa_window_if_possible = true"
// opens a new app window if there is an installed Bookmark App for the URL.
IN_PROC_BROWSER_TEST_P(WebAppNavigationBrowserTest,
// opens a new app window if there is an installed Web App for the URL.
IN_PROC_BROWSER_TEST_P(WebAppNavigateBrowserTest,
AppInstalled_OpenAppWindowIfPossible_True) {
InstallPWA(GetGoogleURL());
......@@ -45,9 +45,9 @@ IN_PROC_BROWSER_TEST_P(WebAppNavigationBrowserTest,
}
// This test verifies that navigating with "open_pwa_window_if_possible = false"
// opens a new foreground tab even if there is an installed Bookmark App for the
// opens a new foreground tab even if there is an installed Web App for the
// URL.
IN_PROC_BROWSER_TEST_P(WebAppNavigationBrowserTest,
IN_PROC_BROWSER_TEST_P(WebAppNavigateBrowserTest,
AppInstalled_OpenAppWindowIfPossible_False) {
InstallPWA(GetGoogleURL());
......@@ -64,7 +64,7 @@ IN_PROC_BROWSER_TEST_P(WebAppNavigationBrowserTest,
// This test verifies that navigating with "open_pwa_window_if_possible = true"
// opens a new foreground tab when there is no app installed for the URL.
IN_PROC_BROWSER_TEST_P(WebAppNavigationBrowserTest,
IN_PROC_BROWSER_TEST_P(WebAppNavigateBrowserTest,
NoAppInstalled_OpenAppWindowIfPossible) {
int num_tabs = browser()->tab_strip_model()->count();
......@@ -79,7 +79,7 @@ IN_PROC_BROWSER_TEST_P(WebAppNavigationBrowserTest,
INSTANTIATE_TEST_SUITE_P(
All,
WebAppNavigationBrowserTest,
WebAppNavigateBrowserTest,
::testing::Values(ControllerType::kHostedAppController,
ControllerType::kUnifiedControllerWithBookmarkApp,
ControllerType::kUnifiedControllerWithWebApp),
......
......@@ -1360,7 +1360,7 @@ if (!is_android) {
"../browser/ui/web_applications/web_app_browsertest.cc",
"../browser/ui/web_applications/web_app_engagement_browsertest.cc",
"../browser/ui/web_applications/web_app_file_handling_browsertest.cc",
"../browser/ui/web_applications/web_app_navigation_browsertest.cc",
"../browser/ui/web_applications/web_app_navigate_browsertest.cc",
"../browser/ui/web_applications/web_app_ui_manager_impl_browsertest.cc",
"../browser/ui/web_applications/web_app_uninstall_browsertest.cc",
"../browser/ui/webauthn/authenticator_dialog_browsertest.cc",
......@@ -1877,8 +1877,8 @@ if (!is_android) {
"../browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_test_utils.h",
"../browser/ui/views/extensions/extension_dialog_browsertest.cc",
"../browser/ui/views/extensions/pwa_confirmation_bubble_view_browsertest.cc",
"../browser/ui/web_applications/test/bookmark_app_navigation_browsertest.cc",
"../browser/ui/web_applications/test/bookmark_app_navigation_browsertest.h",
"../browser/ui/web_applications/test/web_app_navigation_browsertest.cc",
"../browser/ui/web_applications/test/web_app_navigation_browsertest.h",
]
if (enable_autofill_assistant_api) {
......
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