#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
#endif
DownloadItem;
FailState;
DownloadFileType;
_;
Mock;
NiceMock;
Return;
ReturnRef;
ReturnRefOfCopy;
SetArgPointee;
#if BUILDFLAG(FULL_SAFE_BROWSING)
TailoredVerdict;
#endif
namespace {
char kInterruptReasonCounter[] = …;
const size_t kInterruptReasonCount = …;
const base::FilePath::CharType kDefaultTargetFilePath[] = …);
const base::FilePath::CharType kDefaultDisplayFileName[] = …);
const char kDefaultURL[] = …;
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 { … };
}
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
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