#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <bitset>
#include <vector>
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/metrics/statistics_recorder.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h"
#include "chrome/browser/ui/startup/startup_types.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/web_applications/app_browser_controller.h"
#include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h"
#include "chrome/browser/ui/web_applications/web_app_browsertest_base.h"
#include "chrome/browser/ui/web_applications/web_app_metrics.h"
#include "chrome/browser/web_applications/external_install_options.h"
#include "chrome/browser/web_applications/externally_managed_app_manager.h"
#include "chrome/browser/web_applications/mojom/user_display_mode.mojom.h"
#include "chrome/browser/web_applications/web_app_helpers.h"
#include "chrome/browser/web_applications/web_app_install_info.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/services/app_service/public/cpp/app_launch_util.h"
#include "components/site_engagement/content/engagement_type.h"
#include "components/site_engagement/content/site_engagement_service.h"
#include "components/webapps/browser/install_result_code.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "extensions/common/constants.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/views/widget/widget.h"
#include "url/gurl.h"
namespace {
GURL GetUrlForSuffix(const std::string& prefix, int suffix) { … }
enum HistogramIndex { … };
const char* kHistogramNames[] = …;
const char* HistogramEnumIndexToStr(int histogram_index) { … }
Histograms;
void ExpectBucketCounts(const base::HistogramTester& tester,
const Histograms& histograms_mask,
site_engagement::EngagementType type,
base::HistogramBase::Count count) { … }
void ExpectTotalCounts(const base::HistogramTester& tester,
const Histograms& histograms_mask,
base::HistogramBase::Count count) { … }
void ExpectLaunchCounts(const base::HistogramTester& tester,
base::HistogramBase::Count windowLaunches,
base::HistogramBase::Count tabLaunches) { … }
}
namespace web_app {
class WebAppEngagementBrowserTest : public WebAppBrowserTestBase { … };
IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest, AppInWindow) { … }
IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest, DiyAppInWindow) { … }
IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest, AppInTab) { … }
IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest, DiyAppInTab) { … }
IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest, AppWithoutScope) { … }
IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest, TwoApps) { … }
IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest, ManyUserApps) { … }
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_DefaultApp …
#else
#define MAYBE_DefaultApp …
#endif
IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest, MAYBE_DefaultApp) { … }
IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest, NavigateAwayFromAppTab) { … }
IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest, RecordedForNonApps) { … }
#if !BUILDFLAG(IS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest, CommandLineWindowByUrl) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_CommandLineWindowByAppId …
#else
#define MAYBE_CommandLineWindowByAppId …
#endif
IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest,
MAYBE_CommandLineWindowByAppId) { … }
IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest, CommandLineTab) { … }
#endif
}