Refactor dialog testing framework to allow arbitrary UI testing.
This introduces a new base class, TestBrowserUI, and reorganizes the existing
test code into a series of virtual functions so tests can provide the necessary
implementation for non-dialog cases.
This also adds a single consumer of this new base class, InfoBarUITest, to
verify it works.
Bug: 686285
Change-Id: I2b5a7c86347f5042ac5218c9fa90e94f68adf577
Reviewed-on: https://chromium-review.googlesource.com/804953
Commit-Queue: Peter Kasting <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Trent Apted <[email protected]>
Cr-Commit-Position: refs/heads/master@{#524855}
diff --git a/chrome/browser/download/download_danger_prompt_browsertest.cc b/chrome/browser/download/download_danger_prompt_browsertest.cc
index 7758a53..44a6f98 100644
--- a/chrome/browser/download/download_danger_prompt_browsertest.cc
+++ b/chrome/browser/download/download_danger_prompt_browsertest.cc
@@ -354,11 +354,11 @@
danger_type_ = danger_type;
invocation_type_ = invocation_type;
- RunDialog();
+ ShowAndVerifyUi();
}
private:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
ON_CALL(download_, GetURL()).WillByDefault(ReturnRef(download_url_));
ON_CALL(download_, GetReferrerUrl())
.WillByDefault(ReturnRef(GURL::EmptyGURL()));
@@ -389,38 +389,37 @@
};
IN_PROC_BROWSER_TEST_F(DownloadDangerPromptBrowserTest,
- InvokeDialog_DangerousFile) {
+ InvokeUi_DangerousFile) {
RunTest(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE, USER_INITIATED);
}
IN_PROC_BROWSER_TEST_F(DownloadDangerPromptBrowserTest,
- InvokeDialog_DangerousFileFromApi) {
+ InvokeUi_DangerousFileFromApi) {
RunTest(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE, FROM_DOWNLOAD_API);
}
-IN_PROC_BROWSER_TEST_F(DownloadDangerPromptBrowserTest,
- InvokeDialog_DangerousUrl) {
+IN_PROC_BROWSER_TEST_F(DownloadDangerPromptBrowserTest, InvokeUi_DangerousUrl) {
RunTest(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL, USER_INITIATED);
}
IN_PROC_BROWSER_TEST_F(DownloadDangerPromptBrowserTest,
- InvokeDialog_DangerousUrlFromApi) {
+ InvokeUi_DangerousUrlFromApi) {
RunTest(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL, FROM_DOWNLOAD_API);
}
IN_PROC_BROWSER_TEST_F(DownloadDangerPromptBrowserTest,
- InvokeDialog_UncommonContent) {
+ InvokeUi_UncommonContent) {
RunTest(content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT, USER_INITIATED);
}
IN_PROC_BROWSER_TEST_F(DownloadDangerPromptBrowserTest,
- InvokeDialog_UncommonContentFromApi) {
+ InvokeUi_UncommonContentFromApi) {
RunTest(content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT, FROM_DOWNLOAD_API);
}
IN_PROC_BROWSER_TEST_F(DownloadDangerPromptBrowserTest,
- InvokeDialog_PotentiallyUnwanted) {
+ InvokeUi_PotentiallyUnwanted) {
RunTest(content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED, USER_INITIATED);
}
IN_PROC_BROWSER_TEST_F(DownloadDangerPromptBrowserTest,
- InvokeDialog_PotentiallyUnwantedFromApi) {
+ InvokeUi_PotentiallyUnwantedFromApi) {
RunTest(content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED,
FROM_DOWNLOAD_API);
}
diff --git a/chrome/browser/extensions/bookmark_app_helper_browsertest.cc b/chrome/browser/extensions/bookmark_app_helper_browsertest.cc
index ce730444e..58259a8 100644
--- a/chrome/browser/extensions/bookmark_app_helper_browsertest.cc
+++ b/chrome/browser/extensions/bookmark_app_helper_browsertest.cc
@@ -92,7 +92,7 @@
run_loop.Run();
}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
ASSERT_TRUE(embedded_test_server()->Start());
const std::string path = (name == "CreateWindowedPWA")
@@ -124,17 +124,17 @@
};
// Launches an installation confirmation dialog for a bookmark app.
-IN_PROC_BROWSER_TEST_F(BookmarkAppHelperTest, InvokeDialog_CreateBookmarkApp) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(BookmarkAppHelperTest, InvokeUi_CreateBookmarkApp) {
+ ShowAndVerifyUi();
}
// Launches an installation confirmation dialog for a PWA.
-IN_PROC_BROWSER_TEST_F(BookmarkAppHelperTest, InvokeDialog_CreateWindowedPWA) {
+IN_PROC_BROWSER_TEST_F(BookmarkAppHelperTest, InvokeUi_CreateWindowedPWA) {
// The PWA dialog will be launched because manifest_test_page.html passes
// the PWA check, but the kDesktopPWAWindowing flag must also be enabled.
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(features::kDesktopPWAWindowing);
- RunDialog();
+ ShowAndVerifyUi();
}
} // namespace extensions
diff --git a/chrome/browser/infobars/infobars_browsertest.cc b/chrome/browser/infobars/infobars_browsertest.cc
index a887674..ef3787b9 100644
--- a/chrome/browser/infobars/infobars_browsertest.cc
+++ b/chrome/browser/infobars/infobars_browsertest.cc
@@ -16,9 +16,11 @@
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/test/test_browser_ui.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "components/infobars/core/infobar.h"
#include "content/public/browser/notification_service.h"
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/browser/extension_registry.h"
@@ -26,6 +28,10 @@
#include "extensions/browser/test_extension_registry_observer.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
+#if !defined(OS_CHROMEOS)
+#include "chrome/browser/ui/startup/default_browser_infobar_delegate.h"
+#endif
+
class InfoBarsTest : public InProcessBrowserTest {
public:
InfoBarsTest() {}
@@ -93,3 +99,106 @@
browser()->tab_strip_model()->GetActiveWebContents())->
infobar_count());
}
+
+namespace {
+
+// Helper to return when an InfoBar has been removed or replaced.
+class InfoBarObserver : public infobars::InfoBarManager::Observer {
+ public:
+ InfoBarObserver(infobars::InfoBarManager* manager, infobars::InfoBar* infobar)
+ : manager_(manager), infobar_(infobar) {
+ manager_->AddObserver(this);
+ }
+
+ // infobars::InfoBarManager::Observer:
+ void OnInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override {
+ if (infobar != infobar_)
+ return;
+ manager_->RemoveObserver(this);
+ run_loop_.Quit();
+ }
+ void OnInfoBarReplaced(infobars::InfoBar* old_infobar,
+ infobars::InfoBar* new_infobar) override {
+ OnInfoBarRemoved(old_infobar, false);
+ }
+
+ void WaitForRemoval() { run_loop_.Run(); }
+
+ private:
+ infobars::InfoBarManager* manager_;
+ infobars::InfoBar* infobar_;
+ base::RunLoop run_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(InfoBarObserver);
+};
+
+} // namespace
+
+class InfoBarUiTest : public UiBrowserTest {
+ public:
+ InfoBarUiTest() = default;
+
+ // TestBrowserUi:
+ void PreShow() override;
+ void ShowUi(const std::string& name) override;
+ bool VerifyUi() override;
+ void WaitForUserDismissal() override;
+
+ private:
+ // Returns the InfoBarService associated with the active tab.
+ InfoBarService* GetInfoBarService();
+
+ // Sets |infobars_| to a sorted (by pointer value) list of all infobars from
+ // the active tab.
+ void UpdateInfoBars();
+
+ infobars::InfoBarManager::InfoBars infobars_;
+
+ DISALLOW_COPY_AND_ASSIGN(InfoBarUiTest);
+};
+
+void InfoBarUiTest::PreShow() {
+ UpdateInfoBars();
+}
+
+void InfoBarUiTest::ShowUi(const std::string& name) {
+ // TODO(pkasting): Add other infobars, and check in VerifyUi() that the
+ // correct one was shown.
+#if defined(OS_CHROMEOS)
+ ADD_FAILURE() << "This infobar is not supported on this OS.";
+#else
+ chrome::DefaultBrowserInfoBarDelegate::Create(GetInfoBarService(),
+ browser()->profile());
+#endif
+}
+
+bool InfoBarUiTest::VerifyUi() {
+ infobars::InfoBarManager::InfoBars old_infobars = infobars_;
+ UpdateInfoBars();
+ auto added = base::STLSetDifference<infobars::InfoBarManager::InfoBars>(
+ infobars_, old_infobars);
+ return (added.size() == 1) &&
+ (added[0]->delegate()->GetIdentifier() ==
+ infobars::InfoBarDelegate::DEFAULT_BROWSER_INFOBAR_DELEGATE);
+}
+
+void InfoBarUiTest::WaitForUserDismissal() {
+ InfoBarObserver observer(GetInfoBarService(), infobars_.front());
+ observer.WaitForRemoval();
+}
+
+InfoBarService* InfoBarUiTest::GetInfoBarService() {
+ return InfoBarService::FromWebContents(
+ browser()->tab_strip_model()->GetActiveWebContents());
+}
+
+void InfoBarUiTest::UpdateInfoBars() {
+ infobars_ = GetInfoBarService()->infobars_;
+ std::sort(infobars_.begin(), infobars_.end());
+}
+
+#if !defined(OS_CHROMEOS)
+IN_PROC_BROWSER_TEST_F(InfoBarUiTest, InvokeUi_default_browser) {
+ ShowAndVerifyUi();
+}
+#endif
diff --git a/chrome/browser/password_manager/password_manager_browsertest.cc b/chrome/browser/password_manager/password_manager_browsertest.cc
index 29c09a9..3f77775 100644
--- a/chrome/browser/password_manager/password_manager_browsertest.cc
+++ b/chrome/browser/password_manager/password_manager_browsertest.cc
@@ -3518,23 +3518,20 @@
histograms.ExpectTotalCount(kHistogram, 0);
}
-// Harness for showing dialogs as part of the DialogBrowserTest suite. Allows
-// the dialogs to be shown interactively when invoked with, e.g.,
-// browser_tests --gtest_filter=BrowserDialogTest.Invoke --interactive
-// --dialog=PasswordManagerDialogBrowserTest.InvokeDialog_normal.
+// Harness for showing dialogs as part of the DialogBrowserTest suite.
class PasswordManagerDialogBrowserTest
: public SupportsTestDialog<PasswordManagerBrowserTestBase> {
public:
PasswordManagerDialogBrowserTest() = default;
- // SupportsTestDialog:
+ // SupportsTestUi:
void SetUp() override {
- // Secondary UI needs to be enabled before ShowDialog for the test to work.
+ // Secondary UI needs to be enabled before ShowUi for the test to work.
UseMdOnly();
- SupportsTestDialog::SetUp();
+ SupportsTestUi::SetUp();
}
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
// Note regarding flakiness: LocationBarBubbleDelegateView::ShowForReason()
// uses ShowInactive() unless the bubble is invoked with reason ==
// USER_GESTURE. This means that, so long as these dialogs are not triggered
@@ -3561,8 +3558,8 @@
DISALLOW_COPY_AND_ASSIGN(PasswordManagerDialogBrowserTest);
};
-IN_PROC_BROWSER_TEST_F(PasswordManagerDialogBrowserTest, InvokeDialog_normal) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PasswordManagerDialogBrowserTest, InvokeUi_normal) {
+ ShowAndVerifyUi();
}
// Verify that password manager ignores passwords on forms injected into
diff --git a/chrome/browser/permissions/permission_request_manager_browsertest.cc b/chrome/browser/permissions/permission_request_manager_browsertest.cc
index fb9ce5d2..6db3857 100644
--- a/chrome/browser/permissions/permission_request_manager_browsertest.cc
+++ b/chrome/browser/permissions/permission_request_manager_browsertest.cc
@@ -110,7 +110,7 @@
PermissionRequest* MakePermissionRequest(ContentSettingsType permission);
// TestBrowserDialog:
- void ShowDialog(const std::string& name) override;
+ void ShowUi(const std::string& name) override;
// Holds requests that do not delete themselves.
std::vector<std::unique_ptr<PermissionRequest>> owned_requests_;
@@ -143,7 +143,7 @@
return owned_requests_.back().get();
}
-void PermissionDialogTest::ShowDialog(const std::string& name) {
+void PermissionDialogTest::ShowUi(const std::string& name) {
constexpr const char* kMultipleName = "multiple";
constexpr struct {
const char* name;
@@ -470,7 +470,7 @@
// that could result in permission bubbles not being dismissed, and a problem
// referencing a temporary drag window. See http://crbug.com/754552.
IN_PROC_BROWSER_TEST_F(PermissionDialogTest, SwitchBrowserWindow) {
- ShowDialog("geolocation");
+ ShowUi("geolocation");
TabStripModel* strip = browser()->tab_strip_model();
// Drag out into a dragging window. E.g. see steps in [BrowserWindowController
@@ -494,54 +494,53 @@
}
// Host wants to run flash.
-IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeDialog_flash) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeUi_flash) {
+ ShowAndVerifyUi();
}
// Host wants to know your location.
-IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeDialog_geolocation) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeUi_geolocation) {
+ ShowAndVerifyUi();
}
// Host wants to show notifications.
-IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeDialog_notifications) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeUi_notifications) {
+ ShowAndVerifyUi();
}
// Host wants to use your microphone.
-IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeDialog_mic) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeUi_mic) {
+ ShowAndVerifyUi();
}
// Host wants to use your camera.
-IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeDialog_camera) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeUi_camera) {
+ ShowAndVerifyUi();
}
// Host wants to open email links.
-IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeDialog_protocol_handlers) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeUi_protocol_handlers) {
+ ShowAndVerifyUi();
}
// Host wants to use your MIDI devices.
-IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeDialog_midi) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeUi_midi) {
+ ShowAndVerifyUi();
}
// Shows a permissions bubble with multiple requests.
-IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeDialog_multiple) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PermissionDialogTest, InvokeUi_multiple) {
+ ShowAndVerifyUi();
}
// CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER is ChromeOS only.
#if defined(OS_CHROMEOS)
-#define MAYBE_InvokeDialog_protected_media InvokeDialog_protected_media
+#define MAYBE_InvokeUi_protected_media InvokeUi_protected_media
#else
-#define MAYBE_InvokeDialog_protected_media DISABLED_InvokeDialog_protected_media
+#define MAYBE_InvokeUi_protected_media DISABLED_InvokeUi_protected_media
#endif
-IN_PROC_BROWSER_TEST_F(PermissionDialogTest,
- MAYBE_InvokeDialog_protected_media) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PermissionDialogTest, MAYBE_InvokeUi_protected_media) {
+ ShowAndVerifyUi();
}
} // anonymous namespace
diff --git a/chrome/browser/ui/ask_google_for_suggestions_dialog_browsertest.cc b/chrome/browser/ui/ask_google_for_suggestions_dialog_browsertest.cc
index 6453113..22a9f839 100644
--- a/chrome/browser/ui/ask_google_for_suggestions_dialog_browsertest.cc
+++ b/chrome/browser/ui/ask_google_for_suggestions_dialog_browsertest.cc
@@ -15,7 +15,7 @@
AskGoogleForSuggestionsDialogTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
std::unique_ptr<SpellingBubbleModel> model =
base::MakeUnique<SpellingBubbleModel>(
browser()->profile(),
@@ -33,15 +33,13 @@
#if !defined(OS_MACOSX)
// Initially disabled except on Mac due to http://crbug.com/683808.
-#define MAYBE_InvokeDialog_default DISABLED_InvokeDialog_default
+#define MAYBE_InvokeUi_default DISABLED_InvokeUi_default
#else
-#define MAYBE_InvokeDialog_default InvokeDialog_default
+#define MAYBE_InvokeUi_default InvokeUi_default
#endif
-// Test that calls ShowDialog("default"). Interactive when run via
-// browser_tests --gtest_filter=BrowserDialogTest.Invoke --interactive
-// --dialog=AskGoogleForSuggestionsDialogTest.InvokeDialog_default
+// Test that calls ShowUi("default").
IN_PROC_BROWSER_TEST_F(AskGoogleForSuggestionsDialogTest,
- MAYBE_InvokeDialog_default) {
- RunDialog();
+ MAYBE_InvokeUi_default) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/autofill/card_unmask_prompt_view_browsertest.cc b/chrome/browser/ui/autofill/card_unmask_prompt_view_browsertest.cc
index bf2e23b..5b625a2 100644
--- a/chrome/browser/ui/autofill/card_unmask_prompt_view_browsertest.cc
+++ b/chrome/browser/ui/autofill/card_unmask_prompt_view_browsertest.cc
@@ -145,7 +145,7 @@
delegate_.reset(new TestCardUnmaskDelegate());
}
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
CardUnmaskPromptView* dialog =
CreateCardUnmaskPromptView(controller(), contents());
CreditCard card = test::GetMaskedServerCard();
@@ -183,38 +183,35 @@
DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViewBrowserTest);
};
-// Note: Although the following tests all just call RunDialog(), they execute
-// different behavior based on the test name's suffix. See ShowDialog().
-
-IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest, InvokeDialog_expired) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest, InvokeUi_expired) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest, InvokeDialog_valid) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest, InvokeUi_valid) {
+ ShowAndVerifyUi();
}
// This dialog will show a temporary error when Confirm is clicked.
IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest,
- InvokeDialog_valid_TemporaryError) {
- RunDialog();
+ InvokeUi_valid_TemporaryError) {
+ ShowAndVerifyUi();
}
// This dialog will show a permanent error when Confirm is clicked.
IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest,
- InvokeDialog_valid_PermanentError) {
- RunDialog();
+ InvokeUi_valid_PermanentError) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest, DisplayUI) {
- ShowDialog(kExpiryExpired);
+ ShowUi(kExpiryExpired);
}
// Makes sure the user can close the dialog while the verification success
// message is showing.
IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest,
EarlyCloseAfterSuccess) {
- ShowDialog(kExpiryExpired);
+ ShowUi(kExpiryExpired);
controller()->OnUnmaskResponse(base::ASCIIToUTF16("123"),
base::ASCIIToUTF16("10"),
base::ASCIIToUTF16("2020"), false);
@@ -236,7 +233,7 @@
// https://crbug.com/484376
IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest,
CloseTabWhileDialogShowing) {
- ShowDialog(kExpiryExpired);
+ ShowUi(kExpiryExpired);
// Simulate AutofillManager (the delegate in production code) being destroyed
// before CardUnmaskPromptViewBridge::OnConstrainedWindowClosed() is called.
FreeDelegate();
diff --git a/chrome/browser/ui/autofill/save_card_bubble_controller_impl_browsertest.cc b/chrome/browser/ui/autofill/save_card_bubble_controller_impl_browsertest.cc
index 5898906..23dd38b 100644
--- a/chrome/browser/ui/autofill/save_card_bubble_controller_impl_browsertest.cc
+++ b/chrome/browser/ui/autofill/save_card_bubble_controller_impl_browsertest.cc
@@ -37,7 +37,7 @@
}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
@@ -69,28 +69,26 @@
};
// Invokes a bubble asking the user if they want to save a credit card locally.
-// See test_browser_dialog.h for instructions on how to run.
-IN_PROC_BROWSER_TEST_F(SaveCardBubbleControllerImplTest, InvokeDialog_Local) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(SaveCardBubbleControllerImplTest, InvokeUi_Local) {
+ ShowAndVerifyUi();
}
// Invokes a bubble asking the user if they want to save a credit card to the
-// server. See test_browser_dialog.h for instructions on how to run.
-IN_PROC_BROWSER_TEST_F(SaveCardBubbleControllerImplTest, InvokeDialog_Server) {
- RunDialog();
+// server.
+IN_PROC_BROWSER_TEST_F(SaveCardBubbleControllerImplTest, InvokeUi_Server) {
+ ShowAndVerifyUi();
}
// Invokes a bubble asking the user if they want to save a credit card to the
-// server, with an added CVC step. See test_browser_dialog.h for instructions on
-// how to run.
+// server, with an added CVC step.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleControllerImplTest,
- InvokeDialog_Server_WithCvcStep) {
- RunDialog();
+ InvokeUi_Server_WithCvcStep) {
+ ShowAndVerifyUi();
}
// Tests that opening a new tab will hide the save card bubble.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleControllerImplTest, NewTabHidesDialog) {
- ShowDialog("Local");
+ ShowUi("Local");
EXPECT_NE(nullptr, controller()->save_card_bubble_view());
// Open a new tab page in the foreground.
ui_test_utils::NavigateToURLWithDisposition(
diff --git a/chrome/browser/ui/collected_cookies_browsertest.cc b/chrome/browser/ui/collected_cookies_browsertest.cc
index 2d79848..66e801f 100644
--- a/chrome/browser/ui/collected_cookies_browsertest.cc
+++ b/chrome/browser/ui/collected_cookies_browsertest.cc
@@ -24,7 +24,7 @@
CollectedCookiesTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
ASSERT_TRUE(embedded_test_server()->Start());
// Disable cookies.
@@ -62,16 +62,14 @@
DISALLOW_COPY_AND_ASSIGN(CollectedCookiesTestMd);
};
-// Test that calls ShowDialog("default"). Interactive when run via
-// browser_tests --gtest_filter=BrowserDialogTest.Invoke --interactive
-// --dialog=CollectedCookiesTestMd.InvokeDialog_default
-IN_PROC_BROWSER_TEST_F(CollectedCookiesTestMd, InvokeDialog_default) {
- RunDialog();
+// Test that calls ShowUi("default").
+IN_PROC_BROWSER_TEST_F(CollectedCookiesTestMd, InvokeUi_default) {
+ ShowAndVerifyUi();
}
// If this crashes on Windows, use http://crbug.com/79331
IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, DoubleDisplay) {
- ShowDialog(std::string());
+ ShowUi(std::string());
// Click on the info link a second time.
content::WebContents* web_contents =
@@ -81,7 +79,7 @@
// If this crashes on Windows, use http://crbug.com/79331
IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, NavigateAway) {
- ShowDialog(std::string());
+ ShowUi(std::string());
// Navigate to another page.
ui_test_utils::NavigateToURL(
diff --git a/chrome/browser/ui/extensions/extension_installed_bubble_browsertest.cc b/chrome/browser/ui/extensions/extension_installed_bubble_browsertest.cc
index 64e5f3c..43a49c21 100644
--- a/chrome/browser/ui/extensions/extension_installed_bubble_browsertest.cc
+++ b/chrome/browser/ui/extensions/extension_installed_bubble_browsertest.cc
@@ -37,7 +37,7 @@
std::unique_ptr<base::DictionaryValue> extra_keys = nullptr);
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override;
+ void ShowUi(const std::string& name) override;
BubbleController* GetExtensionBubbleControllerFromManager(
BubbleManager* manager) const {
@@ -81,7 +81,7 @@
return bubble;
}
-void ExtensionInstalledBubbleBrowserTest::ShowDialog(const std::string& name) {
+void ExtensionInstalledBubbleBrowserTest::ShowUi(const std::string& name) {
// Default to Manifest::COMPONENT to test all anchoring locations. Without
// this, a page action is added automatically, which will always be the
// preferred anchor.
@@ -107,38 +107,36 @@
}
IN_PROC_BROWSER_TEST_F(ExtensionInstalledBubbleBrowserTest,
- InvokeDialog_BrowserAction) {
- RunDialog();
+ InvokeUi_BrowserAction) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ExtensionInstalledBubbleBrowserTest,
- InvokeDialog_PageAction) {
- RunDialog();
+ InvokeUi_PageAction) {
+ ShowAndVerifyUi();
}
// Test anchoring to the app menu.
IN_PROC_BROWSER_TEST_F(ExtensionInstalledBubbleBrowserTest,
- InvokeDialog_InstalledByDefault) {
- RunDialog();
+ InvokeUi_InstalledByDefault) {
+ ShowAndVerifyUi();
}
// Test anchoring to the omnibox.
-IN_PROC_BROWSER_TEST_F(ExtensionInstalledBubbleBrowserTest,
- InvokeDialog_Omnibox) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(ExtensionInstalledBubbleBrowserTest, InvokeUi_Omnibox) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ExtensionInstalledBubbleBrowserTest,
- InvokeDialog_SignInPromo) {
- RunDialog();
+ InvokeUi_SignInPromo) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(ExtensionInstalledBubbleBrowserTest,
- InvokeDialog_NoAction) {
+IN_PROC_BROWSER_TEST_F(ExtensionInstalledBubbleBrowserTest, InvokeUi_NoAction) {
// Sign in to supppress the signin promo.
SigninManagerFactory::GetForProfile(browser()->profile())
->SetAuthenticatedAccountInfo("test", "[email protected]");
- RunDialog();
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ExtensionInstalledBubbleBrowserTest,
diff --git a/chrome/browser/ui/global_error/global_error_browsertest.cc b/chrome/browser/ui/global_error/global_error_browsertest.cc
index d62c355..9cdc39c4 100644
--- a/chrome/browser/ui/global_error/global_error_browsertest.cc
+++ b/chrome/browser/ui/global_error/global_error_browsertest.cc
@@ -76,13 +76,13 @@
}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override;
+ void ShowUi(const std::string& name) override;
private:
DISALLOW_COPY_AND_ASSIGN(GlobalErrorBubbleTest);
};
-void GlobalErrorBubbleTest::ShowDialog(const std::string& name) {
+void GlobalErrorBubbleTest::ShowUi(const std::string& name) {
content::WindowedNotificationObserver global_errors_updated(
chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED,
base::Bind([](const content::NotificationSource& source,
@@ -177,41 +177,41 @@
}
IN_PROC_BROWSER_TEST_F(GlobalErrorBubbleTest,
- InvokeDialog_ExtensionDisabledGlobalError) {
- RunDialog();
+ InvokeUi_ExtensionDisabledGlobalError) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(GlobalErrorBubbleTest,
- InvokeDialog_ExtensionDisabledGlobalErrorRemote) {
- RunDialog();
+ InvokeUi_ExtensionDisabledGlobalErrorRemote) {
+ ShowAndVerifyUi();
}
// This shows a non-persistent dialog during a RunLoop::RunUntilIdle(), so it's
// not possible to guarantee that events to dismiss the dialog are not processed
// as well. Disable by default to prevent flakiness in browser_tests.
IN_PROC_BROWSER_TEST_F(GlobalErrorBubbleTest,
- DISABLED_InvokeDialog_ExtensionGlobalError) {
- RunDialog();
+ DISABLED_InvokeUi_ExtensionGlobalError) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(GlobalErrorBubbleTest,
- InvokeDialog_ExternalInstallBubbleAlert) {
+ InvokeUi_ExternalInstallBubbleAlert) {
extensions::FeatureSwitch::ScopedOverride prompt(
extensions::FeatureSwitch::prompt_for_external_extensions(), true);
- RunDialog();
+ ShowAndVerifyUi();
}
// RecoveryInstallGlobalError only exists on Windows and Mac.
#if defined(OS_WIN) || defined(OS_MACOSX)
IN_PROC_BROWSER_TEST_F(GlobalErrorBubbleTest,
- InvokeDialog_RecoveryInstallGlobalError) {
- RunDialog();
+ InvokeUi_RecoveryInstallGlobalError) {
+ ShowAndVerifyUi();
}
#endif
// Signin global errors never happon on ChromeOS.
#if !defined(OS_CHROMEOS)
-IN_PROC_BROWSER_TEST_F(GlobalErrorBubbleTest, InvokeDialog_SigninGlobalError) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(GlobalErrorBubbleTest, InvokeUi_SigninGlobalError) {
+ ShowAndVerifyUi();
}
#endif
diff --git a/chrome/browser/ui/test/browser_dialog_browsertest.cc b/chrome/browser/ui/test/browser_ui_browsertest.cc
similarity index 67%
rename from chrome/browser/ui/test/browser_dialog_browsertest.cc
rename to chrome/browser/ui/test/browser_ui_browsertest.cc
index d3d7759..9aa2130 100644
--- a/chrome/browser/ui/test/browser_dialog_browsertest.cc
+++ b/chrome/browser/ui/test/browser_ui_browsertest.cc
@@ -7,51 +7,51 @@
#include "base/test/launcher/test_launcher.h"
#include "base/test/test_switches.h"
#include "base/test/test_timeouts.h"
-#include "chrome/browser/ui/test/test_browser_dialog.h"
+#include "build/build_config.h"
+#include "chrome/browser/ui/test/test_browser_ui.h"
#include "content/public/common/content_switches.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/compositor/compositor_switches.h"
namespace {
-// Switch for BrowserDialogTest.Invoke to spawn a subprocess testing the
-// provided argument under a consistent setup.
-constexpr const char kDialogSwitch[] = "dialog";
+// Switch for BrowserUiTest.Invoke to spawn a subprocess testing the provided
+// argument under a consistent setup.
+constexpr const char kUiSwitch[] = "ui";
-// Pattern to search in test names that indicate support for dialog testing.
-constexpr const char kDialogPattern[] = "InvokeDialog_";
+// Pattern to search in test names that indicate support for UI testing.
+constexpr const char kUiPattern[] = "InvokeUi_";
} // namespace
-// Adds a browser_test entry point into the dialog testing framework. Without a
-// --dialog specified, just lists the available dialogs and exits.
-TEST(BrowserDialogTest, Invoke) {
+// Adds a browser_test entry point into the UI testing framework. Without a
+// --ui specified, just lists the available UIs and exits.
+TEST(BrowserUiTest, Invoke) {
const base::CommandLine& invoker = *base::CommandLine::ForCurrentProcess();
- const std::string dialog_name = invoker.GetSwitchValueASCII(kDialogSwitch);
+ const std::string ui_name = invoker.GetSwitchValueASCII(kUiSwitch);
- std::set<std::string> dialog_cases;
+ std::set<std::string> ui_cases;
const testing::UnitTest* unit_test = testing::UnitTest::GetInstance();
for (int i = 0; i < unit_test->total_test_case_count(); ++i) {
const testing::TestCase* test_case = unit_test->GetTestCase(i);
for (int j = 0; j < test_case->total_test_count(); ++j) {
const char* name = test_case->GetTestInfo(j)->name();
- if (strstr(name, kDialogPattern))
- dialog_cases.insert(test_case->name() + std::string(".") + name);
+ if (strstr(name, kUiPattern))
+ ui_cases.insert(test_case->name() + std::string(".") + name);
}
}
- if (dialog_name.empty()) {
+ if (ui_name.empty()) {
std::string case_list;
- for (const std::string& name : dialog_cases)
+ for (const std::string& name : ui_cases)
case_list += "\t" + name + "\n";
- VLOG(0) << "\nPass one of the following after --" << kDialogSwitch << "=\n"
+ VLOG(0) << "\nPass one of the following after --" << kUiSwitch << "=\n"
<< case_list;
return;
}
- auto it = dialog_cases.find(dialog_name);
- ASSERT_NE(it, dialog_cases.end()) << "Dialog '" << dialog_name
- << "' not found.";
+ auto it = ui_cases.find(ui_name);
+ ASSERT_NE(it, ui_cases.end()) << "UI '" << ui_name << "' not found.";
// Don't create test output for the subprocess (the paths will conflict).
base::CommandLine::StringVector argv = invoker.argv();
@@ -63,8 +63,8 @@
});
base::CommandLine command(argv);
- // Replace TestBrowserDialog.Invoke with |dialog_name|.
- command.AppendSwitchASCII(base::kGTestFilterFlag, dialog_name);
+ // Replace TestBrowserUi.Invoke with |ui_name|.
+ command.AppendSwitchASCII(base::kGTestFilterFlag, ui_name);
base::LaunchOptions options;
diff --git a/chrome/browser/ui/test/test_browser_dialog.cc b/chrome/browser/ui/test/test_browser_dialog.cc
index d6af0f39..95ede0a 100644
--- a/chrome/browser/ui/test/test_browser_dialog.cc
+++ b/chrome/browser/ui/test/test_browser_dialog.cc
@@ -4,19 +4,12 @@
#include "chrome/browser/ui/test/test_browser_dialog.h"
-#include "base/command_line.h"
+#include "base/logging.h"
#include "base/run_loop.h"
#include "base/stl_util.h"
-#include "base/test/gtest_util.h"
-#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
-#include "chrome/browser/platform_util.h"
-#include "chrome/common/chrome_features.h"
-#include "ui/base/ui_base_features.h"
-#include "ui/views/test/widget_test.h"
-#include "ui/views/widget/widget.h"
-#include "ui/views/widget/widget_observer.h"
+#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_CHROMEOS)
#include "ash/public/cpp/config.h"
@@ -28,121 +21,102 @@
#include "chrome/browser/ui/test/test_browser_dialog_mac.h"
#endif
+#if defined(TOOLKIT_VIEWS)
+#include "ui/views/test/widget_test.h"
+#include "ui/views/widget/widget_observer.h"
+#endif
+
namespace {
-// An automatic action for WidgetCloser to post to the RunLoop.
-// TODO(tapted): Explore asynchronous Widget::Close() and DialogClientView::
-// {Accept,Cancel}Window() approaches to test other dialog lifetimes.
-enum class DialogAction {
- INTERACTIVE, // Run interactively.
- CLOSE_NOW, // Call Widget::CloseNow().
- CLOSE, // Call Widget::Close().
-};
-
-// Helper to break out of the nested run loop that runs a test dialog.
-class WidgetCloser : public views::WidgetObserver {
+#if defined(TOOLKIT_VIEWS)
+// Helper to return when a Widget has been closed.
+// TODO(pkasting): This is pretty similar to views::test::WidgetClosingObserver
+// in ui/views/test/widget_test.h but keys off widget destruction rather than
+// closing. Can the two be combined?
+class WidgetCloseObserver : public views::WidgetObserver {
public:
- WidgetCloser(views::Widget* widget, DialogAction action)
- : action_(action), widget_(widget), weak_ptr_factory_(this) {
+ explicit WidgetCloseObserver(views::Widget* widget) : widget_(widget) {
widget->AddObserver(this);
- if (action == DialogAction::INTERACTIVE)
- return;
-
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindOnce(&WidgetCloser::CloseAction,
- weak_ptr_factory_.GetWeakPtr()));
}
- // WidgetObserver:
+ // views::WidgetObserver:
void OnWidgetDestroyed(views::Widget* widget) override {
widget_->RemoveObserver(this);
widget_ = nullptr;
run_loop_.Quit();
}
- void Wait() { run_loop_.Run(); }
+ void WaitForDestroy() { run_loop_.Run(); }
+
+ protected:
+ views::Widget* widget() { return widget_; }
private:
- void CloseAction() {
- if (!widget_)
- return;
+ views::Widget* widget_;
+ base::RunLoop run_loop_;
- switch (action_) {
- case DialogAction::CLOSE_NOW:
- widget_->CloseNow();
- break;
- case DialogAction::CLOSE:
- widget_->Close();
- break;
- case DialogAction::INTERACTIVE:
- NOTREACHED();
- break;
- }
+ DISALLOW_COPY_AND_ASSIGN(WidgetCloseObserver);
+};
+
+// Helper to close a Widget. Inherits from WidgetCloseObserver since regardless
+// of whether the close is done synchronously, we always want callers to wait
+// for it to complete.
+class WidgetCloser : public WidgetCloseObserver {
+ public:
+ WidgetCloser(views::Widget* widget, bool async)
+ : WidgetCloseObserver(widget) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::BindOnce(&WidgetCloser::CloseWidget,
+ weak_ptr_factory_.GetWeakPtr(), async));
}
- base::RunLoop run_loop_;
- const DialogAction action_;
- views::Widget* widget_;
+ private:
+ void CloseWidget(bool async) {
+ if (!widget())
+ return;
- base::WeakPtrFactory<WidgetCloser> weak_ptr_factory_;
+ if (async)
+ widget()->Close();
+ else
+ widget()->CloseNow();
+ }
+
+ base::WeakPtrFactory<WidgetCloser> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(WidgetCloser);
};
-
-// Extracts the |name| argument for ShowDialog() from the current test case.
-// E.g. for InvokeDialog_name (or DISABLED_InvokeDialog_name) returns "name".
-std::string NameFromTestCase() {
- const std::string name = base::TestNameWithoutDisabledPrefix(
- testing::UnitTest::GetInstance()->current_test_info()->name());
- std::string::size_type underscore = name.find('_');
- return underscore == std::string::npos ? std::string()
- : name.substr(underscore + 1);
-}
+#endif // defined(TOOLKIT_VIEWS)
} // namespace
-TestBrowserDialog::TestBrowserDialog() {}
+TestBrowserDialog::TestBrowserDialog() = default;
+TestBrowserDialog::~TestBrowserDialog() = default;
-void TestBrowserDialog::RunDialog() {
+void TestBrowserDialog::PreShow() {
+// The rest of this class assumes the child dialog is toolkit-views. So, for
+// Mac, it will only work when MD for secondary UI is enabled. Without this, a
+// Cocoa dialog will be created, which TestBrowserDialog doesn't support.
+// Force kSecondaryUiMd on Mac to get coverage on the bots. Leave it optional
+// elsewhere so that the non-MD dialog can be invoked to compare.
#if defined(OS_MACOSX)
- // The rest of this method assumes the child dialog is toolkit-views. So, for
- // Mac, it will only work when MD for secondary UI is enabled. Without this, a
- // Cocoa dialog will be created, which TestBrowserDialog doesn't support.
- // Force kSecondaryUiMd on Mac to get coverage on the bots. Leave it optional
- // elsewhere so that the non-MD dialog can be invoked to compare. Note that
- // since SetUp() has already been called, some parts of the toolkit may
- // already be initialized without MD - this is just to ensure Cocoa dialogs
- // are not selected.
- base::test::ScopedFeatureList enable_views_on_mac_always;
- enable_views_on_mac_always.InitWithFeatures(
- {features::kSecondaryUiMd, features::kShowAllDialogsWithViewsToolkit},
- {});
+ // Note that since SetUp() has already been called, some parts of the toolkit
+ // may already be initialized without MD - this is just to ensure Cocoa
+ // dialogs are not selected.
+ UseMdOnly();
#endif
- views::Widget::Widgets widgets_before =
- views::test::WidgetTest::GetAllWidgets();
-#if defined(OS_CHROMEOS)
- // GetAllWidgets() uses AuraTestHelper to find the aura root window, but
- // that's not used on browser_tests, so ask ash. Under mash the MusClient
- // provides the list of root windows, so this isn't needed.
- if (chromeos::GetAshConfig() != ash::Config::MASH) {
- views::Widget::GetAllChildWidgets(ash::Shell::GetPrimaryRootWindow(),
- &widgets_before);
- }
-#endif // OS_CHROMEOS
+ UpdateWidgets();
+}
- ShowDialog(NameFromTestCase());
- views::Widget::Widgets widgets_after =
- views::test::WidgetTest::GetAllWidgets();
-#if defined(OS_CHROMEOS)
- if (chromeos::GetAshConfig() != ash::Config::MASH) {
- views::Widget::GetAllChildWidgets(ash::Shell::GetPrimaryRootWindow(),
- &widgets_after);
- }
-#endif // OS_CHROMEOS
+// This can return false if no dialog was shown, if the dialog shown wasn't a
+// toolkit-views dialog, or if more than one child dialog was shown.
+bool TestBrowserDialog::VerifyUi() {
+#if defined(TOOLKIT_VIEWS)
+ views::Widget::Widgets widgets_before = widgets_;
+ UpdateWidgets();
- auto added = base::STLSetDifference<std::vector<views::Widget*>>(
- widgets_after, widgets_before);
+ auto added =
+ base::STLSetDifference<views::Widget::Widgets>(widgets_, widgets_before);
if (added.size() > 1) {
// Some tests create a standalone window to anchor a dialog. In those cases,
@@ -151,38 +125,57 @@
return !widget->widget_delegate()->AsDialogDelegate();
});
}
+ widgets_ = added;
- // This can fail if no dialog was shown, if the dialog shown wasn't a toolkit-
- // views dialog, or if more than one child dialog was shown.
- ASSERT_EQ(1u, added.size());
+ return added.size() == 1;
+#else
+ NOTIMPLEMENTED();
+ return false;
+#endif
+}
- DialogAction action = DialogAction::CLOSE_NOW;
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- internal::kInteractiveSwitch)) {
- action = DialogAction::INTERACTIVE;
- } else if (AlwaysCloseAsynchronously()) {
- // TODO(tapted): Iterate over close methods when non-interactive for greater
- // test coverage.
- action = DialogAction::CLOSE;
- }
-
- WidgetCloser closer(added[0], action);
+void TestBrowserDialog::WaitForUserDismissal() {
#if defined(OS_MACOSX)
internal::TestBrowserDialogInteractiveSetUp();
#endif
- closer.Wait();
+
+#if defined(TOOLKIT_VIEWS)
+ ASSERT_FALSE(widgets_.empty());
+ WidgetCloseObserver observer(*widgets_.begin());
+ observer.WaitForDestroy();
+#else
+ NOTIMPLEMENTED();
+#endif
}
-void TestBrowserDialog::UseMdOnly() {
-#if defined(OS_MACOSX)
- maybe_enable_md_.InitWithFeatures(
- {features::kSecondaryUiMd, features::kShowAllDialogsWithViewsToolkit},
- {});
+void TestBrowserDialog::DismissUi() {
+#if defined(TOOLKIT_VIEWS)
+ ASSERT_FALSE(widgets_.empty());
+ WidgetCloser closer(*widgets_.begin(), AlwaysCloseAsynchronously());
+ closer.WaitForDestroy();
#else
- maybe_enable_md_.InitWithFeatures({features::kSecondaryUiMd}, {});
+ NOTIMPLEMENTED();
#endif
}
bool TestBrowserDialog::AlwaysCloseAsynchronously() {
+ // TODO(tapted): Iterate over close methods for greater test coverage.
return false;
}
+
+void TestBrowserDialog::UpdateWidgets() {
+#if defined(TOOLKIT_VIEWS)
+ widgets_ = views::test::WidgetTest::GetAllWidgets();
+#if defined(OS_CHROMEOS)
+ // GetAllWidgets() uses AuraTestHelper to find the aura root window, but
+ // that's not used on browser_tests, so ask ash. Under mash the MusClient
+ // provides the list of root windows, so this isn't needed.
+ if (chromeos::GetAshConfig() != ash::Config::MASH) {
+ views::Widget::GetAllChildWidgets(ash::Shell::GetPrimaryRootWindow(),
+ &widgets_);
+ }
+#endif // OS_CHROMEOS
+#else
+ NOTIMPLEMENTED();
+#endif
+}
diff --git a/chrome/browser/ui/test/test_browser_dialog.h b/chrome/browser/ui/test/test_browser_dialog.h
index 459b157c..6c7445d2 100644
--- a/chrome/browser/ui/test/test_browser_dialog.h
+++ b/chrome/browser/ui/test/test_browser_dialog.h
@@ -5,72 +5,28 @@
#ifndef CHROME_BROWSER_UI_TEST_TEST_BROWSER_DIALOG_H_
#define CHROME_BROWSER_UI_TEST_TEST_BROWSER_DIALOG_H_
-#include <string>
-#include <utility>
-#include <vector>
-
#include "base/macros.h"
-#include "base/test/scoped_feature_list.h"
+#include "chrome/browser/ui/test/test_browser_ui.h"
#include "chrome/test/base/in_process_browser_test.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/gfx/native_widget_types.h"
-// TestBrowserDialog provides a way to register an InProcessBrowserTest testing
-// harness with a framework that invokes Chrome browser dialogs in a consistent
-// way. It optionally provides a way to invoke dialogs "interactively". This
-// allows screenshots to be generated easily, with the same test data, to assist
-// with UI review. It also provides a registry of dialogs so they can be
-// systematically checked for subtle changes and regressions.
-//
-// To use TestBrowserDialog, a test harness should inherit from
-// DialogBrowserTest rather than InProcessBrowserTest. If the dialog under test
-// has only a single mode of operation, the only other requirement on the test
-// harness is an override:
-//
-// class FooDialogTest : public DialogBrowserTest {
-// public:
-// ..
-// // DialogBrowserTest:
-// void ShowDialog(const std::string& name) override {
-// /* Show dialog attached to browser() and leave it open. */
-// }
-// ..
-// };
-//
-// then in the foo_dialog_browsertest.cc, define any number of
-//
-// IN_PROC_BROWSER_TEST_F(FooDialogTest, InvokeDialog_name) {
-// RunDialog();
-// }
-//
-// The string after "InvokeDialog_" (here, "name") is the argument given to
-// ShowDialog(). In a regular test suite run, RunDialog() shows the dialog and
-// immediately closes it (after ensuring it was actually created).
-//
-// To get a list of all available dialogs, run the `BrowserDialogTest.Invoke`
-// test case without other arguments. I.e.
-//
-// browser_tests --gtest_filter=BrowserDialogTest.Invoke
-//
-// Dialogs listed can be shown interactively using the --dialog argument. E.g.
-//
-// browser_tests --gtest_filter=BrowserDialogTest.Invoke --interactive
-// --dialog=FooDialogTest.InvokeDialog_name
-class TestBrowserDialog {
+#if defined(TOOLKIT_VIEWS)
+#include "ui/views/widget/widget.h"
+#endif
+
+// A dialog-specific subclass of TestBrowserUi, which will verify that a test
+// showed a single dialog.
+class TestBrowserDialog : public TestBrowserUi {
protected:
TestBrowserDialog();
+ ~TestBrowserDialog() override;
- // Runs the dialog whose name corresponds to the current test case.
- void RunDialog();
+ // TestBrowserUi:
+ void PreShow() override;
+ bool VerifyUi() override;
+ void WaitForUserDismissal() override;
+ void DismissUi() override;
- // Convenience method to force-enable features::kSecondaryUiMd for this test
- // on all platforms. This should be called in an override of SetUp().
- void UseMdOnly();
-
- // Show the dialog corresponding to |name| and leave it open.
- virtual void ShowDialog(const std::string& name) = 0;
-
- // Whether to always close asynchronously using Widget::Close(). This covers
+ // Whether to close asynchronously using Widget::Close(). This covers
// codepaths relying on DialogDelegate::Close(), which isn't invoked by
// Widget::CloseNow(). Dialogs should support both, since the OS can initiate
// the destruction of dialogs, e.g., during logoff which bypass
@@ -78,31 +34,20 @@
virtual bool AlwaysCloseAsynchronously();
private:
- base::test::ScopedFeatureList maybe_enable_md_;
+#if defined(TOOLKIT_VIEWS)
+ // Stores the current widgets in |widgets_|.
+ void UpdateWidgets();
+
+ // The widgets present before/after showing UI.
+ views::Widget::Widgets widgets_;
+#endif // defined(TOOLKIT_VIEWS)
DISALLOW_COPY_AND_ASSIGN(TestBrowserDialog);
};
-// Helper to mix in a TestBrowserDialog to an existing test harness. |Base|
-// must be a descendant of InProcessBrowserTest.
template <class Base>
-class SupportsTestDialog : public Base, public TestBrowserDialog {
- protected:
- template <class... Args>
- explicit SupportsTestDialog(Args&&... args)
- : Base(std::forward<Args>(args)...) {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SupportsTestDialog);
-};
+using SupportsTestDialog = SupportsTestUi<Base, TestBrowserDialog>;
using DialogBrowserTest = SupportsTestDialog<InProcessBrowserTest>;
-namespace internal {
-
-// When present on the command line, runs the test in an interactive mode.
-constexpr const char kInteractiveSwitch[] = "interactive";
-
-} // namespace internal
-
#endif // CHROME_BROWSER_UI_TEST_TEST_BROWSER_DIALOG_H_
diff --git a/chrome/browser/ui/test/test_browser_dialog_mac.h b/chrome/browser/ui/test/test_browser_dialog_mac.h
index eb817b8..c82595ad 100644
--- a/chrome/browser/ui/test/test_browser_dialog_mac.h
+++ b/chrome/browser/ui/test/test_browser_dialog_mac.h
@@ -7,7 +7,11 @@
namespace internal {
-// Platform dependent fixture for TestBrowserDialog.
+// Platform dependent fixture for TestBrowserDialog. browser_tests is not built
+// as an .app bundle, so windows from it cannot normally be activated. But for
+// interactive tests, dialogs need to be activated. This hacks the process type
+// so that they can be, and activates the application in case something already
+// tried (but failed) to activate it before this.
void TestBrowserDialogInteractiveSetUp();
} // namespace internal
diff --git a/chrome/browser/ui/test/test_browser_ui.cc b/chrome/browser/ui/test/test_browser_ui.cc
new file mode 100644
index 0000000..9d8cef0
--- /dev/null
+++ b/chrome/browser/ui/test/test_browser_ui.cc
@@ -0,0 +1,54 @@
+// Copyright 2017 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 "chrome/browser/ui/test/test_browser_ui.h"
+
+#include "base/command_line.h"
+#include "base/test/gtest_util.h"
+#include "base/test/scoped_feature_list.h"
+#include "build/build_config.h"
+#include "chrome/common/chrome_features.h"
+#include "ui/base/ui_base_features.h"
+
+namespace {
+
+// Extracts the |name| argument for ShowUi() from the current test case name.
+// E.g. for InvokeUi_name (or DISABLED_InvokeUi_name) returns "name".
+std::string NameFromTestCase() {
+ const std::string name = base::TestNameWithoutDisabledPrefix(
+ testing::UnitTest::GetInstance()->current_test_info()->name());
+ size_t underscore = name.find('_');
+ return underscore == std::string::npos ? std::string()
+ : name.substr(underscore + 1);
+}
+
+} // namespace
+
+TestBrowserUi::TestBrowserUi() = default;
+TestBrowserUi::~TestBrowserUi() = default;
+
+void TestBrowserUi::ShowAndVerifyUi() {
+ PreShow();
+ ShowUi(NameFromTestCase());
+ ASSERT_TRUE(VerifyUi());
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ internal::kInteractiveSwitch))
+ WaitForUserDismissal();
+ else
+ DismissUi();
+}
+
+void TestBrowserUi::UseMdOnly() {
+ if (enable_md_)
+ return;
+
+ enable_md_ = std::make_unique<base::test::ScopedFeatureList>();
+ enable_md_->InitWithFeatures(
+#if defined(OS_MACOSX)
+ {features::kSecondaryUiMd, features::kShowAllDialogsWithViewsToolkit},
+#else
+ {features::kSecondaryUiMd},
+#endif
+ {});
+}
diff --git a/chrome/browser/ui/test/test_browser_ui.h b/chrome/browser/ui/test/test_browser_ui.h
new file mode 100644
index 0000000..57d1f9f
--- /dev/null
+++ b/chrome/browser/ui/test/test_browser_ui.h
@@ -0,0 +1,136 @@
+// Copyright 2017 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.
+
+#ifndef CHROME_BROWSER_UI_TEST_TEST_BROWSER_UI_H_
+#define CHROME_BROWSER_UI_TEST_TEST_BROWSER_UI_H_
+
+#include <memory>
+#include <string>
+
+#include "base/macros.h"
+#include "chrome/test/base/in_process_browser_test.h"
+
+namespace base {
+namespace test {
+class ScopedFeatureList;
+} // namespace test
+} // namespace base
+
+// TestBrowserUi provides a way to register an InProcessBrowserTest testing
+// harness with a framework that invokes Chrome browser UI in a consistent way.
+// It optionally provides a way to invoke UI "interactively". This allows
+// screenshots to be generated easily, with the same test data, to assist with
+// UI review. It also provides a UI registry so pieces of UI can be
+// systematically checked for subtle changes and regressions.
+//
+// To use TestBrowserUi, a test harness should inherit from UiBrowserTest rather
+// than InProcessBrowserTest, then provide some overrides:
+//
+// class FooUiTest : public UiBrowserTest {
+// public:
+// ..
+// // UiBrowserTest:
+// void ShowUi(const std::string& name) override {
+// /* Show Ui attached to browser() and leave it open. */
+// }
+//
+// bool VerifyUi() override {
+// /* Return true if the UI was successfully shown. */
+// }
+//
+// void WaitForUserDismissal() override {
+// /* Block until the user closes the UI. */
+// }
+// ..
+// };
+//
+// Further overrides are available for tests which need to do work before
+// showing any UI or when closing in non-interactive mode. For tests whose UI
+// is a dialog, there's also the TestBrowserDialog class, which provides all but
+// ShowUi() already; see test_browser_dialog.h.
+//
+// The test may then define any number of cases for individual pieces of UI:
+//
+// IN_PROC_BROWSER_TEST_F(FooUiTest, InvokeUi_name) {
+// // Perform optional setup here; then:
+// ShowAndVerifyUi();
+// }
+//
+// The string after "InvokeUi_" (here, "name") is the argument given to
+// ShowUi(). In a regular test suite run, ShowAndVerifyUi() shows the UI and
+// immediately closes it (after ensuring it was actually created).
+//
+// To get a list of all available UI, run the "BrowserUiTest.Invoke" test case
+// without other arguments, i.e.:
+//
+// browser_tests --gtest_filter=BrowserUiTest.Invoke
+//
+// UI listed can be shown interactively using the --ui argument. E.g.
+//
+// browser_tests --gtest_filter=BrowserUiTest.Invoke --interactive
+// --ui=FooUiTest.InvokeUi_name
+class TestBrowserUi {
+ protected:
+ TestBrowserUi();
+ virtual ~TestBrowserUi();
+
+ // Called by ShowAndVerifyUi() before ShowUi(), to provide a place to do any
+ // setup needed in order to successfully verify the UI post-show.
+ virtual void PreShow() {}
+
+ // Should be implemented in individual tests to show UI with the given |name|
+ // (which will be supplied by the test case).
+ virtual void ShowUi(const std::string& name) = 0;
+
+ // Called by ShowAndVerifyUi() after ShowUi(). Returns whether the UI was
+ // successfully shown.
+ virtual bool VerifyUi() = 0;
+
+ // Called by ShowAndVerifyUi() after VerifyUi(), in the case where the test is
+ // interactive. This should block until the UI has been dismissed.
+ virtual void WaitForUserDismissal() = 0;
+
+ // Called by ShowAndVerifyUi() after VerifyUi(), in the case where the test is
+ // non-interactive. This should do anything necessary to close the UI before
+ // browser shutdown.
+ virtual void DismissUi() {}
+
+ // Shows the UI whose name corresponds to the current test case, and verifies
+ // it was successfully shown. Most test cases can simply invoke this directly
+ // with no other code.
+ void ShowAndVerifyUi();
+
+ // Convenience method to force-enable features::kSecondaryUiMd for this test
+ // on all platforms. This should be called in an override of SetUp().
+ void UseMdOnly();
+
+ private:
+ // If non-null, forces secondary UI to MD.
+ std::unique_ptr<base::test::ScopedFeatureList> enable_md_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestBrowserUi);
+};
+
+// Helper to mix in a TestBrowserUi to an existing test harness. |Base| must be
+// a descendant of InProcessBrowserTest.
+template <class Base, class TestUi>
+class SupportsTestUi : public Base, public TestUi {
+ protected:
+ template <class... Args>
+ explicit SupportsTestUi(Args&&... args) : Base(std::forward<Args>(args)...) {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SupportsTestUi);
+};
+
+using UiBrowserTest = SupportsTestUi<InProcessBrowserTest, TestBrowserUi>;
+
+namespace internal {
+
+// When present on the command line, runs the test in an interactive mode.
+constexpr const char kInteractiveSwitch[] = "interactive";
+
+} // namespace internal
+
+#endif // CHROME_BROWSER_UI_TEST_TEST_BROWSER_UI_H_
diff --git a/chrome/browser/ui/update_chrome_dialog_browsertest.cc b/chrome/browser/ui/update_chrome_dialog_browsertest.cc
index fb2bec3..29db4592 100644
--- a/chrome/browser/ui/update_chrome_dialog_browsertest.cc
+++ b/chrome/browser/ui/update_chrome_dialog_browsertest.cc
@@ -16,7 +16,7 @@
DialogBrowserTest::SetUp();
}
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
InProcessBrowserTest::browser()->window()->ShowUpdateChromeDialog();
}
@@ -24,9 +24,7 @@
DISALLOW_COPY_AND_ASSIGN(UpdateRecommendedDialogTest);
};
-// Test that calls ShowDialog("default"). Interactive when run via
-// browser_tests --gtest_filter=BrowserDialogTest.Invoke --interactive
-// --dialog=UpdateRecommendedDialogTest.InvokeDialog_default
-IN_PROC_BROWSER_TEST_F(UpdateRecommendedDialogTest, InvokeDialog_default) {
- RunDialog();
+// Test that calls ShowUi("default").
+IN_PROC_BROWSER_TEST_F(UpdateRecommendedDialogTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/accessibility/invert_bubble_view_browsertest.cc b/chrome/browser/ui/views/accessibility/invert_bubble_view_browsertest.cc
index f4a01ba..e9be0c3 100644
--- a/chrome/browser/ui/views/accessibility/invert_bubble_view_browsertest.cc
+++ b/chrome/browser/ui/views/accessibility/invert_bubble_view_browsertest.cc
@@ -15,7 +15,7 @@
InvertBubbleViewBrowserTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
ShowInvertBubbleView(browser(), &anchor_);
}
@@ -26,7 +26,7 @@
};
// Invokes a bubble that asks the user if they want to install a high contrast
-// Chrome theme. See test_browser_dialog.h.
-IN_PROC_BROWSER_TEST_F(InvertBubbleViewBrowserTest, InvokeDialog_default) {
- RunDialog();
+// Chrome theme.
+IN_PROC_BROWSER_TEST_F(InvertBubbleViewBrowserTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views_browsertest.cc b/chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views_browsertest.cc
index 1bc7da8..0fd9845 100644
--- a/chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views_browsertest.cc
+++ b/chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views_browsertest.cc
@@ -23,7 +23,7 @@
AppInfoDialogBrowserTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
extension_environment_ =
base::MakeUnique<extensions::TestExtensionEnvironment>(nullptr);
constexpr char kTestExtensionId[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
@@ -52,8 +52,7 @@
DISALLOW_COPY_AND_ASSIGN(AppInfoDialogBrowserTest);
};
-// Invokes a dialog that shows details of an installed extension. See
-// test_browser_dialog.h.
-IN_PROC_BROWSER_TEST_F(AppInfoDialogBrowserTest, InvokeDialog_default) {
- RunDialog();
+// Invokes a dialog that shows details of an installed extension.
+IN_PROC_BROWSER_TEST_F(AppInfoDialogBrowserTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view_browsertest.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view_browsertest.cc
index 83e5b5c..b5db0b52 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view_browsertest.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view_browsertest.cc
@@ -23,7 +23,7 @@
BookmarkBubbleViewBrowserTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
#if !defined(OS_CHROMEOS)
if (name == "bookmark_details") {
SigninManagerFactory::GetForProfile(browser()->profile())
@@ -61,21 +61,20 @@
// ChromeOS is always signed in.
#if !defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(BookmarkBubbleViewBrowserTest,
- InvokeDialog_bookmark_details) {
- RunDialog();
+ InvokeUi_bookmark_details) {
+ ShowAndVerifyUi();
}
#endif
IN_PROC_BROWSER_TEST_F(BookmarkBubbleViewBrowserTest,
- InvokeDialog_bookmark_details_signed_in) {
- RunDialog();
+ InvokeUi_bookmark_details_signed_in) {
+ ShowAndVerifyUi();
}
#if defined(OS_WIN)
-IN_PROC_BROWSER_TEST_F(BookmarkBubbleViewBrowserTest,
- InvokeDialog_ios_promotion) {
+IN_PROC_BROWSER_TEST_F(BookmarkBubbleViewBrowserTest, InvokeUi_ios_promotion) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kForceDesktopIOSPromotion);
- RunDialog();
+ ShowAndVerifyUi();
}
#endif
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_editor_view_browsertest.cc b/chrome/browser/ui/views/bookmarks/bookmark_editor_view_browsertest.cc
index f0536d5d..1c76f5c4 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_editor_view_browsertest.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_editor_view_browsertest.cc
@@ -13,7 +13,7 @@
BookmarkEditorViewBrowserTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
DCHECK_EQ("all_tabs", name);
chrome::ShowBookmarkAllTabsDialog(browser());
}
@@ -24,7 +24,6 @@
// Shows the dialog for bookmarking all tabs. This shows a BookmarkEditorView
// dialog, with a tree view, where a user can rename and select a parent folder.
-// Can be interactive when run with --gtest_filter=BrowserDialogTest.Invoke.
-IN_PROC_BROWSER_TEST_F(BookmarkEditorViewBrowserTest, InvokeDialog_all_tabs) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(BookmarkEditorViewBrowserTest, InvokeUi_all_tabs) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/certificate_selector_dialog_browsertest.cc b/chrome/browser/ui/views/certificate_selector_dialog_browsertest.cc
index 60b73d2..acb64dfe 100644
--- a/chrome/browser/ui/views/certificate_selector_dialog_browsertest.cc
+++ b/chrome/browser/ui/views/certificate_selector_dialog_browsertest.cc
@@ -45,7 +45,7 @@
CertificateSelectorDialogTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
cert_1_ =
net::ImportCertFromFile(net::GetTestCertsDirectory(), "client_1.pem");
cert_2_ =
@@ -65,8 +65,7 @@
DISALLOW_COPY_AND_ASSIGN(CertificateSelectorDialogTest);
};
-// Invokes a dialog that allows the user select a certificate. See
-// test_browser_dialog.h.
-IN_PROC_BROWSER_TEST_F(CertificateSelectorDialogTest, InvokeDialog_default) {
- RunDialog();
+// Invokes a dialog that allows the user select a certificate.
+IN_PROC_BROWSER_TEST_F(CertificateSelectorDialogTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/chrome_cleaner_dialog_browsertest_win.cc b/chrome/browser/ui/views/chrome_cleaner_dialog_browsertest_win.cc
index 1ec91178..6c41726 100644
--- a/chrome/browser/ui/views/chrome_cleaner_dialog_browsertest_win.cc
+++ b/chrome/browser/ui/views/chrome_cleaner_dialog_browsertest_win.cc
@@ -51,7 +51,7 @@
Return(safe_browsing::ChromeCleanerController::State::kInfected));
}
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
chrome::ShowChromeCleanerPrompt(browser(), mock_dialog_controller_.get(),
mock_cleaner_controller_.get());
}
@@ -68,8 +68,8 @@
DISALLOW_COPY_AND_ASSIGN(ChromeCleanerDialogTest);
};
-IN_PROC_BROWSER_TEST_F(ChromeCleanerDialogTest, InvokeDialog_default) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(ChromeCleanerDialogTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
} // namespace
diff --git a/chrome/browser/ui/views/chrome_cleaner_reboot_dialog_browsertest_win.cc b/chrome/browser/ui/views/chrome_cleaner_reboot_dialog_browsertest_win.cc
index e8f1e2b..bef08121 100644
--- a/chrome/browser/ui/views/chrome_cleaner_reboot_dialog_browsertest_win.cc
+++ b/chrome/browser/ui/views/chrome_cleaner_reboot_dialog_browsertest_win.cc
@@ -19,8 +19,7 @@
// Provides tests which allows explicit invocation of the Chrome Cleaner Reboot
// Prompt useful for checking dialog layout or any other interactive
-// functionality tests. See docs/testing/test_browser_dialog.md for description
-// of the testing framework.
+// functionality tests.
class ChromeCleanerRebootDialog : public DialogBrowserTest {
public:
void SetUpInProcessBrowserTestFixture() override {
@@ -28,7 +27,7 @@
}
// DialogBrowserTest overrides.
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
ON_CALL(mock_cleaner_controller_, state())
.WillByDefault(::testing::Return(
safe_browsing::ChromeCleanerController::State::kRebootRequired));
@@ -45,8 +44,8 @@
base::test::ScopedFeatureList scoped_feature_list_;
};
-IN_PROC_BROWSER_TEST_F(ChromeCleanerRebootDialog, InvokeDialog_default) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(ChromeCleanerRebootDialog, InvokeUi_default) {
+ ShowAndVerifyUi();
}
} // namespace
diff --git a/chrome/browser/ui/views/desktop_capture/desktop_media_picker_views_browsertest.cc b/chrome/browser/ui/views/desktop_capture/desktop_media_picker_views_browsertest.cc
index d07f5aff5..96e744c6 100644
--- a/chrome/browser/ui/views/desktop_capture/desktop_media_picker_views_browsertest.cc
+++ b/chrome/browser/ui/views/desktop_capture/desktop_media_picker_views_browsertest.cc
@@ -20,7 +20,7 @@
DesktopMediaPickerViewsBrowserTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
picker_ = base::MakeUnique<DesktopMediaPickerViews>();
auto* web_contents = browser()->tab_strip_model()->GetActiveWebContents();
gfx::NativeWindow native_window = browser()->window()->GetNativeWindow();
@@ -45,8 +45,7 @@
};
// Invokes a dialog that allows the user to select what view of their desktop
-// they would like to share. See test_browser_dialog.h.
-IN_PROC_BROWSER_TEST_F(DesktopMediaPickerViewsBrowserTest,
- InvokeDialog_default) {
- RunDialog();
+// they would like to share.
+IN_PROC_BROWSER_TEST_F(DesktopMediaPickerViewsBrowserTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/device_chooser_browsertest.cc b/chrome/browser/ui/views/device_chooser_browsertest.cc
index f3041e35..87371c55c 100644
--- a/chrome/browser/ui/views/device_chooser_browsertest.cc
+++ b/chrome/browser/ui/views/device_chooser_browsertest.cc
@@ -43,13 +43,13 @@
} // namespace
// Invokes a dialog allowing the user to select a USB device for a web page or
-// extension. See test_browser_dialog.h.
+// extension.
class UsbChooserBrowserTest : public DialogBrowserTest {
public:
UsbChooserBrowserTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
ShowChooser(name, browser(),
base::MakeUnique<FakeUsbChooserController>(device_count_));
}
@@ -62,33 +62,33 @@
DISALLOW_COPY_AND_ASSIGN(UsbChooserBrowserTest);
};
-IN_PROC_BROWSER_TEST_F(UsbChooserBrowserTest, InvokeDialog_NoDevicesBubble) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(UsbChooserBrowserTest, InvokeUi_NoDevicesBubble) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(UsbChooserBrowserTest, InvokeDialog_NoDevicesModal) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(UsbChooserBrowserTest, InvokeUi_NoDevicesModal) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(UsbChooserBrowserTest, InvokeDialog_WithDevicesBubble) {
+IN_PROC_BROWSER_TEST_F(UsbChooserBrowserTest, InvokeUi_WithDevicesBubble) {
device_count_ = 5;
- RunDialog();
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(UsbChooserBrowserTest, InvokeDialog_WithDevicesModal) {
+IN_PROC_BROWSER_TEST_F(UsbChooserBrowserTest, InvokeUi_WithDevicesModal) {
device_count_ = 5;
- RunDialog();
+ ShowAndVerifyUi();
}
// Invokes a dialog allowing the user to select a Bluetooth device for a web
-// page or extension. See test_browser_dialog.h.
+// page or extension.
class BluetoothChooserBrowserTest : public DialogBrowserTest {
public:
BluetoothChooserBrowserTest()
: status_(FakeBluetoothChooserController::BluetoothStatus::UNAVAILABLE) {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
auto controller =
std::make_unique<FakeBluetoothChooserController>(std::move(devices_));
auto* controller_unowned = controller.get();
@@ -145,75 +145,68 @@
};
IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest,
- InvokeDialog_UnavailableBubble) {
- RunDialog();
+ InvokeUi_UnavailableBubble) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest,
- InvokeDialog_UnavailableModal) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest, InvokeUi_UnavailableModal) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest,
- InvokeDialog_NoDevicesBubble) {
+IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest, InvokeUi_NoDevicesBubble) {
set_status(FakeBluetoothChooserController::BluetoothStatus::IDLE);
- RunDialog();
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest,
- InvokeDialog_NoDevicesModal) {
+IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest, InvokeUi_NoDevicesModal) {
set_status(FakeBluetoothChooserController::BluetoothStatus::IDLE);
- RunDialog();
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest,
- InvokeDialog_ScanningBubble) {
+IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest, InvokeUi_ScanningBubble) {
set_status(FakeBluetoothChooserController::BluetoothStatus::SCANNING);
- RunDialog();
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest,
- InvokeDialog_ScanningModal) {
+IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest, InvokeUi_ScanningModal) {
set_status(FakeBluetoothChooserController::BluetoothStatus::SCANNING);
- RunDialog();
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest,
- InvokeDialog_ScanningWithDevicesBubble) {
+ InvokeUi_ScanningWithDevicesBubble) {
set_status(FakeBluetoothChooserController::BluetoothStatus::SCANNING);
AddDeviceForAllStrengths();
- RunDialog();
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest,
- InvokeDialog_ScanningWithDevicesModal) {
+ InvokeUi_ScanningWithDevicesModal) {
set_status(FakeBluetoothChooserController::BluetoothStatus::SCANNING);
AddDeviceForAllStrengths();
- RunDialog();
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest,
- InvokeDialog_ConnectedBubble) {
+IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest, InvokeUi_ConnectedBubble) {
set_status(FakeBluetoothChooserController::BluetoothStatus::IDLE);
AddConnectedDevice();
- RunDialog();
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest,
- InvokeDialog_ConnectedModal) {
+IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest, InvokeUi_ConnectedModal) {
set_status(FakeBluetoothChooserController::BluetoothStatus::IDLE);
AddConnectedDevice();
- RunDialog();
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest, InvokeDialog_PairedBubble) {
+IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest, InvokeUi_PairedBubble) {
set_status(FakeBluetoothChooserController::BluetoothStatus::IDLE);
AddPairedDevice();
- RunDialog();
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest, InvokeDialog_PairedModal) {
+IN_PROC_BROWSER_TEST_F(BluetoothChooserBrowserTest, InvokeUi_PairedModal) {
set_status(FakeBluetoothChooserController::BluetoothStatus::IDLE);
AddPairedDevice();
- RunDialog();
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/extensions/extension_install_dialog_view_browsertest.cc b/chrome/browser/ui/views/extensions/extension_install_dialog_view_browsertest.cc
index abb4d21..181ab88 100644
--- a/chrome/browser/ui/views/extensions/extension_install_dialog_view_browsertest.cc
+++ b/chrome/browser/ui/views/extensions/extension_install_dialog_view_browsertest.cc
@@ -230,7 +230,7 @@
ExtensionInstallDialogViewInteractiveBrowserTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
extensions::ChromeTestExtensionLoader loader(browser()->profile());
base::FilePath test_data_dir;
PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
@@ -284,59 +284,59 @@
};
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
- InvokeDialog_Simple) {
- RunDialog();
+ InvokeUi_Simple) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
- InvokeDialog_External) {
+ InvokeUi_External) {
set_external_install();
- RunDialog();
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
- InvokeDialog_ExternalWithPermission) {
+ InvokeUi_ExternalWithPermission) {
set_external_install();
AddPermission("Example permission");
- RunDialog();
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
- InvokeDialog_FromWebstore) {
+ InvokeUi_FromWebstore) {
set_from_webstore();
- RunDialog();
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
- InvokeDialog_FromWebstoreWithPermission) {
+ InvokeUi_FromWebstoreWithPermission) {
set_from_webstore();
AddPermission("Example permission");
- RunDialog();
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
- InvokeDialog_MultilinePermission) {
+ InvokeUi_MultilinePermission) {
AddPermission(
"In the shade of the house, in the sunshine of the riverbank "
"near the boats, in the shade of the Sal-wood forest, in the "
"shade of the fig tree is where Siddhartha grew up");
- RunDialog();
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
- InvokeDialog_ManyPermissions) {
+ InvokeUi_ManyPermissions) {
for (int i = 0; i < 20; i++)
AddPermission("Example permission");
- RunDialog();
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
- InvokeDialog_DetailedPermission) {
+ InvokeUi_DetailedPermission) {
AddPermissionWithDetails("Example header permission",
{base::ASCIIToUTF16("Detailed permission 1"),
base::ASCIIToUTF16("Detailed permission 2"),
base::ASCIIToUTF16("Detailed permission 3")});
- RunDialog();
+ ShowAndVerifyUi();
}
class ExtensionInstallDialogRatingsSectionTest
diff --git a/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc b/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc
index e228281..ba24278 100644
--- a/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc
+++ b/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc
@@ -51,7 +51,7 @@
void SetUp() override;
// TestBrowserDialog:
- void ShowDialog(const std::string& name) override;
+ void ShowUi(const std::string& name) override;
private:
// ExtensionMessageBubbleBrowserTest:
@@ -75,11 +75,10 @@
// not affect the behavior of the bubble (just the appearance), so enable for
// all platforms.
UseMdOnly();
- SupportsTestDialog::SetUp();
+ SupportsTestUi::SetUp();
}
-void ExtensionMessageBubbleViewBrowserTest::ShowDialog(
- const std::string& name) {
+void ExtensionMessageBubbleViewBrowserTest::ShowUi(const std::string& name) {
// When invoked this way, the dialog test harness must close the bubble.
base::AutoReset<bool> guard(&block_close_, true);
@@ -219,11 +218,11 @@
TestControlledStartupNotShownOnRestart();
}
-// BrowserDialogTest for the warning bubble that appears when opening a new tab
-// and an extension is controlling it. Only shown on Windows.
+// BrowserUiTest for the warning bubble that appears when opening a new tab and
+// an extension is controlling it. Only shown on Windows.
IN_PROC_BROWSER_TEST_F(ExtensionMessageBubbleViewBrowserTest,
- InvokeDialog_ntp_override) {
- RunDialog();
+ InvokeUi_ntp_override) {
+ ShowAndVerifyUi();
}
#endif // defined(OS_WIN)
@@ -248,12 +247,11 @@
TestClickingDismissButton();
}
-// BrowserDialogTest for the warning bubble that appears at startup when there
-// are extensions installed in developer mode. Can be invoked interactively with
-// --gtest_filter=BrowserDialogTest.Invoke.
+// BrowserUiTest for the warning bubble that appears at startup when there are
+// extensions installed in developer mode.
IN_PROC_BROWSER_TEST_F(ExtensionMessageBubbleViewBrowserTest,
- InvokeDialog_devmode_warning) {
- RunDialog();
+ InvokeUi_devmode_warning) {
+ ShowAndVerifyUi();
}
class NtpExtensionBubbleViewBrowserTest
diff --git a/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc b/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc
index 0d6032f..d2ce2ef 100644
--- a/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc
+++ b/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc
@@ -264,7 +264,7 @@
EXTENSION_LOCAL_SOURCE,
EXTENSION_FROM_WEBSTORE,
};
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
extensions::DictionaryBuilder manifest_builder;
manifest_builder.Set("name", "ExtensionForRemoval").Set("version", "1.0");
if (extension_origin_ == EXTENSION_FROM_WEBSTORE) {
@@ -310,7 +310,7 @@
uninstall_method_ = uninstall_method;
extension_origin_ = extension_origin;
- RunDialog();
+ ShowAndVerifyUi();
}
private:
@@ -336,21 +336,21 @@
};
IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewInteractiveBrowserTest,
- InvokeDialog_ManualUninstall) {
+ InvokeUi_ManualUninstall) {
RunTest(MANUAL_UNINSTALL, EXTENSION_LOCAL_SOURCE);
}
IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewInteractiveBrowserTest,
- InvokeDialog_ManualUninstallShowReportAbuse) {
+ InvokeUi_ManualUninstallShowReportAbuse) {
RunTest(MANUAL_UNINSTALL, EXTENSION_FROM_WEBSTORE);
}
IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewInteractiveBrowserTest,
- InvokeDialog_UninstallByExtension) {
+ InvokeUi_UninstallByExtension) {
RunTest(UNINSTALL_BY_EXTENSION, EXTENSION_LOCAL_SOURCE);
}
IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewInteractiveBrowserTest,
- InvokeDialog_UninstallByExtensionShowReportAbuse) {
+ InvokeUi_UninstallByExtensionShowReportAbuse) {
RunTest(UNINSTALL_BY_EXTENSION, EXTENSION_FROM_WEBSTORE);
}
diff --git a/chrome/browser/ui/views/extensions/media_galleries_dialog_views_browsertest.cc b/chrome/browser/ui/views/extensions/media_galleries_dialog_views_browsertest.cc
index 4088981e..e8a04b51 100644
--- a/chrome/browser/ui/views/extensions/media_galleries_dialog_views_browsertest.cc
+++ b/chrome/browser/ui/views/extensions/media_galleries_dialog_views_browsertest.cc
@@ -54,7 +54,7 @@
manager.WaitForNavigationFinished();
}
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
std::vector<base::string16> headers = {base::string16(),
base::ASCIIToUTF16("header2")};
MediaGalleriesDialogController::Entries attached_permissions = {
@@ -78,6 +78,6 @@
};
IN_PROC_BROWSER_TEST_F(MediaGalleriesInteractiveDialogTest,
- InvokeDialog_DisplayDialog) {
- RunDialog();
+ InvokeUi_DisplayDialog) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/extensions/pwa_confirmation_view_browsertest.cc b/chrome/browser/ui/views/extensions/pwa_confirmation_view_browsertest.cc
index f71c7089..d971f78 100644
--- a/chrome/browser/ui/views/extensions/pwa_confirmation_view_browsertest.cc
+++ b/chrome/browser/ui/views/extensions/pwa_confirmation_view_browsertest.cc
@@ -20,7 +20,7 @@
public:
PWAConfirmationViewTest() {}
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
constexpr int kIconSize = 48;
WebApplicationInfo::IconInfo icon_info;
icon_info.data.allocN32Pixels(kIconSize, kIconSize, true);
@@ -58,20 +58,20 @@
// Launches an installation confirmation dialog for a PWA with a short name and
// origin.
-IN_PROC_BROWSER_TEST_F(PWAConfirmationViewTest, InvokeDialog_short_text) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PWAConfirmationViewTest, InvokeUi_short_text) {
+ ShowAndVerifyUi();
}
// Launches an installation confirmation dialog for a PWA with name and origin
// long enough to be elided.
-IN_PROC_BROWSER_TEST_F(PWAConfirmationViewTest, InvokeDialog_long_text) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PWAConfirmationViewTest, InvokeUi_long_text) {
+ ShowAndVerifyUi();
}
// Launches an installation confirmation dialog for a PWA with an RTL subdomain
// which is long enough to be elided.
-IN_PROC_BROWSER_TEST_F(PWAConfirmationViewTest, InvokeDialog_rtl) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PWAConfirmationViewTest, InvokeUi_rtl) {
+ ShowAndVerifyUi();
}
} // namespace
diff --git a/chrome/browser/ui/views/extensions/request_file_system_dialog_browsertest.cc b/chrome/browser/ui/views/extensions/request_file_system_dialog_browsertest.cc
index 34cb81a..dfc53bee 100644
--- a/chrome/browser/ui/views/extensions/request_file_system_dialog_browsertest.cc
+++ b/chrome/browser/ui/views/extensions/request_file_system_dialog_browsertest.cc
@@ -21,7 +21,7 @@
public:
RequestFileSystemDialogTest() {}
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
RequestFileSystemDialogView::ShowDialog(
browser()->tab_strip_model()->GetActiveWebContents(),
"RequestFileSystemDialogTest", "TestVolume", true,
@@ -34,8 +34,8 @@
DISALLOW_COPY_AND_ASSIGN(RequestFileSystemDialogTest);
};
-IN_PROC_BROWSER_TEST_F(RequestFileSystemDialogTest, InvokeDialog_default) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(RequestFileSystemDialogTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
} // namespace
diff --git a/chrome/browser/ui/views/external_protocol_dialog_browsertest.cc b/chrome/browser/ui/views/external_protocol_dialog_browsertest.cc
index 30cc493..e5f2570e 100644
--- a/chrome/browser/ui/views/external_protocol_dialog_browsertest.cc
+++ b/chrome/browser/ui/views/external_protocol_dialog_browsertest.cc
@@ -77,7 +77,7 @@
ExternalProtocolDialogBrowserTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name = "") override {
+ void ShowUi(const std::string& name) override {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
int render_view_process_id =
@@ -108,7 +108,7 @@
};
IN_PROC_BROWSER_TEST_F(ExternalProtocolDialogBrowserTest, TestAccept) {
- ShowDialog();
+ ShowUi(std::string());
EXPECT_TRUE(dialog_->Accept());
EXPECT_TRUE(called_);
EXPECT_TRUE(accept_);
@@ -120,7 +120,7 @@
IN_PROC_BROWSER_TEST_F(ExternalProtocolDialogBrowserTest,
TestAcceptWithChecked) {
- ShowDialog();
+ ShowUi(std::string());
SetChecked(true);
EXPECT_TRUE(dialog_->Accept());
EXPECT_TRUE(called_);
@@ -132,7 +132,7 @@
}
IN_PROC_BROWSER_TEST_F(ExternalProtocolDialogBrowserTest, TestCancel) {
- ShowDialog();
+ ShowUi(std::string());
EXPECT_TRUE(dialog_->Cancel());
EXPECT_FALSE(called_);
EXPECT_FALSE(accept_);
@@ -144,7 +144,7 @@
IN_PROC_BROWSER_TEST_F(ExternalProtocolDialogBrowserTest,
TestCancelWithChecked) {
- ShowDialog();
+ ShowUi(std::string());
SetChecked(true);
EXPECT_TRUE(dialog_->Cancel());
EXPECT_FALSE(called_);
@@ -157,7 +157,7 @@
IN_PROC_BROWSER_TEST_F(ExternalProtocolDialogBrowserTest, TestClose) {
// Closing the dialog should be the same as canceling, except for histograms.
- ShowDialog();
+ ShowUi(std::string());
EXPECT_TRUE(dialog_->Close());
EXPECT_FALSE(called_);
EXPECT_FALSE(accept_);
@@ -170,7 +170,7 @@
IN_PROC_BROWSER_TEST_F(ExternalProtocolDialogBrowserTest,
TestCloseWithChecked) {
// Closing the dialog should be the same as canceling, except for histograms.
- ShowDialog();
+ ShowUi(std::string());
SetChecked(true);
EXPECT_TRUE(dialog_->Close());
EXPECT_FALSE(called_);
@@ -182,8 +182,7 @@
}
// Invokes a dialog that asks the user if an external application is allowed to
-// run. See test_browser_dialog.h.
-IN_PROC_BROWSER_TEST_F(ExternalProtocolDialogBrowserTest,
- InvokeDialog_default) {
- RunDialog();
+// run.
+IN_PROC_BROWSER_TEST_F(ExternalProtocolDialogBrowserTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/feature_promos/bookmark_promo_dialog_browsertest.cc b/chrome/browser/ui/views/feature_promos/bookmark_promo_dialog_browsertest.cc
index 62b4c01..2091ae81 100644
--- a/chrome/browser/ui/views/feature_promos/bookmark_promo_dialog_browsertest.cc
+++ b/chrome/browser/ui/views/feature_promos/bookmark_promo_dialog_browsertest.cc
@@ -14,7 +14,7 @@
BookmarkPromoDialogTest() = default;
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
BrowserView::GetBrowserViewForBrowser(browser())
->toolbar()
->location_bar()
@@ -26,10 +26,7 @@
DISALLOW_COPY_AND_ASSIGN(BookmarkPromoDialogTest);
};
-// Test that calls ShowDialog("default"). Interactive when run via
-// ../browser_tests --gtest_filter=BrowserDialogTest.Invoke --interactive
-// --dialog=BookmarkPromoDialogTest.InvokeDialog_BookmarkPromoBubble
-IN_PROC_BROWSER_TEST_F(BookmarkPromoDialogTest,
- InvokeDialog_BookmarkPromoBubble) {
- RunDialog();
+// Test that calls ShowUi("default").
+IN_PROC_BROWSER_TEST_F(BookmarkPromoDialogTest, InvokeUi_BookmarkPromoBubble) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/feature_promos/incognito_window_promo_dialog_browsertest.cc b/chrome/browser/ui/views/feature_promos/incognito_window_promo_dialog_browsertest.cc
index 2ad2b07..c394b9f 100644
--- a/chrome/browser/ui/views/feature_promos/incognito_window_promo_dialog_browsertest.cc
+++ b/chrome/browser/ui/views/feature_promos/incognito_window_promo_dialog_browsertest.cc
@@ -16,7 +16,7 @@
IncognitoWindowPromoDialogTest() = default;
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
feature_engagement::IncognitoWindowTrackerFactory::GetInstance()
->GetForProfile(browser()->profile())
->ShowPromo();
@@ -28,13 +28,10 @@
} // namespace
-// Test that calls ShowDialog("default"). Interactive when run via
-// ../browser_tests --gtest_filter=BrowserDialogTest.Invoke
-// --interactive
-// --dialog=IncognitoWindowPromoDialogTest.InvokeDialog_IncognitoWindowPromo
+// Test that calls ShowUi("default").
IN_PROC_BROWSER_TEST_F(IncognitoWindowPromoDialogTest,
- InvokeDialog_IncognitoWindowPromo) {
- RunDialog();
+ InvokeUi_IncognitoWindowPromo) {
+ ShowAndVerifyUi();
}
} // namespace feature_engagement
diff --git a/chrome/browser/ui/views/feature_promos/new_tab_promo_dialog_browsertest.cc b/chrome/browser/ui/views/feature_promos/new_tab_promo_dialog_browsertest.cc
index 575e7f0..4c92c8d 100644
--- a/chrome/browser/ui/views/feature_promos/new_tab_promo_dialog_browsertest.cc
+++ b/chrome/browser/ui/views/feature_promos/new_tab_promo_dialog_browsertest.cc
@@ -12,7 +12,7 @@
NewTabPromoDialogTest() = default;
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
// The promo only exists in the TabStripImpl.
TabStripImpl* tab_strip_impl =
BrowserView::GetBrowserViewForBrowser(browser())
@@ -26,9 +26,7 @@
DISALLOW_COPY_AND_ASSIGN(NewTabPromoDialogTest);
};
-// Test that calls ShowDialog("default"). Interactive when run via
-// ../browser_tests --gtest_filter=BrowserDialogTest.Invoke
-// --interactive --dialog=NewTabPromoDialogTest.InvokeDialog_NewTabPromo
-IN_PROC_BROWSER_TEST_F(NewTabPromoDialogTest, InvokeDialog_NewTabPromo) {
- RunDialog();
+// Test that calls ShowUi("default").
+IN_PROC_BROWSER_TEST_F(NewTabPromoDialogTest, InvokeUi_NewTabPromo) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/first_run_bubble_browsertest.cc b/chrome/browser/ui/views/first_run_bubble_browsertest.cc
index 997cb49a..b5ef1166 100644
--- a/chrome/browser/ui/views/first_run_bubble_browsertest.cc
+++ b/chrome/browser/ui/views/first_run_bubble_browsertest.cc
@@ -14,7 +14,7 @@
FirstRunBubbleBrowserTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
FirstRunBubble::Show(browser());
}
@@ -23,7 +23,7 @@
};
// Invokes a dialog that tells the user they can type into the omnibox to search
-// with Google. See test_browser_dialog.h.
-IN_PROC_BROWSER_TEST_F(FirstRunBubbleBrowserTest, InvokeDialog_default) {
- RunDialog();
+// with Google.
+IN_PROC_BROWSER_TEST_F(FirstRunBubbleBrowserTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/hung_renderer_view_browsertest.cc b/chrome/browser/ui/views/hung_renderer_view_browsertest.cc
index 8f669bf..7ed9b27 100644
--- a/chrome/browser/ui/views/hung_renderer_view_browsertest.cc
+++ b/chrome/browser/ui/views/hung_renderer_view_browsertest.cc
@@ -20,7 +20,7 @@
HungRendererDialogViewBrowserTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
auto* web_contents = browser()->tab_strip_model()->GetActiveWebContents();
TabDialogs::FromWebContents(web_contents)
->ShowHungRendererDialog(content::WebContentsUnresponsiveState());
@@ -30,12 +30,11 @@
DISALLOW_COPY_AND_ASSIGN(HungRendererDialogViewBrowserTest);
};
-// Invokes the hung renderer (aka page unresponsive) dialog. See
-// test_browser_dialog.h.
+// Invokes the hung renderer (aka page unresponsive) dialog.
// TODO(tapted): The framework sometimes doesn't pick up the spawned dialog and
-// the ASSERT_EQ in TestBrowserDialog::RunDialog() fails. This seems to only
+// the ASSERT_EQ in TestBrowserUi::ShowAndVerifyUi() fails. This seems to only
// happen on the bots. So the test is disabled for now.
IN_PROC_BROWSER_TEST_F(HungRendererDialogViewBrowserTest,
- DISABLED_InvokeDialog_default) {
- RunDialog();
+ DISABLED_InvokeUi_default) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/importer/import_lock_dialog_view_browsertest.cc b/chrome/browser/ui/views/importer/import_lock_dialog_view_browsertest.cc
index 766cc793..5e7c9d59 100644
--- a/chrome/browser/ui/views/importer/import_lock_dialog_view_browsertest.cc
+++ b/chrome/browser/ui/views/importer/import_lock_dialog_view_browsertest.cc
@@ -15,7 +15,7 @@
ImportLockDialogViewBrowserTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
gfx::NativeWindow native_window = browser()->window()->GetNativeWindow();
ImportLockDialogView::Show(native_window, base::Callback<void(bool)>());
}
@@ -25,7 +25,7 @@
};
// Invokes a dialog that implores the user to close Firefox before trying to
-// import data. See test_browser_dialog.h.
-IN_PROC_BROWSER_TEST_F(ImportLockDialogViewBrowserTest, InvokeDialog_default) {
- RunDialog();
+// import data.
+IN_PROC_BROWSER_TEST_F(ImportLockDialogViewBrowserTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/location_bar/content_setting_bubble_dialog_browsertest.cc b/chrome/browser/ui/views/location_bar/content_setting_bubble_dialog_browsertest.cc
index 1b4996a..a0997fa 100644
--- a/chrome/browser/ui/views/location_bar/content_setting_bubble_dialog_browsertest.cc
+++ b/chrome/browser/ui/views/location_bar/content_setting_bubble_dialog_browsertest.cc
@@ -39,7 +39,7 @@
void ShowDialogBubble(ContentSettingsType content_type,
ContentSettingImageModel::ImageType image_type);
- void ShowDialog(const std::string& name) override;
+ void ShowUi(const std::string& name) override;
private:
DISALLOW_COPY_AND_ASSIGN(ContentSettingBubbleDialogTest);
@@ -110,7 +110,7 @@
static_cast<int>(image_type), 1);
}
-void ContentSettingBubbleDialogTest::ShowDialog(const std::string& name) {
+void ContentSettingBubbleDialogTest::ShowUi(const std::string& name) {
constexpr struct {
const char* name;
ContentSettingsType content_type;
@@ -148,68 +148,63 @@
ADD_FAILURE() << "Unknown dialog type";
}
-IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeDialog_cookies) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeUi_cookies) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeDialog_images) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeUi_images) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest,
- InvokeDialog_javascript) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeUi_javascript) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeDialog_plugins) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeUi_plugins) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeDialog_popups) {
+IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeUi_popups) {
ASSERT_TRUE(embedded_test_server()->Start());
- RunDialog();
+ ShowAndVerifyUi();
+}
+
+IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeUi_geolocation) {
+ ShowAndVerifyUi();
+}
+
+IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeUi_ppapi_broker) {
+ ShowAndVerifyUi();
+}
+
+IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeUi_mixed_script) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest,
- InvokeDialog_geolocation) {
- RunDialog();
+ InvokeUi_mediastream_mic) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest,
- InvokeDialog_ppapi_broker) {
- RunDialog();
+ InvokeUi_mediastream_camera) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest,
- InvokeDialog_mixed_script) {
- RunDialog();
+ InvokeUi_protocol_handlers) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest,
- InvokeDialog_mediastream_mic) {
- RunDialog();
+ InvokeUi_automatic_downloads) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest,
- InvokeDialog_mediastream_camera) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeUi_midi_sysex) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest,
- InvokeDialog_protocol_handlers) {
- RunDialog();
-}
-
-IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest,
- InvokeDialog_automatic_downloads) {
- RunDialog();
-}
-
-IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest,
- InvokeDialog_midi_sysex) {
- RunDialog();
-}
-
-IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeDialog_ads) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(ContentSettingBubbleDialogTest, InvokeUi_ads) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/location_bar/zoom_bubble_view_browsertest.cc b/chrome/browser/ui/views/location_bar/zoom_bubble_view_browsertest.cc
index c1db4d9..530eafe 100644
--- a/chrome/browser/ui/views/location_bar/zoom_bubble_view_browsertest.cc
+++ b/chrome/browser/ui/views/location_bar/zoom_bubble_view_browsertest.cc
@@ -162,7 +162,7 @@
ZoomBubbleDialogTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
content::WebContents* web_contents = browser_view->GetActiveWebContents();
ZoomBubbleView::ShowBubble(web_contents, gfx::Point(),
@@ -173,9 +173,7 @@
DISALLOW_COPY_AND_ASSIGN(ZoomBubbleDialogTest);
};
-// Test that calls ShowDialog("default"). Interactive when run via
-// browser_tests --gtest_filter=BrowserDialogTest.Invoke --interactive
-// --dialog=ZoomBubbleDialogTest.InvokeDialog_default
-IN_PROC_BROWSER_TEST_F(ZoomBubbleDialogTest, InvokeDialog_default) {
- RunDialog();
+// Test that calls ShowUi("default").
+IN_PROC_BROWSER_TEST_F(ZoomBubbleDialogTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/page_info/page_info_bubble_view_browsertest.cc b/chrome/browser/ui/views/page_info/page_info_bubble_view_browsertest.cc
index 488939be..5bf4408c 100644
--- a/chrome/browser/ui/views/page_info/page_info_bubble_view_browsertest.cc
+++ b/chrome/browser/ui/views/page_info/page_info_bubble_view_browsertest.cc
@@ -113,7 +113,7 @@
PageInfoBubbleViewBrowserTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
// All the possible test names.
constexpr char kInsecure[] = "Insecure";
constexpr char kInternal[] = "Internal";
@@ -396,90 +396,88 @@
}
// Shows the Page Info bubble for a HTTP page (specifically, about:blank).
-IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, InvokeDialog_Insecure) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, InvokeUi_Insecure) {
+ ShowAndVerifyUi();
}
// Shows the Page Info bubble for a HTTPS page.
-IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, InvokeDialog_Secure) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, InvokeUi_Secure) {
+ ShowAndVerifyUi();
}
// Shows the Page Info bubble for an internal page, e.g. chrome://settings.
-IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, InvokeDialog_Internal) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, InvokeUi_Internal) {
+ ShowAndVerifyUi();
}
// Shows the Page Info bubble for an extensions page.
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
- InvokeDialog_InternalExtension) {
- RunDialog();
+ InvokeUi_InternalExtension) {
+ ShowAndVerifyUi();
}
// Shows the Page Info bubble for a chrome page that displays the source HTML.
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
- InvokeDialog_InternalViewSource) {
- RunDialog();
+ InvokeUi_InternalViewSource) {
+ ShowAndVerifyUi();
}
// Shows the Page Info bubble for a site flagged for malware by Safe Browsing.
-IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, InvokeDialog_Malware) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, InvokeUi_Malware) {
+ ShowAndVerifyUi();
}
// Shows the Page Info bubble for a site flagged for social engineering by Safe
// Browsing.
-IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, InvokeDialog_Deceptive) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, InvokeUi_Deceptive) {
+ ShowAndVerifyUi();
}
// Shows the Page Info bubble for a site flagged for distributing unwanted
// software by Safe Browsing.
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
- InvokeDialog_UnwantedSoftware) {
- RunDialog();
+ InvokeUi_UnwantedSoftware) {
+ ShowAndVerifyUi();
}
// Shows the Page Info bubble Safe Browsing soft warning after detecting the
// user has re-used an existing password on a site, e.g. due to phishing.
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
- InvokeDialog_PasswordReuseSoft) {
- RunDialog();
+ InvokeUi_PasswordReuseSoft) {
+ ShowAndVerifyUi();
}
// Shows the Page Info bubble Safe Browsing warning after detecting the user has
// re-used an existing password on a site, e.g. due to phishing.
-IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
- InvokeDialog_PasswordReuse) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, InvokeUi_PasswordReuse) {
+ ShowAndVerifyUi();
}
// Shows the Page Info bubble for an admin-provided cert when the page is
// secure, but has a form that submits to an insecure url.
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
- InvokeDialog_MixedContentForm) {
- RunDialog();
+ InvokeUi_MixedContentForm) {
+ ShowAndVerifyUi();
}
// Shows the Page Info bubble for an admin-provided cert when the page is
// secure, but it uses insecure resources (e.g. images).
-IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
- InvokeDialog_MixedContent) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, InvokeUi_MixedContent) {
+ ShowAndVerifyUi();
}
// Shows the Page Info bubble with all the permissions displayed with 'Allow'
// set. All permissions will show regardless of its factory default value.
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
- InvokeDialog_AllowAllPermissions) {
- RunDialog();
+ InvokeUi_AllowAllPermissions) {
+ ShowAndVerifyUi();
}
// Shows the Page Info bubble with all the permissions displayed with 'Block'
// set. All permissions will show regardless of its factory default value.
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
- InvokeDialog_BlockAllPermissions) {
- RunDialog();
+ InvokeUi_BlockAllPermissions) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
diff --git a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view_browsertest.cc b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view_browsertest.cc
index 52bbfa30..3832fe17b 100644
--- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view_browsertest.cc
+++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view_browsertest.cc
@@ -16,7 +16,7 @@
ManagePasswordsBubbleDialogViewTest() {}
~ManagePasswordsBubbleDialogViewTest() override {}
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
if (name == "PendingPasswordBubble") {
SetupPendingPassword();
} else if (name == "AutomaticPasswordBubble") {
@@ -40,12 +40,12 @@
}
}
- // SupportsTestDialog:
+ // SupportsTestUi:
void SetUp() override {
#if defined(OS_MACOSX)
UseMdOnly(); // This needs to be called during SetUp() on Mac.
#endif
- SupportsTestDialog::SetUp();
+ SupportsTestUi::SetUp();
}
private:
@@ -53,23 +53,23 @@
};
IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleDialogViewTest,
- InvokeDialog_PendingPasswordBubble) {
- RunDialog();
+ InvokeUi_PendingPasswordBubble) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleDialogViewTest,
- InvokeDialog_AutomaticPasswordBubble) {
- RunDialog();
+ InvokeUi_AutomaticPasswordBubble) {
+ ShowAndVerifyUi();
}
// Disabled: ExecuteManagePasswordsCommand() spins a runloop which will be flaky
// in a browser test. See http://crbug.com/716681.
IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleDialogViewTest,
- DISABLED_InvokeDialog_ManagePasswordBubble) {
- RunDialog();
+ DISABLED_InvokeUi_ManagePasswordBubble) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleDialogViewTest,
- InvokeDialog_AutoSignin) {
- RunDialog();
+ InvokeUi_AutoSignin) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/passwords/password_dialog_view_browsertest.cc b/chrome/browser/ui/views/passwords/password_dialog_view_browsertest.cc
index 414d8fa..2fbc4dd 100644
--- a/chrome/browser/ui/views/passwords/password_dialog_view_browsertest.cc
+++ b/chrome/browser/ui/views/passwords/password_dialog_view_browsertest.cc
@@ -99,7 +99,7 @@
public:
// DialogBrowserTest:
void SetUpOnMainThread() override;
- void ShowDialog(const std::string& name) override;
+ void ShowUi(const std::string& name) override;
void SetupChooseCredentials(
std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials,
@@ -435,7 +435,7 @@
}
// DialogBrowserTest methods for interactive dialog invocation.
-void PasswordDialogViewTest::ShowDialog(const std::string& name) {
+void PasswordDialogViewTest::ShowUi(const std::string& name) {
if (name == "AutoSigninFirstRun") {
controller()->OnPromptEnableAutoSignin();
return;
@@ -489,26 +489,24 @@
}
}
-IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest,
- InvokeDialog_PopupAutoSigninPrompt) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest, InvokeUi_PopupAutoSigninPrompt) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(
PasswordDialogViewTest,
- InvokeDialog_PopupAccountChooserWithSingleCredentialClickSignIn) {
- RunDialog();
+ InvokeUi_PopupAccountChooserWithSingleCredentialClickSignIn) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(
PasswordDialogViewTest,
- InvokeDialog_PopupAccountChooserWithMultipleCredentialClickSignIn) {
- RunDialog();
+ InvokeUi_PopupAccountChooserWithMultipleCredentialClickSignIn) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest,
- InvokeDialog_AutoSigninFirstRun) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest, InvokeUi_AutoSigninFirstRun) {
+ ShowAndVerifyUi();
}
} // namespace
diff --git a/chrome/browser/ui/views/payments/payment_request_browsertest.cc b/chrome/browser/ui/views/payments/payment_request_browsertest.cc
index 2c9f80f3..97b6f5e 100644
--- a/chrome/browser/ui/views/payments/payment_request_browsertest.cc
+++ b/chrome/browser/ui/views/payments/payment_request_browsertest.cc
@@ -434,9 +434,7 @@
PaymentsRequestVisualTest() {}
// TestBrowserDialog:
- void ShowDialog(const std::string& name) override {
- InvokePaymentRequestUI();
- }
+ void ShowUi(const std::string& name) override { InvokePaymentRequestUI(); }
bool AlwaysCloseAsynchronously() override {
// Bypassing Widget::CanClose() causes payments::JourneyLogger to see the
@@ -448,9 +446,9 @@
DISALLOW_COPY_AND_ASSIGN(PaymentsRequestVisualTest);
};
-IN_PROC_BROWSER_TEST_F(PaymentsRequestVisualTest, InvokeDialog_NoShipping) {
+IN_PROC_BROWSER_TEST_F(PaymentsRequestVisualTest, InvokeUi_NoShipping) {
NavigateTo("/payment_request_no_shipping_test.html");
- RunDialog();
+ ShowAndVerifyUi();
}
class PaymentRequestSettingsLinkTest : public PaymentRequestBrowserTestBase {
diff --git a/chrome/browser/ui/views/profiles/forced_reauthentication_dialog_view_browsertest.cc b/chrome/browser/ui/views/profiles/forced_reauthentication_dialog_view_browsertest.cc
index 33d1dfd77..1bc5832 100644
--- a/chrome/browser/ui/views/profiles/forced_reauthentication_dialog_view_browsertest.cc
+++ b/chrome/browser/ui/views/profiles/forced_reauthentication_dialog_view_browsertest.cc
@@ -20,7 +20,7 @@
ForcedReauthenticationDialogViewBrowserTest() {}
// override DialogBrowserTest
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
Profile* profile = browser()->profile();
SigninManager* manager = SigninManagerFactory::GetForProfile(profile);
manager->SetAuthenticatedAccountInfo("test1", "[email protected]");
@@ -35,8 +35,8 @@
};
IN_PROC_BROWSER_TEST_F(ForcedReauthenticationDialogViewBrowserTest,
- InvokeDialog_default) {
- RunDialog();
+ InvokeUi_default) {
+ ShowAndVerifyUi();
}
// Dialog will not be display if there is no valid browser window.
diff --git a/chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc b/chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc
index acb51eb1..cb201662 100644
--- a/chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc
+++ b/chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc
@@ -125,8 +125,8 @@
ProfileChooserViewExtensionsTest() {}
~ProfileChooserViewExtensionsTest() override {}
- // SupportsTestDialog:
- void ShowDialog(const std::string& name) override {
+ // SupportsTestUi:
+ void ShowUi(const std::string& name) override {
constexpr char kSignedIn[] = "SignedIn";
constexpr char kMultiProfile[] = "MultiProfile";
constexpr char kGuest[] = "Guest";
@@ -388,43 +388,42 @@
}
// Shows a non-signed in profile with no others.
-IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, InvokeDialog_default) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
// Shows a signed in profile with no others.
-IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest,
- InvokeDialog_SignedIn) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, InvokeUi_SignedIn) {
+ ShowAndVerifyUi();
}
// Shows the |ProfileChooserView| with three different profiles.
IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest,
- InvokeDialog_MultiProfile) {
- RunDialog();
+ InvokeUi_MultiProfile) {
+ ShowAndVerifyUi();
}
// Shows the |ProfileChooserView| during a Guest browsing session.
-IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, InvokeDialog_Guest) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, InvokeUi_Guest) {
+ ShowAndVerifyUi();
}
// Shows the manage account link, which appears when account consistency is
// enabled for signed-in accounts.
IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest,
- InvokeDialog_ManageAccountLink) {
- RunDialog();
+ InvokeUi_ManageAccountLink) {
+ ShowAndVerifyUi();
}
// Shows the |ProfileChooserView| from a signed-in account that has a supervised
// user profile attached.
IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest,
- InvokeDialog_SupervisedOwner) {
- RunDialog();
+ InvokeUi_SupervisedOwner) {
+ ShowAndVerifyUi();
}
// Shows the |ProfileChooserView| when a supervised user is the active profile.
IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest,
- InvokeDialog_SupervisedUser) {
- RunDialog();
+ InvokeUi_SupervisedUser) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/safe_browsing/password_reuse_modal_warning_dialog_browsertest.cc b/chrome/browser/ui/views/safe_browsing/password_reuse_modal_warning_dialog_browsertest.cc
index 1ec7bd6a..a8dc24b 100644
--- a/chrome/browser/ui/views/safe_browsing/password_reuse_modal_warning_dialog_browsertest.cc
+++ b/chrome/browser/ui/views/safe_browsing/password_reuse_modal_warning_dialog_browsertest.cc
@@ -27,7 +27,7 @@
~PasswordReuseModalWarningTest() override {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
dialog_ = new PasswordReuseModalWarningDialog(
@@ -59,16 +59,16 @@
DISALLOW_COPY_AND_ASSIGN(PasswordReuseModalWarningTest);
};
-IN_PROC_BROWSER_TEST_F(PasswordReuseModalWarningTest, InvokeDialog_default) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(PasswordReuseModalWarningTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(PasswordReuseModalWarningTest, InvokeDialog_softer) {
+IN_PROC_BROWSER_TEST_F(PasswordReuseModalWarningTest, InvokeUi_softer) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeatureWithParameters(
safe_browsing::kGoogleBrandedPhishingWarning,
{{"softer_warning", "true"}});
- RunDialog();
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(PasswordReuseModalWarningTest, TestBasicDialogBehavior) {
@@ -76,13 +76,13 @@
// Simulating a click on ui::DIALOG_BUTTON_OK button results in a
// CHANGE_PASSWORD action.
- ShowDialog(std::string());
+ ShowUi(std::string());
dialog_->GetDialogClientView()->AcceptWindow();
EXPECT_EQ(PasswordProtectionService::CHANGE_PASSWORD, latest_user_action_);
// Simulating a click on ui::DIALOG_BUTTON_CANCEL button results in an
// IGNORE_WARNING action.
- ShowDialog(std::string());
+ ShowUi(std::string());
dialog_->GetDialogClientView()->CancelWindow();
EXPECT_EQ(PasswordProtectionService::IGNORE_WARNING, latest_user_action_);
}
@@ -91,7 +91,7 @@
CloseDialogWhenWebContentsDestroyed) {
ASSERT_TRUE(embedded_test_server()->Start());
- ShowDialog(std::string());
+ ShowUi(std::string());
CloseActiveWebContents();
EXPECT_EQ(PasswordProtectionService::CLOSE, latest_user_action_);
}
diff --git a/chrome/browser/ui/views/session_crashed_bubble_view_browsertest.cc b/chrome/browser/ui/views/session_crashed_bubble_view_browsertest.cc
index 938c5049..827bba3 100644
--- a/chrome/browser/ui/views/session_crashed_bubble_view_browsertest.cc
+++ b/chrome/browser/ui/views/session_crashed_bubble_view_browsertest.cc
@@ -18,7 +18,7 @@
SessionCrashedBubbleViewTest() {}
~SessionCrashedBubbleViewTest() override {}
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
views::View* anchor_view = BrowserView::GetBrowserViewForBrowser(browser())
->toolbar()
->app_menu_button();
@@ -32,6 +32,6 @@
};
IN_PROC_BROWSER_TEST_F(SessionCrashedBubbleViewTest,
- InvokeDialog_SessionCrashedBubble) {
- RunDialog();
+ InvokeUi_SessionCrashedBubble) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/settings_reset_prompt_dialog_browsertest.cc b/chrome/browser/ui/views/settings_reset_prompt_dialog_browsertest.cc
index 31a4243..346cde5a 100644
--- a/chrome/browser/ui/views/settings_reset_prompt_dialog_browsertest.cc
+++ b/chrome/browser/ui/views/settings_reset_prompt_dialog_browsertest.cc
@@ -148,7 +148,7 @@
class SettingsResetPromptDialogTest : public DialogBrowserTest {
public:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
const std::map<std::string, ModelParams> name_to_model_params = {
{"DefaultSearchEngineChanged",
{SettingType::DEFAULT_SEARCH_ENGINE, 0, 0}},
@@ -183,55 +183,54 @@
};
IN_PROC_BROWSER_TEST_F(SettingsResetPromptDialogTest,
- InvokeDialog_DefaultSearchEngineChanged) {
- RunDialog();
+ InvokeUi_DefaultSearchEngineChanged) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(SettingsResetPromptDialogTest,
- InvokeDialog_SingleStartupPageChanged) {
- RunDialog();
+ InvokeUi_SingleStartupPageChanged) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(SettingsResetPromptDialogTest,
- InvokeDialog_MultipleStartupPagesChanged) {
- RunDialog();
+ InvokeUi_MultipleStartupPagesChanged) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(SettingsResetPromptDialogTest,
- InvokeDialog_HomePageChanged) {
- RunDialog();
+ InvokeUi_HomePageChanged) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(SettingsResetPromptDialogTest,
- InvokeDialog_DefaultSearchEngineChangedByExtension) {
- RunDialog();
+ InvokeUi_DefaultSearchEngineChangedByExtension) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(SettingsResetPromptDialogTest,
- InvokeDialog_SingleStartupPageChangedByExtension) {
- RunDialog();
+ InvokeUi_SingleStartupPageChangedByExtension) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(SettingsResetPromptDialogTest,
- InvokeDialog_MultipleStartupPagesChangedByExtension) {
- RunDialog();
+ InvokeUi_MultipleStartupPagesChangedByExtension) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(SettingsResetPromptDialogTest,
- InvokeDialog_HomePageChangedByExtension) {
- RunDialog();
+ InvokeUi_HomePageChangedByExtension) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(
SettingsResetPromptDialogTest,
- InvokeDialog_DefaultSearchEngineChangedByMultipleExtensions) {
- RunDialog();
-}
-IN_PROC_BROWSER_TEST_F(
- SettingsResetPromptDialogTest,
- InvokeDialog_SingleStartupPageChangedByMultipleExtensions) {
- RunDialog();
-}
-IN_PROC_BROWSER_TEST_F(
- SettingsResetPromptDialogTest,
- InvokeDialog_MultipleStartupPagesChangedByMultipleExtensions) {
- RunDialog();
+ InvokeUi_DefaultSearchEngineChangedByMultipleExtensions) {
+ ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(SettingsResetPromptDialogTest,
- InvokeDialog_HomePageChangedByMultipleExtensions) {
- RunDialog();
+ InvokeUi_SingleStartupPageChangedByMultipleExtensions) {
+ ShowAndVerifyUi();
+}
+IN_PROC_BROWSER_TEST_F(
+ SettingsResetPromptDialogTest,
+ InvokeUi_MultipleStartupPagesChangedByMultipleExtensions) {
+ ShowAndVerifyUi();
+}
+IN_PROC_BROWSER_TEST_F(SettingsResetPromptDialogTest,
+ InvokeUi_HomePageChangedByMultipleExtensions) {
+ ShowAndVerifyUi();
}
} // namespace
diff --git a/chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views_browsertest.cc b/chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views_browsertest.cc
index f0f1d46..ff3af99 100644
--- a/chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views_browsertest.cc
+++ b/chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views_browsertest.cc
@@ -43,7 +43,7 @@
DialogBrowserTest::SetUp();
}
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
Profile* profile = browser()->profile();
// Add a bookmark to ensure CheckShouldPromptForNewProfile() returns true.
@@ -65,10 +65,7 @@
DISALLOW_COPY_AND_ASSIGN(ProfileSigninConfirmationDialogTest);
};
-// Test that calls ShowDialog("default"). Interactive when run via
-// browser_tests --gtest_filter=BrowserDialogTest.Invoke --interactive
-// --dialog=ProfileSigninConfirmationDialogTest.InvokeDialog_default
-IN_PROC_BROWSER_TEST_F(ProfileSigninConfirmationDialogTest,
- InvokeDialog_default) {
- RunDialog();
+// Test that calls ShowUi("default").
+IN_PROC_BROWSER_TEST_F(ProfileSigninConfirmationDialogTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/browser/ui/views/toolbar/outdated_upgrade_bubble_view_browsertest.cc b/chrome/browser/ui/views/toolbar/outdated_upgrade_bubble_view_browsertest.cc
index bd9b68b5..58fb244 100644
--- a/chrome/browser/ui/views/toolbar/outdated_upgrade_bubble_view_browsertest.cc
+++ b/chrome/browser/ui/views/toolbar/outdated_upgrade_bubble_view_browsertest.cc
@@ -14,7 +14,7 @@
OutdatedUpgradeBubbleTest() = default;
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
ToolbarView* toolbar_view =
BrowserView::GetBrowserViewForBrowser(browser())->toolbar();
if (name == "Outdated")
@@ -31,17 +31,17 @@
DISALLOW_COPY_AND_ASSIGN(OutdatedUpgradeBubbleTest);
};
-IN_PROC_BROWSER_TEST_F(OutdatedUpgradeBubbleTest, InvokeDialog_Outdated) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(OutdatedUpgradeBubbleTest, InvokeUi_Outdated) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(OutdatedUpgradeBubbleTest, InvokeDialog_NoAutoUpdate) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(OutdatedUpgradeBubbleTest, InvokeUi_NoAutoUpdate) {
+ ShowAndVerifyUi();
}
// The critical upgrade dialog is intentionally only shown on Windows.
#if defined(OS_WIN)
-IN_PROC_BROWSER_TEST_F(OutdatedUpgradeBubbleTest, InvokeDialog_Critical) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(OutdatedUpgradeBubbleTest, InvokeUi_Critical) {
+ ShowAndVerifyUi();
}
#endif
diff --git a/chrome/browser/ui/views/try_chrome_dialog_win/try_chrome_dialog_browsertest.cc b/chrome/browser/ui/views/try_chrome_dialog_win/try_chrome_dialog_browsertest.cc
index b3ecee5..0c7f30b1 100644
--- a/chrome/browser/ui/views/try_chrome_dialog_win/try_chrome_dialog_browsertest.cc
+++ b/chrome/browser/ui/views/try_chrome_dialog_win/try_chrome_dialog_browsertest.cc
@@ -78,7 +78,7 @@
// functionality.
class TryChromeDialogBrowserTestBase : public InProcessBrowserTest {
public:
- // Breaks ShowDialog() out of its modal run loop.
+ // Breaks ShowDialogSync() out of its modal run loop.
void QuitModalLoop() {
if (quit_closure_)
quit_closure_.Run();
@@ -289,19 +289,19 @@
TryChromeDialogTest()
: SupportsTestDialog<TryChromeDialogBrowserTestBase>(GetParam()) {}
- // SupportsTestDialog:
+ // SupportsTestUi:
void SetUp() override {
UseMdOnly();
- SupportsTestDialog::SetUp();
+ SupportsTestUi::SetUp();
}
- void ShowDialog(const std::string& name) override { ShowDialogSync(); }
+ void ShowUi(const std::string& name) override { ShowDialogSync(); }
private:
DISALLOW_COPY_AND_ASSIGN(TryChromeDialogTest);
};
-IN_PROC_BROWSER_TEST_P(TryChromeDialogTest, InvokeDialog_default) {
- RunDialog();
+IN_PROC_BROWSER_TEST_P(TryChromeDialogTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
INSTANTIATE_TEST_CASE_P(
diff --git a/chrome/browser/ui/views/uninstall_view_browsertest.cc b/chrome/browser/ui/views/uninstall_view_browsertest.cc
index 7a37338..cc6a8f2 100644
--- a/chrome/browser/ui/views/uninstall_view_browsertest.cc
+++ b/chrome/browser/ui/views/uninstall_view_browsertest.cc
@@ -14,7 +14,7 @@
UninstallViewBrowserTest() {}
// DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
+ void ShowUi(const std::string& name) override {
// UninstallView may need to know whether Chrome is the default browser,
// which requires IO. Since this is a test, we'll just allow that.
base::ThreadRestrictions::SetIOAllowed(true);
@@ -31,12 +31,10 @@
DISALLOW_COPY_AND_ASSIGN(UninstallViewBrowserTest);
};
-// Invokes a dialog confirming that the user wants to uninstall Chrome. See
-// test_browser_dialog.h.
+// Invokes a dialog confirming that the user wants to uninstall Chrome.
// Disabled because the build bots don't click to dismiss the dialog, they just
// wait for it to time out. Unfortunately because we have to explicitly exit
-// (see ShowDialog above) this approach doesn't work.
-IN_PROC_BROWSER_TEST_F(UninstallViewBrowserTest,
- DISABLED_InvokeDialog_default) {
- RunDialog();
+// (see ShowUi above) this approach doesn't work.
+IN_PROC_BROWSER_TEST_F(UninstallViewBrowserTest, DISABLED_InvokeUi_default) {
+ ShowAndVerifyUi();
}
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
index 8c0c443..66c0f67 100644
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
@@ -784,11 +784,13 @@
"../browser/ui/sync/profile_signin_confirmation_helper_browsertest.cc",
"../browser/ui/tab_modal_confirm_dialog_browsertest.cc",
"../browser/ui/tab_modal_confirm_dialog_browsertest.h",
- "../browser/ui/test/browser_dialog_browsertest.cc",
+ "../browser/ui/test/browser_ui_browsertest.cc",
"../browser/ui/test/test_browser_dialog.cc",
"../browser/ui/test/test_browser_dialog.h",
"../browser/ui/test/test_browser_dialog_mac.h",
"../browser/ui/test/test_browser_dialog_mac.mm",
+ "../browser/ui/test/test_browser_ui.cc",
+ "../browser/ui/test/test_browser_ui.h",
"../browser/ui/toolbar/browser_actions_bar_browsertest.cc",
"../browser/ui/toolbar/browser_actions_bar_browsertest.h",
"../browser/ui/toolbar/component_toolbar_actions_browsertest.cc",
diff --git a/chrome/test/base/browser_tests_main.cc b/chrome/test/base/browser_tests_main.cc
index d0d20b0..0ef205d 100644
--- a/chrome/test/base/browser_tests_main.cc
+++ b/chrome/test/base/browser_tests_main.cc
@@ -10,7 +10,7 @@
#if defined(OS_WIN)
#include "base/win/win_util.h"
-#include "chrome/browser/ui/test/test_browser_dialog.h"
+#include "chrome/browser/ui/test/test_browser_ui.h"
#endif // defined(OS_WIN)
int main(int argc, char** argv) {
diff --git a/components/infobars/core/infobar_manager.h b/components/infobars/core/infobar_manager.h
index bbf944f..2d44965 100644
--- a/components/infobars/core/infobar_manager.h
+++ b/components/infobars/core/infobar_manager.h
@@ -16,6 +16,7 @@
class ConfirmInfoBarDelegate;
class GURL;
+class InfoBarUiTest;
namespace infobars {
@@ -119,6 +120,8 @@
virtual void NotifyInfoBarRemoved(InfoBar* infobar, bool animate);
private:
+ friend class ::InfoBarUiTest;
+
// InfoBars associated with this InfoBarManager. We own these pointers.
// However, this is not a vector of unique_ptr, because we don't delete the
// infobars directly once they've been added to this; instead, when we're
diff --git a/docs/README.md b/docs/README.md
index 2e3f4ed..37e256bb 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -154,8 +154,7 @@
Diagnosing and fixing layout test flakiness due to ordering dependencies.
* [Running Layout Tests using `content_shell`](testing/layout_tests_in_content_shell.md) -
Running layout tests by hand.
-* [Testing Browser Dialogs](testing/test_browser_dialog.md) - Using
- TestBrowserDialog
+* [Testing Browser UI](testing/test_browser_ui.md) - Using TestBrowserUi
* [Web Platform Tests](testing/web_platform_tests.md) - Shared tests across
browser vendors
* [Using Breakpad with `content_shell`](testing/using_breakpad_with_content_shell.md) -
diff --git a/docs/testing/test_browser_dialog.md b/docs/testing/test_browser_dialog.md
index 44cf92a..270fc51c 100644
--- a/docs/testing/test_browser_dialog.md
+++ b/docs/testing/test_browser_dialog.md
@@ -1,100 +1,109 @@
-# Testing Chrome browser dialogs with TestBrowserDialog
+# Testing Chrome browser UI with TestBrowserUi
-\#include "[chrome/browser/ui/test/test_browser_dialog.h]"
+\#include "[chrome/browser/ui/test/test_browser_ui.h]"
-`TestBrowserDialog` provides a way to register an `InProcessBrowserTest` testing
-harness with a framework that invokes Chrome browser dialogs in a consistent
-way. It optionally provides a way to invoke dialogs "interactively". This allows
-screenshots to be generated easily, with the same test data, to assist with UI
-review. It also provides a registry of dialogs so they can be systematically
-checked for subtle changes and regressions.
+`TestBrowserUi` (and convenience class `TestBrowserDialog`) provide ways to
+register an `InProcessBrowserTest` testing harness with a framework that invokes
+Chrome browser UI in a consistent way. They optionally provide a way to invoke
+UI "interactively". This allows screenshots to be generated easily, with the
+same test data, to assist with UI review. `TestBrowserUi` also provides a UI
+registry so pieces of UI can be systematically checked for subtle changes and
+regressions.
[TOC]
-## How to register a dialog
+## How to register UI
-If registering an existing dialog, there's a chance it already has a test
-harness inheriting, using, or with `typedef InProcessBrowserTest` (or a
-descendant of it). If so, using `TestBrowserDialog` is straightforward. Assume
-the existing InProcessBrowserTest is in `foo_dialog_browsertest.cc`:
+If registering existing UI, there's a chance it already has a test harness
+inheriting, using, or with `typedef InProcessBrowserTest` (or a descendant of
+it). If so, using `TestBrowserDialog` (for a dialog) is straightforward, and
+`TestBrowserUi` (for other types of UI) relatively so. Assume the existing
+`InProcessBrowserTest` is in `foo_browsertest.cc`:
- class FooDialogTest : public InProcessBrowserTest { ...
+ class FooUiTest : public InProcessBrowserTest { ...
-Change this to inherit from DialogBrowserTest, and override
-`ShowDialog(std::string)`. See [Advanced Usage](#Advanced-Usage) for details.
+Change this to inherit from `DialogBrowserTest` (for dialogs) or `UiBrowserTest`
+(for non-dialogs), and override `ShowUi(std::string)`. For non-dialogs, also
+override `VerifyUi()` and `WaitForUserDismissal()`. See
+[Advanced Usage](#Advanced-Usage) for details.
```cpp
-class FooDialogTest : public DialogBrowserTest {
+class FooUiTest : public UiBrowserTest {
public:
..
- // DialogBrowserTest:
- void ShowDialog(const std::string& name) override {
- /* Show dialog attached to browser() and leave it open. */
+ // UiBrowserTest:
+ void ShowUi(const std::string& name) override {
+ /* Show Ui attached to browser() and leave it open. */
+ }
+ // These next two are not necessary if subclassing DialogBrowserTest.
+ bool VerifyUi() override {
+ /* Return true if the UI was successfully shown. */
+ }
+ void WaitForUserDismissal() override {
+ /* Block until the UI has been dismissed. */
}
..
};
```
-Then add test invocations using the usual GTest macros, in
-`foo_dialog_browsertest.cc`:
+Finally, add test invocations using the usual GTest macros, in
+`foo_browsertest.cc`:
```cpp
-IN_PROC_BROWSER_TEST_F(FooDialogTest, InvokeDialog_default) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(FooUiTest, InvokeUi_default) {
+ ShowAndVerifyUi();
}
```
Notes:
-* The body of the test is always just "`RunDialog();`".
-* "`default`" is the `std::string` passed to `ShowDialog()` and can be
+* The body of the test is always just "`ShowAndVerifyUi();`".
+* "`default`" is the `std::string` passed to `ShowUi()` and can be
customized. See
- [Testing additional dialog "styles"](#Testing-additional-dialog-styles).
-* The text before `default` (in this case) must always be "`InvokeDialog_`".
+ [Testing additional UI "styles"](#Testing-additional-ui-styles).
+* The text before `default` (in this case) must always be "`InvokeUi_`".
### Concrete examples
* [chrome/browser/ui/ask_google_for_suggestions_dialog_browsertest.cc]
-* [chrome/browser/ui/autofill/card_unmask_prompt_view_browsertest.cc]
-* [chrome/browser/ui/collected_cookies_browsertest.cc]
-* [chrome/browser/ui/update_chrome_dialog_browsertest.cc]
+* [chrome/browser/infobars/infobars_browsertest.cc]
## Running the tests
-List the available dialogs with
+List the available pieces of UI with
- $ ./browser_tests --gtest_filter=BrowserDialogTest.Invoke
+ $ ./browser_tests --gtest_filter=BrowserUiTest.Invoke
-E.g. `FooDialogTest.InvokeDialog_default` should be listed. To show the dialog
+E.g. `FooUiTest.InvokeUi_default` should be listed. To show the UI
interactively, run
- $ ./browser_tests --gtest_filter=BrowserDialogTest.Invoke --interactive \
- --dialog=FooDialogTest.InvokeDialog_default
+ $ ./browser_tests --gtest_filter=BrowserUiTest.Invoke --interactive \
+ --ui=FooUiTest.InvokeUi_default
### Implementation
-`BrowserDialogTest.Invoke` searches for gtests that have "`InvokeDialog_`" in
-their name, so they can be collected in a list. Providing a `--dialog` argument
-will invoke that test case in a subprocess. Including `--interactive` will set
-up an environment for that subprocess that allows interactivity, e.g., to take
-screenshots. The test ends once the dialog is dismissed.
+`BrowserUiTest.Invoke` searches for gtests that have "`InvokeUi_`" in their
+names, so they can be collected in a list. Providing a `--ui` argument will
+invoke that test case in a subprocess. Including `--interactive` will set up an
+environment for that subprocess that allows interactivity, e.g., to take
+screenshots. The test ends once the UI is dismissed.
-The `FooDialogTest.InvokeDialog_default` test case **will still be run in the
-usual browser_tests test suite**. Ensure it passes, and isn’t flaky. This will
-give your dialog some regression test coverage. `RunDialog()` checks to ensure a
-dialog is actually created when it invokes `ShowDialog("default")`.
+The `FooUiTest.InvokeUi_default` test case **will still be run in the usual
+browser_tests test suite**. Ensure it passes, and isn’t flaky. This will
+give your UI some regression test coverage. `ShowAndVerifyUi()` checks to ensure
+UI is actually created when it invokes `ShowUi("default")`.
-### BrowserDialogTest.Invoke
+### BrowserUiTest.Invoke
This is also run in browser_tests but, when run that way, the test case just
lists the registered test harnesses (it does *not* iterate over them). A
-subprocess is never created unless --dialog is passed on the command line.
+subprocess is never created unless --ui is passed on the command line.
## Advanced Usage
If your test harness inherits from a descendant of `InProcessBrowserTest` (one
-example: [ExtensionBrowserTest]) then the `SupportsTestDialog<>` template is
-provided. E.g.
+example: [ExtensionBrowserTest]) then the `SupportsTestUi<>` and
+`SupportsTestDialog` templates are provided. E.g.
```cpp
class ExtensionInstallDialogViewTestBase : public ExtensionBrowserTest { ...
@@ -107,43 +116,47 @@
public SupportsTestDialog<ExtensionBrowserTest> { ...
```
-### Testing additional dialog "styles"
+If you need to do any setup before `ShowUi()` is called, or any teardown in the
+non-interactive case, you can override the `PreShow()` and `DismissUi()
+methods.
-Add additional test cases, with a different string after "`InvokeDialog_`".
+### Testing additional UI "styles"
+
+Add additional test cases, with a different string after "`InvokeUi_`".
Example:
```cpp
-IN_PROC_BROWSER_TEST_F(CardUnmaskViewBrowserTest, InvokeDialog_expired) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(CardUnmaskViewBrowserTest, InvokeUi_expired) {
+ ShowAndVerifyUi();
}
-IN_PROC_BROWSER_TEST_F(CardUnmaskViewBrowserTest, InvokeDialog_valid) {
- RunDialog();
+IN_PROC_BROWSER_TEST_F(CardUnmaskViewBrowserTest, InvokeUi_valid) {
+ ShowAndVerifyUi();
}
```
The strings "`expired`" or “`valid`” will be given as arguments to
-`ShowDialog(std::string)`.
+`ShowUi(std::string)`.
## Rationale
Bug reference: [Issue 654151](http://crbug.com/654151).
-Chrome has a lot of browser dialogs; often for obscure use-cases and often hard
-to invoke. It has traditionally been difficult to be systematic while checking
-dialogs for possible regressions. For example, to investigate changes to shared
-layout parameters which are testable only with visual inspection.
+Chrome has a lot of browser UI; often for obscure use-cases and often hard to
+invoke. It has traditionally been difficult to be systematic while checking UI
+for possible regressions. For example, to investigate changes to shared layout
+parameters which are testable only with visual inspection.
For Chrome UI review, screenshots need to be taken. Iterating over all the
-"styles" that a dialog may appear with is fiddly. E.g. a login or particular web
+"styles" that UI may appear with is fiddly. E.g. a login or particular web
server setup may be required. It’s important to provide a consistent “look” for
UI review (e.g. same test data, same browser size, anchoring position, etc.).
-Some dialogs lack tests. Some dialogs have zero coverage on the bots. Dialogs
-can have tricky lifetimes and common mistakes are repeated. TestBrowserDialog
-runs simple "Show dialog" regression tests and can be extended to do more.
+Some UI lacks tests. Some UI has zero coverage on the bots. UI elements can have
+tricky lifetimes and common mistakes are repeated. TestBrowserUi runs simple
+"Show UI" regression tests and can be extended to do more.
-Even discovering the full set of dialogs present for each platform in Chrome is
+Even discovering the full set of UI present for each platform in Chrome is
[difficult](http://crbug.com/686239).
### Why browser_tests?
@@ -152,12 +165,12 @@
size that can be used as a dialog anchor and to take screenshots for UI
review.
* UI review have requested that screenshots be provided with the entire
- browser window so that the relative size of the dialog/change under
+ browser window so that the relative size of the UI element/change under
review can be assessed.
-* Some dialogs already have a test harness with appropriate setup (e.g. test
- data) running in browser_tests.
- * Supporting `BrowserDialogTest` should require minimal setup and minimal
+* Some UI already has a test harness with appropriate setup (e.g. test data)
+ running in browser_tests.
+ * Supporting `BrowserUiTest` should require minimal setup and minimal
ongoing maintenance.
* An alternative is to maintain a working end-to-end build target executable
@@ -167,19 +180,18 @@
`MaterialDesignController::Initialize()`, etc.).
* Why not chrome.exe?
- * E.g. a scrappy chrome:// page with links to invoke dialogs would be
- great!
+ * E.g. a scrappy chrome:// page with links to invoke UI would be great!
* But...
- * A dialog may have test data (e.g. credit card info) which shouldn’t
- be in the release build.
- * A dialog may use EmbeddedTestServer.
+ * UI may have test data (e.g. credit card info) which shouldn’t be in
+ the release build.
+ * UI may use EmbeddedTestServer.
* Higher maintenance cost - can’t leverage existing test harnesses.
## Future Work
-* Opt in more dialogs!
- * Eventually, all of them.
- * A `BrowserDialogTest` for every descendant of `views::DialogDelegate`.
+* Opt in more UI!
+ * Eventually, all of it.
+ * A `DialogBrowserTest` for every descendant of `views::DialogDelegate`.
* Automatically generate screenshots (for each platform, in various languages)
* Build upon [CL 2008283002](https://codereview.chromium.org/2008283002/)
@@ -188,8 +200,8 @@
* Probably requires altering the browser_test suite code directly rather
than just adding a test case as in the current approach
-* An automated test suite for dialogs
- * Test various ways to dismiss or hide a dialog
+* An automated test suite for UI
+ * Test various ways to dismiss or hide UI, especially dialogs
* e.g. native close (via taskbar?)
* close parent window (possibly via task bar)
* close parent tab
@@ -200,8 +212,8 @@
* Drag tab off browser into a new window
* Fullscreen that may create a new window/parent
-* Find obscure workflows for invoking dialogs that have no test coverage and
- cause crashes (e.g. [http://crrev.com/426302](http://crrev.com/426302))
+* Find obscure workflows for invoking UI that has no test coverage and causes
+ crashes (e.g. [http://crrev.com/426302](http://crrev.com/426302))
* Supporting window-modal dialogs with a null parent window.
* Find memory leaks, e.g. [http://crrev.com/432320](http://crrev.com/432320)
@@ -209,71 +221,69 @@
## Appendix: Sample output
-**$ ./out/gn_Debug/browser_tests --gtest_filter=BrowserDialogTest.Invoke**
+**$ ./out/gn_Debug/browser_tests --gtest_filter=BrowserUiTest.Invoke**
```
-Note: Google Test filter = BrowserDialogTest.Invoke
+Note: Google Test filter = BrowserUiTest.Invoke
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
-[----------] 1 test from BrowserDialogTest
-[ RUN ] BrowserDialogTest.Invoke
-[26879:775:0207/134949.118352:30434675...:INFO:browser_dialog_browsertest.cc(46)
-Pass one of the following after --dialog=
- AskGoogleForSuggestionsDialogTest.InvokeDialog_default
- CardUnmaskPromptViewBrowserTest.InvokeDialog_expired
- CardUnmaskPromptViewBrowserTest.InvokeDialog_valid
- CollectedCookiesTestMd.InvokeDialog_default
- UpdateRecommendedDialogTest.InvokeDialog_default
-/* lots more will eventually be listed here */
-[ OK ] BrowserDialogTest.Invoke (0 ms)
-[----------] 1 test from BrowserDialogTest (0 ms total)
+[----------] 1 test from BrowserUiTest
+[ RUN ] BrowserUiTest.Invoke
+[26879:775:0207/134949.118352:30434675...:INFO:browser_ui_browsertest.cc(46)
+Pass one of the following after --ui=
+ AppInfoDialogBrowserTest.InvokeUi_default
+ AskGoogleForSuggestionsDialogTest.DISABLED_InvokeUi_default
+ BluetoothChooserBrowserTest.InvokeUi_ConnectedBubble
+ BluetoothChooserBrowserTest.InvokeUi_ConnectedModal
+/* and many more */
+[ OK ] BrowserUiTest.Invoke (0 ms)
+[----------] 1 test from BrowserUiTest (0 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (1 ms total)
[ PASSED ] 1 test.
-[1/1] BrowserDialogTest.Invoke (334 ms)
+[1/1] BrowserUiTest.Invoke (334 ms)
SUCCESS: all tests passed.
```
-**$ ./out/gn_Debug/browser_tests --gtest_filter=BrowserDialogTest.Invoke
---dialog=CardUnmaskPromptViewBrowserTest.InvokeDialog_expired**
+**$ ./out/gn_Debug/browser_tests --gtest_filter=BrowserUiTest.Invoke
+--ui=CardUnmaskPromptViewBrowserTest.InvokeUi_expired**
```
-Note: Google Test filter = BrowserDialogTest.Invoke
+Note: Google Test filter = BrowserUiTest.Invoke
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
-[----------] 1 test from BrowserDialogTest
-[ RUN ] BrowserDialogTest.Invoke
+[----------] 1 test from BrowserUiTest
+[ RUN ] BrowserUiTest.Invoke
Note: Google Test filter = CardUnmaskPromptViewBrowserTest.InvokeDefault
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from CardUnmaskPromptViewBrowserTest, where TypeParam =
-[ RUN ] CardUnmaskPromptViewBrowserTest.InvokeDialog_expired
+[ RUN ] CardUnmaskPromptViewBrowserTest.InvokeUi_expired
/* 7 lines of uninteresting log spam */
-[ OK ] CardUnmaskPromptViewBrowserTest.InvokeDialog_expired (1324 ms)
+[ OK ] CardUnmaskPromptViewBrowserTest.InvokeUi_expired (1324 ms)
[----------] 1 test from CardUnmaskPromptViewBrowserTest (1324 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (1325 ms total)
[ PASSED ] 1 test.
-[ OK ] BrowserDialogTest.Invoke (1642 ms)
-[----------] 1 test from BrowserDialogTest (1642 ms total)
+[ OK ] BrowserUiTest.Invoke (1642 ms)
+[----------] 1 test from BrowserUiTest (1642 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (1642 ms total)
[ PASSED ] 1 test.
-[1/1] BrowserDialogTest.Invoke (2111 ms)
+[1/1] BrowserUiTest.Invoke (2111 ms)
SUCCESS: all tests passed.
```
-**$ ./out/gn_Debug/browser_tests --gtest_filter=BrowserDialogTest.Invoke
---dialog=CardUnmaskPromptViewBrowserTest.InvokeDialog_expired --interactive**
+**$ ./out/gn_Debug/browser_tests --gtest_filter=BrowserUiTest.Invoke
+--dialog=CardUnmaskPromptViewBrowserTest.InvokeUi_expired --interactive**
```
/*
* Output as above, except the test are not interleaved, and the browser window
- * should remain open until the dialog is dismissed
+ * should remain open until the UI is dismissed
*/
```
+[chrome/browser/ui/test/test_browser_ui.h]: https://cs.chromium.org/chromium/src/chrome/browser/ui/test/test_browser_ui.h
[chrome/browser/ui/test/test_browser_dialog.h]: https://cs.chromium.org/chromium/src/chrome/browser/ui/test/test_browser_dialog.h
-[chrome/browser/ui/autofill/card_unmask_prompt_view_browsertest.cc]: https://cs.chromium.org/chromium/src/chrome/browser/ui/autofill/card_unmask_prompt_view_browsertest.cc?l=104&q=ShowDialog
-[chrome/browser/ui/collected_cookies_browsertest.cc]: https://cs.chromium.org/chromium/src/chrome/browser/ui/collected_cookies_browsertest.cc?l=26&q=ShowDialog
-[chrome/browser/ui/ask_google_for_suggestions_dialog_browsertest.cc]: https://cs.chromium.org/chromium/src/chrome/browser/ui/ask_google_for_suggestions_dialog_browsertest.cc?l=18&q=ShowDialog
-[chrome/browser/ui/update_chrome_dialog_browsertest.cc]: https://cs.chromium.org/chromium/src/chrome/browser/ui/update_chrome_dialog_browsertest.cc?l=15&q=ShowDialog
+[chrome/browser/ui/ask_google_for_suggestions_dialog_browsertest.cc]: https://cs.chromium.org/chromium/src/chrome/browser/ui/ask_google_for_suggestions_dialog_browsertest.cc?l=18&q=ShowUi
+[chrome/browser/infobars/infobars_browsertest.cc]: https://cs.chromium.org/chromium/src/chrome/browser/infobars/infobars_browsertest.cc?l=134&q=UiBrowserTest
[ExtensionBrowserTest]: https://cs.chromium.org/chromium/src/chrome/browser/extensions/extension_browsertest.h?q=extensionbrowsertest&l=40
diff --git a/testing/buildbot/filters/mash.browser_tests.filter b/testing/buildbot/filters/mash.browser_tests.filter
index 875d362..c6b1b04 100644
--- a/testing/buildbot/filters/mash.browser_tests.filter
+++ b/testing/buildbot/filters/mash.browser_tests.filter
@@ -45,7 +45,7 @@
VolumeControllerTest.*
# Tests from elsewhere.
-BrowserDialogTest.*
+BrowserUiTest.*
CastSessionBrowserTest.*
ChromeContentBrowserClientMashTest.*
ChromeContentRendererClientSearchBoxTest.*