chromium/chrome/browser/ui/web_applications/web_app_engagement_browsertest.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#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) {}

// Must be zero-based as this will be stored in a bitset.
enum HistogramIndex {};

// The order (indices) must match HistogramIndex enum above:
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

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) {}

// TODO(crbug.com/40884336): Flaky on Mac.
#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) {}

// On Chrome OS, PWAs are launched via the app service rather than via command
// line flags.
#if !BUILDFLAG(IS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest, CommandLineWindowByUrl) {}

// TODO(crbug.com/40877225): Flaky on Mac.
#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

}  // namespace web_app