chromium/chrome/browser/media/webrtc/webrtc_video_quality_browsertest.cc

// Copyright 2013 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 <stddef.h>

#include "base/base64.h"
#include "base/command_line.h"
#include "base/environment.h"
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
#include "base/process/launch.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "base/test/test_timeouts.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/media/webrtc/webrtc_browsertest_base.h"
#include "chrome/browser/media/webrtc/webrtc_browsertest_common.h"
#include "chrome/browser/media/webrtc/webrtc_browsertest_perf.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/infobars/content/content_infobar_manager.h"
#include "components/infobars/core/infobar.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "media/base/media_switches.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/python_utils.h"
#include "testing/perf/perf_test.h"
#include "third_party/blink/public/common/features.h"
#include "ui/gl/gl_switches.h"

namespace {
std::string MakeLabel(const char* test_name, const std::string& video_codec) {}
}  // namespace

static const base::FilePath::CharType kFrameAnalyzerExecutable[] =FILE_PATH_LITERAL("frame_analyzer.exe");
#else
    FILE_PATH_LITERAL("frame_analyzer");
#endif

static const base::FilePath::CharType kCapturedYuvFileName[] =);
static const base::FilePath::CharType kCapturedWebmFileName[] =);
static const char kMainWebrtcTestHtmlPage[] =;
static const char kCapturingWebrtcHtmlPage[] =;

static const struct VideoQualityTestConfig {} kVideoConfigurations[] =;

// Test the video quality of the WebRTC output.
//
// Prerequisites: This test case must run on a machine with a chrome playing
// the video from the reference files located in GetReferenceFilesDir().
// The file kReferenceY4mFileName.kY4mFileExtension is played using a
// FileVideoCaptureDevice and its sibling with kYuvFileExtension is used for
// comparison.
//
// You must also compile the frame_analyzer target before you run this
// test to get all the tools built.
//
// The test runs several custom binaries - rgba_to_i420 converter and
// frame_analyzer. Both tools can be found under third_party/webrtc/rtc_tools.
// The test also runs a stand alone Python implementation of a WebSocket server
// (pywebsocket) and a barcode_decoder script.
class WebRtcVideoQualityBrowserTest : public WebRtcTestBase,
    public testing::WithParamInterface<VideoQualityTestConfig> {};

INSTANTIATE_TEST_SUITE_P();

// WebRTC's frame_analyzer doesn't build from a Chromium's component build.
#if defined(COMPONENT_BUILD)
#define MAYBE_MANUAL_TestVideoQualityVp8
#else
#define MAYBE_MANUAL_TestVideoQualityVp8
#endif
IN_PROC_BROWSER_TEST_P(WebRtcVideoQualityBrowserTest,
                       MAYBE_MANUAL_TestVideoQualityVp8) {}

// Flaky on windows and WebRTC's frame_analyzer doesn't build from a Chromium's
// component build.
// TODO(crbug.com/40100787): re-enable when flakiness is investigated, diagnosed
// and resolved.
#if BUILDFLAG(IS_WIN) || defined(COMPONENT_BUILD)
#define MAYBE_MANUAL_TestVideoQualityVp9
#else
#define MAYBE_MANUAL_TestVideoQualityVp9
#endif
IN_PROC_BROWSER_TEST_P(WebRtcVideoQualityBrowserTest,
                       MAYBE_MANUAL_TestVideoQualityVp9) {}

#if BUILDFLAG(RTC_USE_H264)

// Flaky on mac (crbug.com/754684) and WebRTC's frame_analyzer doesn't build
// from a Chromium's component build.
#if BUILDFLAG(IS_MAC) || defined(COMPONENT_BUILD)
#define MAYBE_MANUAL_TestVideoQualityH264
#else
#define MAYBE_MANUAL_TestVideoQualityH264
#endif

IN_PROC_BROWSER_TEST_P(WebRtcVideoQualityBrowserTest,
                       MAYBE_MANUAL_TestVideoQualityH264) {
  base::ScopedAllowBlockingForTesting allow_blocking;
  // Only run test if run-time feature corresponding to |rtc_use_h264| is on.
  if (!base::FeatureList::IsEnabled(
          blink::features::kWebRtcH264WithOpenH264FFmpeg)) {
    LOG(WARNING) << "Run-time feature WebRTC-H264WithOpenH264FFmpeg disabled. "
        "Skipping WebRtcVideoQualityBrowserTest.MANUAL_TestVideoQualityH264 "
        "(test \"OK\")";
    return;
  }
  TestVideoQuality("H264", true /* prefer_hw_video_codec */);
}

#endif  // BUILDFLAG(RTC_USE_H264)