#include <cmath>
#include <string_view>
#include "base/command_line.h"
#include "base/containers/flat_map.h"
#include "base/files/file_util.h"
#include "base/strings/stringprintf.h"
#include "base/test/trace_event_analyzer.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/api/tab_capture/tab_capture_performance_test_base.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/test_launcher_utils.h"
#include "chrome/test/base/test_switches.h"
#include "chrome/test/base/tracing.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "extensions/common/switches.h"
#include "extensions/test/extension_test_message_listener.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_result_reporter.h"
#include "ui/compositor/compositor_switches.h"
#include "ui/gl/gl_switches.h"
namespace {
constexpr int kTrimEvents = …;
constexpr int kMinDataPointsForFullRun = …;
constexpr int kMinDataPointsForQuickRun = …;
constexpr char kMetricPrefixTabCapture[] = …;
constexpr char kMetricCaptureMs[] = …;
constexpr char kMetricCaptureFailRatePercent[] = …;
constexpr char kMetricCaptureLatencyMs[] = …;
constexpr char kMetricRendererFrameDrawMs[] = …;
constexpr char kEventCapture[] = …;
constexpr char kEventSuffixFailRate[] = …;
constexpr char kEventSuffixLatency[] = …;
constexpr char kEventCommitAndDrawCompositorFrame[] = …;
const base::flat_map<std::string, std::string> kEventToMetricMap(
{ … });
perf_test::PerfResultReporter SetUpTabCaptureReporter(
const std::string& story) { … }
std::string GetMetricFromEventName(const std::string& event_name) { … }
#define EXPECT_FOR_PERFORMANCE_RUN(expr) …
enum TestFlags { … };
bool EventWasSuccessful(const trace_analyzer::TraceEvent* event) { … }
class TabCapturePerformanceTest : public TabCapturePerformanceTestBase,
public testing::WithParamInterface<int> { … };
}
#if BUILDFLAG(IS_CHROMEOS)
#define MAYBE_Performance …
#elif BUILDFLAG(IS_MAC)
#define MAYBE_Performance …
#elif BUILDFLAG(IS_LINUX) && defined(ADDRESS_SANITIZER)
#define MAYBE_Performance …
#else
#define MAYBE_Performance …
#endif
IN_PROC_BROWSER_TEST_P(TabCapturePerformanceTest, MAYBE_Performance) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
INSTANTIATE_TEST_SUITE_P(All,
TabCapturePerformanceTest,
testing::Values(kUseGpu,
kTestThroughWebRTC | kUseGpu));
#else
INSTANTIATE_TEST_SUITE_P(…);
#endif