chromium/content/browser/download/save_package_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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/342213636): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "content/browser/download/save_package.h"

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

#include <string>

#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "content/browser/download/save_file_manager.h"
#include "content/public/browser/browser_context.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/fake_local_frame.h"
#include "content/test/test_render_view_host.h"
#include "content/test/test_web_contents.h"
#include "net/test/url_request/url_request_mock_http_job.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "url/gurl.h"

namespace content {

#define FPL
#define HTML_EXTENSION
#if BUILDFLAG(IS_WIN)
#define FPL_HTML_EXTENSION
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
#define FPL_HTML_EXTENSION
#endif

namespace {

// This constant copied from save_package.cc.
#if BUILDFLAG(IS_WIN)
const uint32_t kMaxFilePathLength = MAX_PATH - 1;
const uint32_t kMaxFileNameLength = MAX_PATH - 1;
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
const uint32_t kMaxFilePathLength =;
const uint32_t kMaxFileNameLength =;
#endif

bool HasOrdinalNumber(const base::FilePath::StringType& filename) {}

}  // namespace

class SavePackageTest : public RenderViewHostImplTestHarness {};

static const struct {} kGeneratedFiles[] =;

TEST_F(SavePackageTest, TestSuccessfullyGenerateSavePackageFilename) {}

TEST_F(SavePackageTest, TestUnSuccessfullyGenerateSavePackageFilename) {}

// Crashing on Windows, see http://crbug.com/79365
#if BUILDFLAG(IS_WIN)
#define MAYBE_TestLongSavePackageFilename
#else
#define MAYBE_TestLongSavePackageFilename
#endif
TEST_F(SavePackageTest, MAYBE_TestLongSavePackageFilename) {}

// Crashing on Windows, see http://crbug.com/79365
#if BUILDFLAG(IS_WIN)
#define MAYBE_TestLongSafePureFilename
#else
#define MAYBE_TestLongSafePureFilename
#endif
TEST_F(SavePackageTest, MAYBE_TestLongSafePureFilename) {}

// GetUrlToBeSaved method should return correct url to be saved.
TEST_F(SavePackageTest, TestGetUrlToBeSaved) {}

// GetUrlToBeSaved method sould return actual url to be saved,
// instead of the displayed url used to view source of a page.
// Ex:GetUrlToBeSaved method should return http://www.google.com
// when user types view-source:http://www.google.com
TEST_F(SavePackageTest, TestGetUrlToBeSavedViewSource) {}

class SavePackageFencedFrameTest : public SavePackageTest {};

// FakeLocalFrame implementation that records calls to
// GetSavableResourceLinks().
class FakeLocalFrameWithSavableResourceLinks : public FakeLocalFrame {};

// Tests that SavePackage does not create an unnecessary task that gets the
// resources links from fenced frames.
// If fenced frames become savable, this test will need to be updated.
// See https://crbug.com/1321102
TEST_F(SavePackageFencedFrameTest,
       DontRequestSavableResourcesFromFencedFrames) {}

}  // namespace content