chromium/ui/gfx/text_elider_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.
//
// Unit tests for eliding and formatting utility functions.

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

#include "ui/gfx/text_elider.h"

#include <stddef.h>

#include <memory>
#include <vector>

#include "base/files/file_path.h"
#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/font.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/font_render_params.h"
#include "ui/gfx/text_utils.h"

namespace gfx {

namespace {

struct FileTestcase {};

struct Testcase {};

}  // namespace

TEST(TextEliderTest, ElideEmail) {}

TEST(TextEliderTest, ElideEmailMoreSpace) {}

TEST(TextEliderTest, TestFilenameEliding) {}

TEST(TextEliderTest, ElideTextTruncate) {}

TEST(TextEliderTest, ElideTextEllipsis) {}

TEST(TextEliderTest, ElideTextEllipsisFront) {}

// Checks that all occurrences of |first_char| are followed by |second_char| and
// all occurrences of |second_char| are preceded by |first_char| in |text|. Can
// be used to test surrogate pairs or two-character combining sequences.
static void CheckCodeUnitPairs(const std::u16string& text,
                               char16_t first_char,
                               char16_t second_char) {}

// Test that both both UTF-16 surrogate pairs and combining character sequences
// do not get split by ElideText.
TEST(TextEliderTest, ElideTextAtomicSequences) {}

TEST(TextEliderTest, ElideTextLongStrings) {}

// Detailed tests for StringSlicer. These are faster and test more of the edge
// cases than the above tests which are more end-to-end.

TEST(TextEliderTest, StringSlicerBasicTest) {}

TEST(TextEliderTest, StringSlicerWhitespace_UseDefault) {}

TEST(TextEliderTest, StringSlicerWhitespace_NoTrim) {}

TEST(TextEliderTest, StringSlicerWhitespace_Trim) {}

TEST(TextEliderTest, StringSlicer_ElideMiddle_MultipleWhitespace) {}

TEST(TextEliderTest, StringSlicerSurrogate) {}

TEST(TextEliderTest, StringSlicerCombining) {}

TEST(TextEliderTest, StringSlicerCombiningSurrogate) {}

TEST(TextEliderTest, ElideString) {}

TEST(TextEliderTest, ElideRectangleText) {}

TEST(TextEliderTest, ElideRectangleTextFirstWordTruncated) {}

TEST(TextEliderTest, ElideRectangleTextPunctuation) {}

TEST(TextEliderTest, ElideRectangleTextLongWords) {}

// This test is to make sure that the width of each wrapped line does not
// exceed the available width. On some platform like Mac, this test used to
// fail because the truncated integer width is returned for the string
// and the accumulation of the truncated values causes the elide function
// to wrap incorrectly.
TEST(TextEliderTest, ElideRectangleTextCheckLineWidth) {}

#if BUILDFLAG(IS_CHROMEOS_ASH)
// This test was created specifically to test a message from crbug.com/415213.
// It tests that width of concatenation of words equals sum of widths of the
// words.
TEST(TextEliderTest, ElideRectangleTextCheckConcatWidthEqualsSumOfWidths) {
  FontList font_list;
  font_list = FontList("Noto Sans UI,ui-sans, 12px");
  SetFontRenderParamsDeviceScaleFactor(1.25f);
#define WIDTH
  EXPECT_EQ(WIDTH(u"The administrator for this account has"),
            WIDTH(u"The ") + WIDTH(u"administrator ") + WIDTH(u"for ") +
                WIDTH(u"this ") + WIDTH(u"account ") + WIDTH(u"has"));
#undef WIDTH
  SetFontRenderParamsDeviceScaleFactor(1.0f);
}
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

TEST(TextEliderTest, ElideRectangleString) {}

TEST(TextEliderTest, ElideRectangleStringNotStrict) {}

TEST(TextEliderTest, ElideRectangleWide16) {}

TEST(TextEliderTest, ElideRectangleWide32) {}

TEST(TextEliderTest, TruncateString) {}

}  // namespace gfx