chromium/chrome/browser/media/webrtc/webrtc_event_log_uploader_impl_unittest.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.

#include "chrome/browser/media/webrtc/webrtc_event_log_uploader.h"

#include <memory>
#include <string>

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/media/webrtc/webrtc_event_log_manager_common.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "content/public/test/browser_task_environment.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/test/test_url_loader_factory.h"
#include "services/network/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace webrtc_event_logging {

_;
StrictMock;
BrowserContextId;

namespace {
class UploadObserver {};

#if BUILDFLAG(IS_POSIX)
void RemovePermissions(const base::FilePath& path, int removed_permissions) {}

void RemoveReadPermissions(const base::FilePath& path) {}
#endif  // BUILDFLAG(IS_POSIX)
}  // namespace

class WebRtcEventLogUploaderImplTest : public ::testing::Test {};

TEST_F(WebRtcEventLogUploaderImplTest, SuccessfulUploadReportedToObserver) {}

// Version #1 - request reported as successful, but got an error (404) as the
// HTTP return code.
// Due to the simplicitly of both tests, this also tests the scenario
// FileDeletedAfterUnsuccessfulUpload, rather than giving each its own test.
TEST_F(WebRtcEventLogUploaderImplTest, UnsuccessfulUploadReportedToObserver1) {}

// Version #2 - request reported as failed; HTTP return code ignored, even
// if it's a purported success.
TEST_F(WebRtcEventLogUploaderImplTest, UnsuccessfulUploadReportedToObserver2) {}

#if BUILDFLAG(IS_POSIX)
TEST_F(WebRtcEventLogUploaderImplTest, FailureToReadFileReportedToObserver) {}

TEST_F(WebRtcEventLogUploaderImplTest, NonExistentFileReportedToObserver) {}
#endif  // BUILDFLAG(IS_POSIX)

TEST_F(WebRtcEventLogUploaderImplTest, FilesUpToMaxSizeUploaded) {}

TEST_F(WebRtcEventLogUploaderImplTest, ExcessivelyLargeFilesNotUploaded) {}

TEST_F(WebRtcEventLogUploaderImplTest,
       CancelBeforeUploadCompletionCallsCallbackWithFalse) {}

TEST_F(WebRtcEventLogUploaderImplTest, SecondCallToCancelHasNoEffect) {}

TEST_F(WebRtcEventLogUploaderImplTest,
       CancelAfterUploadCompletionCallbackWasCalledHasNoEffect) {}

TEST_F(WebRtcEventLogUploaderImplTest, CancelOnAbortedUploadHasNoEffect) {}

TEST_F(WebRtcEventLogUploaderImplTest, CancelOnOngoingUploadDeletesFile) {}

TEST_F(WebRtcEventLogUploaderImplTest,
       GetWebRtcLogFileInfoReturnsCorrectInfoBeforeUploadDone) {}

TEST_F(WebRtcEventLogUploaderImplTest,
       GetWebRtcLogFileInfoReturnsCorrectInfoAfterUploadSucceeded) {}

TEST_F(WebRtcEventLogUploaderImplTest,
       GetWebRtcLogFileInfoReturnsCorrectInfoWhenCalledOnCancelledUpload) {}

// TODO(crbug.com/40545136): Add a unit test that shows that files with
// non-ASCII filenames are discard. (Or, alternatively, add support for them.)

}  // namespace webrtc_event_logging