chromium/ui/base/l10n/l10n_util_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/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "ui/base/l10n/l10n_util.h"

#include <stddef.h>

#include <cstring>
#include <memory>

#include "base/containers/flat_set.h"
#include "base/environment.h"
#include "base/files/file_util.h"
#include "base/i18n/case_conversion.h"
#include "base/i18n/rtl.h"
#include "base/i18n/time_formatting.h"
#include "base/path_service.h"
#include "base/strings/pattern.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/icu_test_util.h"
#include "base/test/scoped_path_override.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
#include "third_party/icu/source/common/unicode/locid.h"
#include "ui/base/grit/ui_base_test_resources.h"
#include "ui/base/l10n/l10n_util_collator.h"
#include "ui/base/ui_base_paths.h"

#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_APPLE)
#include <cstdlib>
#endif

ASCIIToUTF16;
UTF8ToUTF16;

namespace {

class StringWrapper {};

}  // namespace

class L10nUtilTest : public PlatformTest {};

TEST_F(L10nUtilTest, GetString) {}

#if !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_ANDROID)
// On Mac, we are disabling this test because GetApplicationLocale() as an
// API isn't something that we'll easily be able to unit test in this manner.
// The meaning of that API, on the Mac, is "the locale used by Cocoa's main
// nib file", which clearly can't be stubbed by a test app that doesn't use
// Cocoa.

// On Android, we are disabling this test since GetApplicationLocale() just
// returns the system's locale, which, similarly, is not easily unit tested.

#if BUILDFLAG(IS_POSIX) && defined(USE_GLIB) && !BUILDFLAG(IS_CHROMEOS_ASH)
const bool kPlatformHasDefaultLocale =;
const bool kUseLocaleFromEnvironment =;
const bool kSupportsLocalePreference =;
#elif BUILDFLAG(IS_WIN)
const bool kPlatformHasDefaultLocale = true;
const bool kUseLocaleFromEnvironment = false;
const bool kSupportsLocalePreference = true;
#else
const bool kPlatformHasDefaultLocale = false;
const bool kUseLocaleFromEnvironment = false;
const bool kSupportsLocalePreference = true;
#endif

void SetDefaultLocaleForTest(const std::string& tag, base::Environment* env) {}

TEST_F(L10nUtilTest, GetAppLocale) {}
#endif  // !BUILDFLAG(IS_APPLE)

TEST_F(L10nUtilTest, SortStringsUsingFunction) {}

/**
 * Helper method for validating strings that require direcitonal markup.
 * Checks that parentheses are enclosed in appropriate direcitonal markers.
 */
void CheckUiDisplayNameForLocale(const std::string& locale,
                                 const std::string& display_locale,
                                 bool is_rtl) {}

TEST_F(L10nUtilTest, GetDisplayNameForLocaleWithoutCountry) {}

TEST_F(L10nUtilTest, GetDisplayNameForLocale) {}

// TODO:(crbug.com/1456465) Re-enable test for iOS
// In iOS17, NSLocale's internal implementation was modified resulting in
// redefined behavior for existing functions. As a result,
// `l10n_util::GetDisplayNameForCountry` no longer produces the same output in
// iOS17 as previous versions.
#if BUILDFLAG(IS_IOS)
#define MAYBE_GetDisplayNameForCountry
#else
#define MAYBE_GetDisplayNameForCountry
#endif
TEST_F(L10nUtilTest, MAYBE_GetDisplayNameForCountry) {}

TEST_F(L10nUtilTest, GetParentLocales) {}

TEST_F(L10nUtilTest, IsValidLocaleSyntax) {}

TEST_F(L10nUtilTest, TimeDurationFormatAllLocales) {}

TEST_F(L10nUtilTest, GetUserFacingUILocaleList) {}

TEST_F(L10nUtilTest, PlatformLocalesIsSorted) {}

TEST_F(L10nUtilTest, IsPossibleAcceptLanguage) {}

TEST_F(L10nUtilTest, IsAcceptLanguageDisplayable) {}

TEST_F(L10nUtilTest, KeepAcceptedLanguages) {}

TEST_F(L10nUtilTest, FormatStringComputeCorrectOffsetInRTL) {}