chromium/chrome/browser/download/download_item_model_unittest.cc

// Copyright 2012 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/download/download_item_model.h"

#include <stddef.h>
#include <stdint.h>

#include <string>
#include <vector>

#include "base/check_op.h"
#include "base/i18n/rtl.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "base/time/time.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
#include "chrome/browser/download/download_commands.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_core_service_impl.h"
#include "chrome/browser/download/download_ui_model.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/download/public/common/download_danger_type.h"
#include "components/download/public/common/download_interrupt_reasons.h"
#include "components/download/public/common/download_item_rename_handler.h"
#include "components/download/public/common/mock_download_item.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/signin/public/identity_manager/identity_test_utils.h"
#include "components/vector_icons/vector_icons.h"
#include "content/public/browser/download_item_utils.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/text/bytes_formatting.h"
#include "ui/base/ui_base_features.h"

#if !BUILDFLAG(IS_ANDROID)
#include "base/strings/pattern.h"
#include "chrome/test/base/testing_profile.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "ui/views/vector_icons.h"

#if BUILDFLAG(FULL_SAFE_BROWSING)
#include "chrome/browser/safe_browsing/download_protection/download_protection_service.h"
#endif  // BUILDFLAG(FULL_SAFE_BROWSING)

#endif  // BUILDFLAG(IS_ANDROID)

DownloadItem;
FailState;
DownloadFileType;
_;
Mock;
NiceMock;
Return;
ReturnRef;
ReturnRefOfCopy;
SetArgPointee;

#if BUILDFLAG(FULL_SAFE_BROWSING)
TailoredVerdict;
#endif

namespace {

// Create a char array that has as many elements as there are download
// interrupt reasons. We can then use that in a static_assert to make sure
// that all the interrupt reason codes are accounted for. The reason codes are
// unfortunately sparse, making this necessary.
char kInterruptReasonCounter[] =;
const size_t kInterruptReasonCount =;

// Default target path for a mock download item in DownloadItemModelTest.
const base::FilePath::CharType kDefaultTargetFilePath[] =);

const base::FilePath::CharType kDefaultDisplayFileName[] =);

// Default URL for a mock download item in DownloadItemModelTest.
const char kDefaultURL[] =;

// A DownloadCoreService that returns the TestChromeDownloadManagerDelegate.
class TestDownloadCoreService : public DownloadCoreServiceImpl {};

TestDownloadCoreService::TestDownloadCoreService(Profile* profile)
    :{}

TestDownloadCoreService::~TestDownloadCoreService() = default;

ChromeDownloadManagerDelegate*
TestDownloadCoreService::GetDownloadManagerDelegate() {}

static std::unique_ptr<KeyedService> CreateTestDownloadCoreService(
    content::BrowserContext* browser_context) {}

class TestChromeDownloadManagerDelegate : public ChromeDownloadManagerDelegate {};

TestChromeDownloadManagerDelegate::~TestChromeDownloadManagerDelegate() =
    default;

bool TestChromeDownloadManagerDelegate::IsOpenInBrowserPreferredForFile(
    const base::FilePath& path) {}

class FakeRenameHandler : public download::DownloadItemRenameHandler {};

}  // namespace

class DownloadItemModelTest : public testing::Test {};

TEST_F(DownloadItemModelTest, InterruptedStatus) {}

TEST_F(DownloadItemModelTest, InterruptTooltip) {}

TEST_F(DownloadItemModelTest, InProgressStatus) {}

TEST_F(DownloadItemModelTest, CompletedStatus) {}

TEST_F(DownloadItemModelTest, CompletedBubbleWarningStatusText) {}

TEST_F(DownloadItemModelTest,
       CompletedBubbleWarningStatusText_FiletypeWarning) {}

#if !BUILDFLAG(IS_ANDROID)

TEST_F(DownloadItemModelTest, ShouldPreferOpeningInBrowser) {}

TEST_F(DownloadItemModelTest, ShouldShowInBubble) {}

TEST_F(DownloadItemModelTest, GetBubbleStatusMessageWithBytes) {}
#endif  // !BUILDFLAG(IS_ANDROID)

TEST_F(DownloadItemModelTest, ShouldShowInShelf) {}

TEST_F(DownloadItemModelTest, DangerLevel) {}

TEST_F(DownloadItemModelTest, HasSupportedImageMimeType) {}

TEST_F(DownloadItemModelTest, ShouldRemoveFromShelfWhenComplete) {}

TEST_F(DownloadItemModelTest, ShouldShowDropdown) {}

TEST_F(DownloadItemModelTest, RenamingProgress) {}

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
class DownloadItemModelTailoredWarningTest : public DownloadItemModelTest {};

TEST_F(DownloadItemModelTailoredWarningTest, GetTailoredWarningType) {}

class DownloadItemModelTailoredWarningDisabledTest
    : public DownloadItemModelTailoredWarningTest {};

TEST_F(DownloadItemModelTailoredWarningDisabledTest,
       GetBubbleUIInfoForTailoredWarning_Disabled) {}

#endif  // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)