#include "chrome/test/base/ui_test_utils.h"
#include <stddef.h>
#include <memory>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/test_timeouts.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "chrome/browser/ui/location_bar/location_bar.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/find_result_waiter.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/download/public/common/download_item.h"
#include "components/find_in_page/find_notification_details.h"
#include "components/find_in_page/find_tab_helper.h"
#include "components/history/core/browser/history_service_observer.h"
#include "components/javascript_dialogs/app_modal_dialog_controller.h"
#include "components/javascript_dialogs/app_modal_dialog_queue.h"
#include "components/omnibox/browser/autocomplete_controller.h"
#include "components/omnibox/browser/autocomplete_controller_emitter.h"
#include "components/omnibox/browser/omnibox_controller.h"
#include "components/omnibox/browser/omnibox_edit_model.h"
#include "components/omnibox/browser/omnibox_view.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/download_test_observer.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "net/base/filename_util.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_constants.h"
#include "net/cookies/cookie_monster.h"
#include "net/cookies/cookie_store.h"
#include "net/cookies/cookie_util.h"
#include "services/device/public/mojom/geoposition.mojom.h"
#include "services/network/public/cpp/resource_request_body.h"
#include "services/network/public/mojom/cookie_manager.mojom.h"
#include "third_party/blink/public/common/chrome_debug_urls.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/test/widget_activation_waiter.h"
#include "ui/views/widget/widget_interactive_uitest_utils.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
#if defined(TOOLKIT_VIEWS)
#include "ui/views/test/widget_test_api.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#endif
NavigationController;
NavigationEntry;
OpenURLParams;
Referrer;
WebContents;
namespace ui_test_utils {
namespace {
Browser* WaitForBrowserNotInSet(std::set<Browser*> excluded_browsers) { … }
class AppModalDialogWaiter : public javascript_dialogs::AppModalDialogObserver { … };
class AutocompleteChangeObserver : public AutocompleteController::Observer { … };
class WebContentsDestructionObserver : public content::WebContentsObserver { … };
}
bool GetCurrentTabTitle(const Browser* browser, std::u16string* title) { … }
void NavigateToURL(NavigateParams* params) { … }
void NavigateToURLWithPost(Browser* browser, const GURL& url) { … }
content::RenderFrameHost* NavigateToURL(Browser* browser, const GURL& url) { … }
content::RenderFrameHost*
NavigateToURLWithDispositionBlockUntilNavigationsComplete(
Browser* browser,
const GURL& url,
int number_of_navigations,
WindowOpenDisposition disposition,
int browser_test_flags) { … }
content::RenderFrameHost* NavigateToURLWithDisposition(
Browser* browser,
const GURL& url,
WindowOpenDisposition disposition,
int browser_test_flags) { … }
content::RenderFrameHost* NavigateToURLBlockUntilNavigationsComplete(
Browser* browser,
const GURL& url,
int number_of_navigations) { … }
base::FilePath GetTestFilePath(const base::FilePath& dir,
const base::FilePath& file) { … }
GURL GetTestUrl(const base::FilePath& dir, const base::FilePath& file) { … }
bool GetRelativeBuildDirectory(base::FilePath* build_dir) { … }
javascript_dialogs::AppModalDialogController* WaitForAppModalDialog() { … }
#if defined(TOOLKIT_VIEWS)
void WaitForViewVisibility(Browser* browser, ViewID vid, bool visible) { … }
#endif
int FindInPage(WebContents* tab,
const std::u16string& search_string,
bool forward,
bool match_case,
int* ordinal,
gfx::Rect* selection_rect) { … }
void DownloadURL(Browser* browser, const GURL& download_url) { … }
void WaitForAutocompleteDone(Browser* browser) { … }
bool WaitForMinimized(Browser* browser) { … }
bool WaitForMaximized(Browser* browser) { … }
views::AsyncWidgetRequestWaiter CreateAsyncWidgetRequestWaiter(
Browser& browser) { … }
void SetAndWaitForBounds(Browser& browser, const gfx::Rect& bounds) { … }
bool MaximizeAndWaitUntilUIUpdateDone(Browser& browser) { … }
FullscreenWaiter::FullscreenWaiter(Browser* browser,
FullscreenWaiter::Expectation expectation)
: … { … }
FullscreenWaiter::~FullscreenWaiter() = default;
void FullscreenWaiter::Wait() { … }
void FullscreenWaiter::OnFullscreenStateChanged() { … }
bool FullscreenWaiter::IsSatisfied() const { … }
void ToggleFullscreenModeAndWait(Browser* browser) { … }
void WaitUntilBrowserBecomeActive(Browser* browser) { … }
bool IsBrowserActive(Browser* browser) { … }
Browser* OpenNewEmptyWindowAndWaitUntilActivated(
Profile* profile,
bool should_trigger_session_restore) { … }
BrowserSetLastActiveWaiter::BrowserSetLastActiveWaiter(
Browser* browser,
bool wait_for_set_last_active_observed)
: … { … }
BrowserSetLastActiveWaiter::~BrowserSetLastActiveWaiter() { … }
void BrowserSetLastActiveWaiter::Wait() { … }
void BrowserSetLastActiveWaiter::OnBrowserSetLastActive(Browser* browser) { … }
void WaitForBrowserSetLastActive(Browser* browser,
bool wait_for_set_last_active_observed) { … }
void SendToOmniboxAndSubmit(Browser* browser,
const std::string& input,
base::TimeTicks match_selection_timestamp) { … }
Browser* GetBrowserNotInSet(const std::set<Browser*>& excluded_browsers) { … }
namespace {
void GetCookieCallback(base::RepeatingClosure callback,
net::CookieList* cookies,
const net::CookieAccessResultList& cookie_list,
const net::CookieAccessResultList& excluded_cookies) { … }
}
void GetCookies(const GURL& url,
WebContents* contents,
int* value_size,
std::string* value) { … }
AllTabsObserver::AllTabsObserver() = default;
AllTabsObserver::~AllTabsObserver() { … }
void AllTabsObserver::AddAllBrowsers() { … }
void AllTabsObserver::Wait() { … }
void AllTabsObserver::ConditionMet() { … }
void AllTabsObserver::OnTabStripModelChanged(
TabStripModel* tab_strip_model,
const TabStripModelChange& change,
const TabStripSelectionChange& selection) { … }
void AllTabsObserver::OnBrowserAdded(Browser* browser) { … }
void AllTabsObserver::AddBrowser(const Browser* browser) { … }
void AllTabsObserver::AddWebContents(content::WebContents* web_contents) { … }
void AllTabsObserver::OnWebContentsDestroyed(WebContents* web_contents) { … }
AllTabsObserver::TabNavigationMapEntry::TabNavigationMapEntry() = default;
AllTabsObserver::TabNavigationMapEntry::~TabNavigationMapEntry() = default;
UrlLoadObserver::UrlLoadObserver(const GURL& url) : … { … }
UrlLoadObserver::~UrlLoadObserver() = default;
std::unique_ptr<base::CheckedObserver> UrlLoadObserver::ProcessOneContents(
WebContents* web_contents) { … }
void UrlLoadObserver::OnDidStopLoading(WebContents* web_contents) { … }
UrlLoadObserver::LoadStopObserver::LoadStopObserver(UrlLoadObserver* owner,
WebContents* web_contents)
: … { … }
UrlLoadObserver::LoadStopObserver::~LoadStopObserver() = default;
void UrlLoadObserver::LoadStopObserver::DidStopLoading() { … }
HistoryEnumerator::HistoryEnumerator(Profile* profile) { … }
HistoryEnumerator::~HistoryEnumerator() { … }
class WaitHistoryLoadedObserver : public history::HistoryServiceObserver { … };
WaitHistoryLoadedObserver::WaitHistoryLoadedObserver(
content::MessageLoopRunner* runner)
: … { … }
WaitHistoryLoadedObserver::~WaitHistoryLoadedObserver() { … }
void WaitHistoryLoadedObserver::OnHistoryServiceLoaded(
history::HistoryService* service) { … }
void WaitForHistoryToLoad(history::HistoryService* history_service) { … }
Browser* WaitForBrowserToOpen() { … }
void WaitForBrowserToClose(Browser* browser) { … }
TabAddedWaiter::TabAddedWaiter(Browser* browser) { … }
content::WebContents* TabAddedWaiter::Wait() { … }
void TabAddedWaiter::OnTabStripModelChanged(
TabStripModel* tab_strip_model,
const TabStripModelChange& change,
const TabStripSelectionChange& selection) { … }
AllBrowserTabAddedWaiter::AllBrowserTabAddedWaiter() { … }
AllBrowserTabAddedWaiter::~AllBrowserTabAddedWaiter() { … }
content::WebContents* AllBrowserTabAddedWaiter::Wait() { … }
void AllBrowserTabAddedWaiter::OnTabStripModelChanged(
TabStripModel* tab_strip_model,
const TabStripModelChange& change,
const TabStripSelectionChange& selection) { … }
void AllBrowserTabAddedWaiter::OnBrowserAdded(Browser* browser) { … }
BrowserChangeObserver::BrowserChangeObserver(Browser* browser, ChangeType type)
: … { … }
BrowserChangeObserver::~BrowserChangeObserver() { … }
Browser* BrowserChangeObserver::Wait() { … }
void BrowserChangeObserver::OnBrowserAdded(Browser* browser) { … }
void BrowserChangeObserver::OnBrowserRemoved(Browser* browser) { … }
CheckWaiter::CheckWaiter(base::RepeatingCallback<bool()> callback,
bool expected,
const base::TimeDelta& timeout)
: … { … }
CheckWaiter::~CheckWaiter() = default;
void CheckWaiter::Wait() { … }
bool CheckWaiter::Check() { … }
ViewBoundsWaiter::ViewBoundsWaiter(views::View* observed_view)
: … { … }
ViewBoundsWaiter::~ViewBoundsWaiter() { … }
void ViewBoundsWaiter::WaitForNonEmptyBounds() { … }
void ViewBoundsWaiter::OnViewBoundsChanged(views::View* observed_view) { … }
}