chromium/components/filename_generation/filename_generation_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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/filename_generation/filename_generation.h"

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace filename_generation {

#define FPL
#define HTML_EXTENSION
#if BUILDFLAG(IS_WIN)
#define FPL_HTML_EXTENSION
#else
#define FPL_HTML_EXTENSION
#endif

namespace {

base::FilePath GetLongNamePathInDirectory(
    int max_length,
    const base::FilePath::CharType* suffix,
    const base::FilePath& dir) {}

}  // namespace

static const struct {} kExtensionTestCases[] =;

// Crashing on Windows, see http://crbug.com/79365
#if BUILDFLAG(IS_WIN)
#define MAYBE_TestEnsureHtmlExtension
#else
#define MAYBE_TestEnsureHtmlExtension
#endif
TEST(FilenameGenerationTest, MAYBE_TestEnsureHtmlExtension) {}

// Crashing on Windows, see http://crbug.com/79365
#if BUILDFLAG(IS_WIN)
#define MAYBE_TestEnsureMimeExtension
#else
#define MAYBE_TestEnsureMimeExtension
#endif
TEST(FilenameGenerationTest, MAYBE_TestEnsureMimeExtension) {}

// Test that the suggested names generated are reasonable:
// If the name is a URL, retrieve only the path component since the path name
// generation code will turn the entire URL into the file name leading to bad
// extension names. For example, a page with no title and a URL:
// http://www.foo.com/a/path/name.txt will turn into file:
// "http www.foo.com a path name.txt", when we want to save it as "name.txt".

static const struct GenerateFilenameTestCase {} kGenerateFilenameCases[] =;

// Crashing on Windows, see http://crbug.com/79365
#if BUILDFLAG(IS_WIN)
#define MAYBE_TestGenerateFilename
#else
#define MAYBE_TestGenerateFilename
#endif
TEST(FilenameGenerationTest, MAYBE_TestGenerateFilename) {}

TEST(FilenameGenerationTest, TestBasicTruncation) {}

TEST(FilenameGenerationTest, TestTruncationFail) {}

}  // filename_generation