chromium/components/url_formatter/elide_url_unittest.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/url_formatter/elide_url.h"

#include <stddef.h>

#include <algorithm>

#include "base/logging.h"
#include "base/run_loop.h"
#include "base/strings/escape.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "components/url_formatter/url_formatter.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/text_elider.h"
#include "ui/gfx/text_utils.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace {

struct Testcase {};

struct ProgressiveTestcase {};

struct UrlComponent {};

struct ParsingTestcase {};

#if !BUILDFLAG(IS_ANDROID)

// Returns the width of a utf8 or utf16 string using default UI font, or the
// provided |font_list|.
float GetWidth(const std::string& utf8,
               const gfx::FontList& font_list = gfx::FontList()) {}
float GetWidth(const std::u16string& utf16,
               const gfx::FontList& font_list = gfx::FontList()) {}

// Verify that one or more URLs passes through an explicit sequence of elided
// strings as available space progressively decreases. This helps ensure that
// transitional corner cases are handled properly. To be tolerant of
// character-width variation across platforms, the test allows a limited number
// of expected strings to be skipped mid-run.  The first and last expected
// strings must be matched. If the algorithm produces a string that isn't in the
// expected string list, the test fill fail. Example test expectations:
//
// google.com/intl/en/.../ads/   <-- Must match.
// google.com/intl/.../ads/
// google.com/.../ads/
// google.com/intl...   <- Elider can skip this, in case the 'l' does not fit.
// google.com/int...
// google.com/in...   <- Must match.
//
void RunProgressiveElisionTest(
    const std::vector<ProgressiveTestcase>& testcases) {}

void RunElisionTest(const std::vector<Testcase>& testcases) {}

// Test eliding of commonplace URLs.
TEST(TextEliderTest, TestGeneralEliding) {}

// When there is very little space available, the elision code will shorten
// both path AND file name to an ellipsis - ".../...". To avoid this result,
// there is a hack in place that simply treats them as one string in this
// case.
TEST(TextEliderTest, TestTrailingEllipsisSlashEllipsisHack) {}

// Test eliding of empty strings, URLs with ports, passwords, queries, etc.
TEST(TextEliderTest, TestElisionSpecialCases) {}

// Test eliding of file: URLs.
TEST(TextEliderTest, TestFileURLEliding) {}

TEST(TextEliderTest, TestHostEliding) {}

#endif  // !BUILDFLAG(IS_ANDROID)

struct OriginTestData {};

// Common test data for both FormatUrlForSecurityDisplay() and
// FormatOriginForSecurityDisplay()
const OriginTestData common_tests[] =;

TEST(TextEliderTest, FormatUrlForSecurityDisplay) {}

TEST(TextEliderTest, FormatOriginForSecurityDisplay) {}

TEST(TextEliderTest, FormatUrlForDisplayOmitSchemePathAndTrivialSubdomains) {}

TEST(TextEliderTest,
     FormatUrlForDisplayOmitSchemePathTrivialSubdomainsAndMobilePrefix) {}

}  // namespace